Howto create battery alert without creating a template for every device


#533

This is a great topic, thank you for sharing this.
I’m trying to add my August home lock to the listing since that’s the one battery I actually need to keep an eye on.
The parameter by default is: battery_level
I tried adding to customize.yaml but that didn’t work, or at least it isn’t showing up in the states page – my second question is on a card template for lovelace.

lock.front_door:                                                                                                           
   battery_template: "{{ battery_level.value | int }}"

#534

You don’t need to use customize if the attribute is named battery_level. It should be detected automatically.

I haven’t looked at Lovelace yet. I rarely use the Home Assistant UI so it keeps getting bumped by higher priority things.


#535

Odd because that’s the one device that isn’t showing up:

The difference in the entities that show up and don’t are in the attributes, the naming is capped with a space, vs. all lower case with an underscore.

+show : Battery Level: 51
-noshow: battery_level: 29

image


#536

A little progress. I disabled august, and renabled it and the battery now show up, but it’s Unknown?

Oddly enough if you open the item, it shows the battery level:

image


#537

That’s due to your battery_template. Remove that from customize, restart Home Assistant, lock or unlock your lock, then restart Home Assistant again, then lock or unlock your lock.

For completeness, the correct battery template would be { value_json.value | int }, but as I said, that is the default template, so you don’t need to specify it.


#538

Hi , I keep getting a configuration invalid error with the latest version of the battery_alert package 1.1.6. This is the error I’m getting, expected dict for dictionary value @ data['packages']['battery_alert']['retain'].

I have the battery_alert.yaml file in the config/packages folder and I’m using HASSIO version 0.84.6.

Here is what my configuration.yaml looks like.

homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  # Location required to calculate the time the sun rises and sets
  latitude: 
  longitude:
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 225
  # metric for Metric, imperial for Imperial
  unit_system: imperial
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: America/Los_Angeles
  # Customization file
  customize: !include customize.yaml
  packages: !include_dir_named packages

#539

And here is my home-assistant.log

2018-12-27 23:10:40 WARNING (MainThread) [homeassistant.components.mqtt] Data in your config entry is going to override your configuration.yaml: {'broker': '192.168.1.205', 'discovery': True, 'port': 1883}
2018-12-27 23:10:40 WARNING (MainThread) [homeassistant.components.http] legacy_api_password support has been enabled. If you don't require it, remove the 'api_password' from your http config.
2018-12-27 23:10:40 WARNING (MainThread) [homeassistant.components.mqtt] Data in your config entry is going to override your configuration.yaml: {'broker': 'core-mosquitto', 'discovery': True, 'password': 'kDrCXnQxoEQ4si5qkhzld0lYC-239t0_', 'port': 1883, 'protocol': '3.1.1', 'username': 'homeassistant'}
2018-12-27 23:10:44 WARNING (MainThread) [homeassistant.loader] You are using a custom component for media_player.alexa which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2018-12-27 23:10:45 WARNING (MainThread) [homeassistant.components.sensor.template] Template sensor pool_timer_power has no entity ids configured to track nor were we able to extract the entities to track from the value template(s). This entity will only be able to be updated manually.
2018-12-27 23:10:45 WARNING (MainThread) [homeassistant.components.sensor.template] Template sensor pool_timer_energy has no entity ids configured to track nor were we able to extract the entities to track from the value template(s). This entity will only be able to be updated manually.
2018-12-27 23:10:45 WARNING (MainThread) [homeassistant.components.sensor.template] Template sensor monoprice_plug_energy has no entity ids configured to track nor were we able to extract the entities to track from the value template(s). This entity will only be able to be updated manually.
2018-12-27 23:10:45 WARNING (MainThread) [homeassistant.components.sensor.template] Template sensor monoprice_plug_power has no entity ids configured to track nor were we able to extract the entities to track from the value template(s). This entity will only be able to be updated manually.
2018-12-27 23:10:49 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Monoprice outlet Kwh: UndefinedError: 'switch' is undefined
2018-12-27 23:10:49 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Pool timer W: UndefinedError: 'switch' is undefined
2018-12-27 23:10:49 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Pool timer Kwh: UndefinedError: 'switch' is undefined
2018-12-27 23:10:49 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Monoprice outlet W: UndefinedError: 'switch' is undefined
2018-12-27 23:23:29 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']
    - customize: [source /config/configuration.yaml:13]
      elevation: 225
      latitude: 
      longitude: 
      name: Home
      packages: [source /config/configuration.yaml:14]
        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: America/Los_Angeles
      unit_system: imperial
