notoriousbdg / Home-AssistantConfig

Apache License 2.0
180 stars 49 forks source link

expected dict for dictionary value @ data['packages']['battery_alert']['retain'] #9

Closed bartandeweg closed 5 years ago

bartandeweg commented 5 years ago

After using the latest version of both your package and hassio i get this error:

expected dict for dictionary value @ data['packages']['battery_alert']['retain']

Any idea on this?

notoriousbdg commented 5 years ago

There isn't enough info to determine what could be causing that. Can you provide more logs?

bartandeweg commented 5 years ago

Sure. Thius is the full log on this topic:

2018-11-25 16:03:20 ERROR (MainThread) [homeassistant.components.hassio] INFO:homeassistant.util.package:Attempting install of colorlog==3.1.4
Testing configuration at /config
Failed config
  homeassistant: 
    - expected dict for dictionary value @ data['packages']['battery_alert']['retain']
      packages: [source /config/configuration.yaml:15]
        battery_alert: [source /config/packages/battery_alert.yaml:230]
          automation: [source /config/packages/battery_alert.yaml:360]
            - action: [source /config/packages/battery_alert.yaml:371]
                - condition: template
                  value_template: {% macro battery_level() %} {% for entity_id in states.group.battery_status.attributes.entity_id if (
  not is_state_attr(entity_id, 'battery_alert_disabled', true)
  and states(entity_id) is not none
  and (
    (
      (
        states(entity_id) is number
        or states(entity_id) | length == states(entity_id)| int | string | length
        or states(entity_id) | length == states(entity_id)| float | string | length
      )
      and states(entity_id) | int < states.input_number.battery_alert_threshold_max.state | int
      and states(entity_id) | int > states.input_number.battery_alert_threshold_min.state | int
    )
    or states(entity_id) | lower == 'low'
    or states(entity_id) | lower == 'unknown'
  )
) -%}
  {{ state_attr(entity_id, "friendly_name") }} ({{ states(entity_id) }})
{% endfor -%} {% endmacro %} {{ battery_level() | trim != "" }}
                - data_template: [source /config/packages/battery_alert.yaml:397]
                    message: {% macro battery_level() %} {% for entity_id in states.group.battery_status.attributes.entity_id if (
  not is_state_attr(entity_id, 'battery_alert_disabled', true)
  and states(entity_id) is not none
  and (
    (
      (
        states(entity_id) is number
        or states(entity_id) | length == states(entity_id)| int | string | length
        or states(entity_id) | length == states(entity_id)| float | string | length
      )
      and states(entity_id) | int < states.input_number.battery_alert_threshold_max.state | int
      and states(entity_id) | int > states.input_number.battery_alert_threshold_min.state | int
    )
    or states(entity_id) | lower == 'low'
    or states(entity_id) | lower == 'unknown'
  )
) -%}
  {{ state_attr(entity_id, "friendly_name") }} ({{ states(entity_id) }})
{% endfor -%} {% endmacro %} {{ battery_level() }}
                    notification_id: low_battery_alert
                    title: Low Battery Levels
                  service: persistent_notification.create
              alias: battery_notification
              initial_state: on
              trigger: [source /config/packages/battery_alert.yaml:363]
                - platform: time
                  minutes: /15
                  seconds: 0
                - platform: state
                  entity_id: [source /config/packages/battery_alert.yaml:368]
                    - input_number.battery_alert_threshold_min
                    - input_number.battery_alert_threshold_max
            - action: [source /config/packages/battery_alert.yaml:434]
                - condition: template
                  value_template: {% macro battery_level() %} {% for entity_id in states.group.battery_status.attributes.entity_id if (
  not is_state_attr(entity_id, 'battery_alert_disabled', true)
  and states(entity_id) is not none
  and (
    (
      (
        states(entity_id) is number
        or states(entity_id) | length == states(entity_id)| int | string | length
        or states(entity_id) | length == states(entity_id)| float | string | length
      )
      and states(entity_id) | int < states.input_number.battery_alert_threshold_max.state | int
      and states(entity_id) | int > states.input_number.battery_alert_threshold_min.state | int
    )
    or states(entity_id) | lower == 'low'
    or states(entity_id) | lower == 'unknown'
  )
) -%}
  {{ state_attr(entity_id, "friendly_name") }} ({{ states(entity_id) }})
{% endfor -%} {% endmacro %} {{ battery_level() | trim == "" }}
                - data: [source /config/packages/battery_alert.yaml:460]
                    notification_id: low_battery_alert
                  service: persistent_notification.dismiss
              alias: battery_notification_clear
              initial_state: on
              trigger: [source /config/packages/battery_alert.yaml:426]
                - platform: time
                  minutes: /15
                  seconds: 0
                - platform: state
                  entity_id: [source /config/packages/battery_alert.yaml:431]
                    - input_number.battery_alert_threshold_min
                    - input_number.battery_alert_threshold_max
            - action: [source /config/packages/battery_alert.yaml:474]
                - condition: template
                  value_template: {% macro battery_level() %} {% for entity_id in states.group.battery_status.attributes.entity_id if (
  not is_state_attr(entity_id, 'battery_alert_disabled', true)
  and states(entity_id) is not none
  and (
    (
      (
        states(entity_id) is number
        or states(entity_id) | length == states(entity_id)| int | string | length
        or states(entity_id) | length == states(entity_id)| float | string | length
      )
      and states(entity_id) | int < states.input_number.battery_alert_threshold_max.state | int
      and states(entity_id) | int > states.input_number.battery_alert_threshold_min.state | int
    )
    or states(entity_id) | lower == 'low'
    or states(entity_id) | lower == 'unknown'
  )
) -%}
  {{ state_attr(entity_id, "friendly_name") }} ({{ states(entity_id) }})
{% endfor -%} {% endmacro %} {{ battery_level() | trim != "" }}
                - data_template: [source /config/packages/battery_alert.yaml:478]
                    data: [source /config/packages/battery_alert.yaml:480]
                      attachments: [source /config/packages/battery_alert.yaml:481]
                        - color: #52c0f2
                          text: {% macro battery_level() %} {% for entity_id in states.group.battery_status.attributes.entity_id if (
  not is_state_attr(entity_id, 'battery_alert_disabled', true)
  and states(entity_id) is not none
  and (
    (
      (
        states(entity_id) is number
        or states(entity_id) | length == states(entity_id)| int | string | length
        or states(entity_id) | length == states(entity_id)| float | string | length
      )
      and states(entity_id) | int < states.input_number.battery_alert_threshold_max.state | int
      and states(entity_id) | int > states.input_number.battery_alert_threshold_min.state | int
    )
    or states(entity_id) | lower == 'low'
    or states(entity_id) | lower == 'unknown'
  )
) -%}
  {{ state_attr(entity_id, "friendly_name") }} ({{ states(entity_id) }})
{% endfor -%} {% endmacro %} {{ battery_level() }}
                          title: These devices have low battery levels
                    message: Low Battery Levels
                  service: notify.slack_notify
              alias: battery_notification_slack
              initial_state: on
              trigger: [source /config/packages/battery_alert.yaml:465]
                - platform: time
                  at: 10:00:00
                - platform: time
                  at: 18:00:00
                - platform: state
                  entity_id: [source /config/packages/battery_alert.yaml:471]
                    - input_number.battery_alert_threshold_min
                    - input_number.battery_alert_threshold_max
            - action: [source /config/packages/battery_alert.yaml:497]
                - condition: template
                  value_template: {% macro battery_level() %} {% for entity_id in states.group.battery_status.attributes.entity_id if (
  not is_state_attr(entity_id, 'battery_alert_disabled', true)
  and states(entity_id) is not none
  and (
    (
      (
        states(entity_id) is number
        or states(entity_id) | length == states(entity_id)| int | string | length
        or states(entity_id) | length == states(entity_id)| float | string | length
      )
      and states(entity_id) | int < states.input_number.battery_alert_threshold_max.state | int
      and states(entity_id) | int > states.input_number.battery_alert_threshold_min.state | int
    )
    or states(entity_id) | lower == 'low'
    or states(entity_id) | lower == 'unknown'
  )
) -%}
  {{ state_attr(entity_id, "friendly_name") }} ({{ states(entity_id) }})
{% endfor -%} {% endmacro %} {{ battery_level() | trim != "" }}
                - data_template: [source /config/packages/battery_alert.yaml:501]
                    message: {% macro battery_level() %} {% for entity_id in states.group.battery_status.attributes.entity_id if (
  not is_state_attr(entity_id, 'battery_alert_disabled', true)
  and states(entity_id) is not none
  and (
    (
      (
        states(entity_id) is number
        or states(entity_id) | length == states(entity_id)| int | string | length
        or states(entity_id) | length == states(entity_id)| float | string | length
      )
      and states(entity_id) | int < states.input_number.battery_alert_threshold_max.state | int
      and states(entity_id) | int > states.input_number.battery_alert_threshold_min.state | int
    )
    or states(entity_id) | lower == 'low'
    or states(entity_id) | lower == 'unknown'
  )
) -%}
  {{ state_attr(entity_id, "friendly_name") }} ({{ states(entity_id) }})
{% endfor -%} {% endmacro %} {{ battery_level() }}
                    title: Low Battery Levels
                  service: notify.telegram
              alias: battery_notification_telegram
              initial_state: on
              trigger: [source /config/packages/battery_alert.yaml:488]
                - platform: time
                  at: 10:00:00
                - platform: time
                  at: 18:00:00
                - platform: state
                  entity_id: [source /config/packages/battery_alert.yaml:494]
                    - input_number.battery_alert_threshold_min
                    - input_number.battery_alert_threshold_max
            - action: [source /config/packages/battery_alert.yaml:516]
                - condition: template
                  value_template: {% macro battery_level() %} {% for entity_id in states.group.battery_status.attributes.entity_id if (
  not is_state_attr(entity_id, 'battery_alert_disabled', true)
  and states(entity_id) is not none
  and (
    (
      (
        states(entity_id) is number
        or states(entity_id) | length == states(entity_id)| int | string | length
        or states(entity_id) | length == states(entity_id)| float | string | length
      )
      and states(entity_id) | int < states.input_number.battery_alert_threshold_max.state | int
      and states(entity_id) | int > states.input_number.battery_alert_threshold_min.state | int
    )
    or states(entity_id) | lower == 'low'
    or states(entity_id) | lower == 'unknown'
  )
) -%}
  {{ state_attr(entity_id, "friendly_name") }} ({{ states(entity_id) }})
{% endfor -%} {% endmacro %} {{ battery_level() | trim != "" }}
                - data_template: [source /config/packages/battery_alert.yaml:520]
                    message: {% macro battery_level() %} {% for entity_id in states.group.battery_status.attributes.entity_id if (
  not is_state_attr(entity_id, 'battery_alert_disabled', true)
  and states(entity_id) is not none
  and (
    (
      (
        states(entity_id) is number
        or states(entity_id) | length == states(entity_id)| int | string | length
        or states(entity_id) | length == states(entity_id)| float | string | length
      )
      and states(entity_id) | int < states.input_number.battery_alert_threshold_max.state | int
      and states(entity_id) | int > states.input_number.battery_alert_threshold_min.state | int
    )
    or states(entity_id) | lower == 'low'
    or states(entity_id) | lower == 'unknown'
  )
) -%}
  {{ state_attr(entity_id, "friendly_name") }} ({{ states(entity_id) }})
{% endfor -%} {% endmacro %} {{ battery_level() }}
                    title: Low Battery Levels
                  service: notify.pushover
              alias: battery_notification_pushover
              initial_state: on
              trigger: [source /config/packages/battery_alert.yaml:507]
                - platform: time
                  at: 10:00:00
                - platform: time
                  at: 18:00:00
                - platform: state
                  entity_id: [source /config/packages/battery_alert.yaml:513]
                    - input_number.battery_alert_threshold_min
                    - input_number.battery_alert_threshold_max
            - action: [source /config/packages/battery_alert.yaml:554]
                - data_template: [source /config/packages/battery_alert.yaml:556]
                    payload: {
  {% if trigger.event.data.new_state.attributes.battery_level is defined -%}
    {%- set attribname = 'battery_level' -%}
  {%- elif trigger.event.data.new_state.attributes.battery is defined -%}
    {%- set attribname = 'battery' -%}
  {%- elif trigger.event.data.new_state.attributes['Battery numeric'] is defined -%}
    {%- set attribname = 'Battery numeric' -%}
  {%- endif -%}
  "name": "{{ trigger.event.data.new_state.name }} Battery",
  "state_topic": "homeassistant/sensor/{{ trigger.event.data.entity_id.split('.')[1] }}_battery/state",
  {% if trigger.event.data.new_state.attributes.battery_template is defined -%}
  "value_template": "{{ trigger.event.data.new_state.attributes.battery_template }}",
  "unit_of_measurement": "%",
  "device_class": "battery",
  {% elif trigger.event.data.new_state.attributes.battery_template_string is defined -%}
  "value_template": "{{ trigger.event.data.new_state.attributes.battery_template_string }}",
  "icon": "mdi:battery",
  {% else -%}
  "value_template": "{{ "{{" }} value_json.value | int {{ "}}" }}",
  "unit_of_measurement": "%",
  "device_class": "battery",
  {% endif -%}
  "unique_id": "{{ trigger.event.data.entity_id.split('.')[1] }}_battery",
  "json_attributes": [
    "entity_id",
    "{{ attribname }}",
    "mqtt_config_topic",
    "mqtt_state_topic"
  ]
}
                    retain: True
                    topic: homeassistant/sensor/{{ trigger.event.data.entity_id.split('.')[1] }}_battery/config
                  service: mqtt.publish
                - data_template: [source /config/packages/battery_alert.yaml:591]
                    payload: {
  {% if trigger.event.data.new_state.attributes.battery_level is defined -%}
    {%- set attribval = trigger.event.data.new_state.attributes.battery_level -%}
    {%- set attribname = 'battery_level' -%}
  {%- elif trigger.event.data.new_state.attributes.battery is defined -%}
    {%- set attribval = trigger.event.data.new_state.attributes.battery -%}
    {%- set attribname = 'battery' -%}
  {%- elif trigger.event.data.new_state.attributes['Battery numeric'] is defined -%}
    {%- set attribval = (trigger.event.data.new_state.attributes['Battery numeric'] | int + 1) * 10 -%}
    {%- set attribname = 'Battery numeric' -%}
  {%- endif -%}
  "value": {%- if attribval | int == attribval -%}
    {{ attribval }}
  {%- elif attribval | float == attribval -%}
    {{ attribval }}
  {%- elif attribval | length == attribval | float | string | length -%}
    {{ attribval | float }}
  {%- elif attribval | length == attribval | int | string | length -%}
    {{ attribval | int }}
  {%- else -%}
    "{{ attribval }}"
  {%- endif %},
  "entity_id": "{{ trigger.event.data.entity_id }}",
  {% if attribname is defined -%}
  "{{ attribname }}": "{{ attribval }}",
  {%- endif %}
  "mqtt_config_topic": "homeassistant/sensor/{{ trigger.event.data.entity_id.split('.')[1] }}_battery/config",
  "mqtt_state_topic": "homeassistant/sensor/{{ trigger.event.data.entity_id.split('.')[1] }}_battery/state"
}
                    retain: True
                    topic: homeassistant/sensor/{{ trigger.event.data.entity_id.split('.')[1] }}_battery/state
                  service: mqtt.publish
              alias: battery_sensor_from_attributes
              condition: [source /config/packages/battery_alert.yaml:529]
                - condition: template
                  value_template: {{ trigger is not none }}
                - condition: template
                  value_template: {{ trigger.event.data is not none }}
                - condition: template
                  value_template: {{ trigger.event.data.old_state is not none }}
                - condition: template
                  value_template: {{ trigger.event.data.new_state is not none }}
                - condition: template
                  value_template: {{ trigger.event.data.new_state.attributes is not none }}
                - condition: template
                  value_template: {{ 'battery' not in trigger.event.data.new_state.name | lower }}
                - condition: template
                  value_template: {{ not is_state_attr(trigger.event.data.entity_id, 'device_class', 'battery') }}
                - condition: template
                  value_template: {{ not is_state_attr(trigger.event.data.entity_id, 'battery_sensor_creation_disabled', true) }}
                - condition: or
                  conditions: [source /config/packages/battery_alert.yaml:547]
                    - condition: template
                      value_template: {{ trigger.event.data.new_state.attributes.battery_level is defined }}
                    - condition: template
                      value_template: {{ trigger.event.data.new_state.attributes.battery is defined }}
                    - condition: template
                      value_template: {{ trigger.event.data.new_state.attributes['Battery numeric'] is defined }}
              initial_state: on
              trigger: [source /config/packages/battery_alert.yaml:526]
                - platform: event
                  event_type: state_changed
            - action: [source /config/packages/battery_alert.yaml:632]
                - data_template: [source /config/packages/battery_alert.yaml:634]
                    entities: {%- for item in states.sensor if (
  is_state_attr(item.entity_id, 'device_class', 'battery')
  or 'battery' in item.attributes.icon | lower
  or (item.entity_id | lower).endswith('_bat')
  or (item.name | lower).endswith('_bat')
  ) or (
    (
      'battery' in item.entity_id | lower
      or 'battery' in item.name | lower
    ) and (
      item.attributes.icon is not defined
    ) and (
      not is_state_attr(item.entity_id, 'battery_alert_disabled', true)
    )
  )
-%}
  {{ item.entity_id }}{% if not loop.last %}, {% endif %}
{%- endfor -%}
                    object_id: battery_status
                  service: group.set
              alias: update_battery_status_group_members
              initial_state: on
              trigger: [source /config/packages/battery_alert.yaml:626]
                - platform: homeassistant
                  event: start
                - platform: time
                  minutes: /5
                  seconds: 0
            - action: [source /config/packages/battery_alert.yaml:664]
                - data_template: [source /config/packages/battery_alert.yaml:666]
                    topic: {{ states.input_text.clear_mqtt_topic.state }}
                  service: mqtt.publish
              alias: clear_mqtt_topic
              condition: [source /config/packages/battery_alert.yaml:661]
                - condition: template
                  value_template: {{ 'homeassistant/sensor/' in states.input_text.clear_mqtt_topic.state }}
              initial_state: on
              trigger: [source /config/packages/battery_alert.yaml:657]
                - platform: state
                  entity_id: [source /config/packages/battery_alert.yaml:659]
                    - input_text.clear_mqtt_topic
          group: [source /config/packages/battery_alert.yaml:306]
            battery_alert: [source /config/packages/battery_alert.yaml:313]
              control: hidden
              entities: [source /config/packages/battery_alert.yaml:315]
                - input_number.battery_alert_threshold_min
                - input_number.battery_alert_threshold_max
                - input_text.clear_mqtt_topic
                - automation.battery_notification
                - automation.battery_notification_clear
                - automation.battery_notification_slack
                - automation.battery_notification_telegram
                - automation.battery_notification_pushover
                - automation.battery_sensor_from_attributes
                - automation.update_battery_status_group_members
                - automation.clear_mqtt_topic
            battery_view: [source /config/packages/battery_alert.yaml:307]
              entities: [source /config/packages/battery_alert.yaml:309]
                - group.battery_status
                - group.battery_alert
              view: True
          homeassistant: [source /config/packages/battery_alert.yaml:231]
            customize: [source /config/packages/battery_alert.yaml:235]
              automation.battery_notification: [source /config/packages/battery_alert.yaml:263]
                friendly_name: Battery Notification
                icon: mdi:comment-alert-outline
                package: battery_alert
              automation.battery_notification_clear: [source /config/packages/battery_alert.yaml:268]
                friendly_name: Battery Notification Clear
                icon: mdi:comment-remove-outline
                package: battery_alert
              automation.battery_notification_pushover: [source /config/packages/battery_alert.yaml:283]
                friendly_name: Battery Notification Pushover
                icon: mdi:comment-alert-outline
                package: battery_alert
              automation.battery_notification_slack: [source /config/packages/battery_alert.yaml:273]
                friendly_name: Battery Notification Slack
                icon: mdi:comment-alert-outline
                package: battery_alert
              automation.battery_notification_telegram: [source /config/packages/battery_alert.yaml:278]
                friendly_name: Battery Notification Telegram
                icon: mdi:comment-alert-outline
                package: battery_alert
              automation.battery_sensor_from_attributes: [source /config/packages/battery_alert.yaml:288]
                friendly_name: Create Battery Sensor from Attributes
                icon: mdi:battery-charging-wireless-outline
                package: battery_alert
              automation.clear_mqtt_topic: [source /config/packages/battery_alert.yaml:298]
                friendly_name: Clear a Retained MQTT Topic
                icon: mdi:server-remove
                package: battery_alert
              automation.update_battery_status_group_members: [source /config/packages/battery_alert.yaml:293]
                friendly_name: Update Battery Status Group Members
                icon: mdi:group
                package: battery_alert
              group.battery_alert: [source /config/packages/battery_alert.yaml:248]
                control: hidden
                friendly_name: Battery Alert
                icon: mdi:steam
                package: battery_alert
              group.battery_status: [source /config/packages/battery_alert.yaml:254]
                control: hidden
                friendly_name: Battery Status
                icon: mdi:battery-charging
                package: battery_alert
              group.battery_view: [source /config/packages/battery_alert.yaml:243]
                friendly_name: Batteries
                icon: mdi:battery-alert
                package: battery_alert
              package.node_anchors: [source /config/packages/battery_alert.yaml:236]
                customize: [source /config/packages/battery_alert.yaml:236]
                  package: battery_alert
          input_number: [source /config/packages/battery_alert.yaml:331]
            battery_alert_threshold_max: [source /config/packages/battery_alert.yaml:332]
              icon: mdi:arrow-collapse-up
              max: 100
              min: -1
              mode: slider
              name: Max Alert Threshold
            battery_alert_threshold_min: [source /config/packages/battery_alert.yaml:340]
              icon: mdi:arrow-collapse-down
              max: 100
              min: -1
              mode: slider
              name: Min Alert Threshold
          input_text: [source /config/packages/battery_alert.yaml:351]
            clear_mqtt_topic: [source /config/packages/battery_alert.yaml:352]
              initial: 
              mode: text
              name: MQTT Topic to Clear
          retain: True
      time_zone: Europe/Amsterdam
      unit_system: metric
Successful config (partial)
  homeassistant:
notoriousbdg commented 5 years ago

Can you show me what the homeassistant: section of configuration.yaml looks like?

bartandeweg commented 5 years ago

Sure:

homeassistant:
  name: xxxxxx
  latitude: xx.xxxx33
  longitude: x.xxxx13
  elevation: 0
  unit_system: metric
  time_zone: Europe/Amsterdam
  customize: !include customize.yaml 
  packages: !include_dir_named packages
jumping2000 commented 5 years ago

After using the latest version of both your package and hassio i get this error:

expected dict for dictionary value @ data['packages']['battery_alert']['retain']

Any idea on this?

I also have this error on hass.io 0.84.2 and package 1.1.6 (2018-11-21)

notoriousbdg commented 5 years ago

Not sure if you are still having this issue, but copy/paste from the regular page can introduce some unwanted garbage. Try using the raw link to copy/paste from. That's fixed this issue for others.

bartandeweg commented 5 years ago

This is fixing the problem indeed. It is working again. Any idea how to get this up and running using lovelace?

notoriousbdg commented 5 years ago

Glad to hear that fixed the issue. I haven't looked at lovelace yet, so I don't know if there are any issues.

jumping2000 commented 5 years ago

Not sure if you are still having this issue, but copy/paste from the regular page can introduce some unwanted garbage. Try using the raw link to copy/paste from. That's fixed this issue for others.

ok, it works, thank you