Successful config (partial)
  homeassistant:

Any ideas?

Thanks


#540

Did you save the package using the raw link on the github age? It looks like there must be some formatting issue with the package, and the raw link removes all of the extra stuff that might break things.


#541

I didn’t and that was exactly the problem. Thanks so much, that fixed it and it’s running now.


#542

Does anyone know why some of my created sensors don’t have the percentage symbol?


#543

@elnaor do you mind posting your version without the MQTT? I only have z-wave devices and also wanted to implement a slimmed down version of this package for my battery powered devices. Thanks.


#544

@NotoriousBDG, any idea how I can get the ‘%’ symbol back on my battery entities here?


#545

44
00

I am using the lastest version from Github and I have problems with my homematic devices which only show “High”, “Medium” or “Low”.
They are only shown with 0%

Do I have to change the battery_template_string here as well?

For my other Homematic devices, which re port Voltage level, I made a custom entry for battery_template_string which is working fine.
How to handle the other devices?

From reviewing the full thread I saw that @NotoriousBDG reported this issues as well, but I should have been resolved with an update of the package … however not for me.

Thanks
BR
Chris


#546

Can you show me a screenshot of the affected sensors from the states page? I need to see the attributes for those sensors.

All you have to do is manually create all of the battery sensors then disable the automation named Create Battery Sensor from Attributes.

It doesn’t look that sensor is from the latest version of the package. If you have the latest version installed, then a restart is probably all that’s needed to clear that up.


#547

so not totally sure what broke, but during one of the updates, this method no longer works. no sensors have been added, removed or changed. i am getting the following warning.

Template sensor low_battery has no entity ids configured to track nor were we able to extract the entities to track from the value template(s). This entity will only be updated manually.


#548

I don’t think that’s related to this package. Did you create a template sensor named low_battery?


#549

Here you go. Appreciate your work on this package!


#550

i created a template sensor, per some of the original posts back in october last year.

- platform: template
  sensors:
    low_battery:
      friendly_name: "Low Battery"
      value_template: >
        {%- set threshold = 40 -%}
        {%- set domains = ['binary_sensor', 'sensor', 'zwave', 'lock'] -%}
        {%- for domain in domains -%}
        {%- for item in states[domain] if ((item.attributes.battery_level is defined and item.attributes['battery_level'] | i$
            {{ item.attributes.friendly_name }}{%- if not loop.last %}, {% endif -%}
        {%- endfor -%}
        {%- endfor -%}

then my automation is

 id: low_battery_alert
 alias: 'Battery Alert'
trigger:
  - platform: time
    at: '10:00:00'
  - platform: time
    at: '18:00:00'
condition:
  condition: template
  value_template: "{% if states('sensor.low_battery') %}true{% endif %}"
action:
  - service: notify.notify
    data:
      title: "Low Battery"
      message: "{{ states('sensor.low_battery') }}"
  - service: persistent_notification.create
    data_template:
      title: Low Battery
      message: "{{ states('sensor.low_battery') }}"
      notification_id: low-battery-alert

#551

That sensor is not created by the package. Whichever component that created the sensor would need to be updated to add the unit_of_measurement attribute of %.


#552

There were some breaking changes recently that are causing that issue. I’d recommend updating to the latest version of the package since it’s not affected.