Z Wave Battery Notification Help

I am trying to develop an automation that alerts me to a low battery level on any of my z wave devices, but I am getting some errors after I reload the automation module. Note that the config checker does not result in any errors and the log file does not show any errors from actually loading it, but shows this (multiple times):

2017-07-26 13:58:45 ERROR (MainThread) [homeassistant.components.websocket_api] WS 1714641200: Client exceeded max pending messages [2]: 512

I think this might mean that too many messages are trying to go through Join? Will this format of an automation actually work? There are 20 actual devices listed in my config.

Config (slightly scrubbed):

  - alias: Battery Notifications
    trigger:
      - platform: numeric_state
        entity_id:
          - zwave.entity1
          - zwave.entity2
          - zwave.entity3
          - etc......
        value_template: "{{ state.attributes.battery_level }}"
        below: '20'
    action:
      service: notify.join_name
      data:
        message: 'Battery is low'

If I get it to work, I will work on formatting the message to output the triggering entity id.

Thanks.

2 Likes

I found another thread that helped me simplify this but the notification does not work correctly. Instead of “(Friendly_name of entity) needs new batteries” it says " Low Battery Alert needs new batteries." Anyone have any ideas?

  - alias: Low Battery Notification
    hide_entity: True
    trigger:
      - platform: template
        value_template: >
          {% for zwave in states.zwave if zwave.attributes.battery_level %}
            {%- if zwave.attributes.battery_level | int < 60 -%}
              {{true}}
            {%- endif -%}
          {%- endfor -%}
    action:
      - service: notify.join_name
        data_template:
          message: >
            {{ trigger.to_state.attributes.friendly_name }} needs new batteries.
6 Likes

Restarted HASS and it works now.

1 Like

I am trying to make this for alle binary_sensors. How do you trigger this for a test? I have the following code:

  • alias: Low Battery Notification
    hide_entity: false
    trigger:
    • platform: template
      value_template: >
      {% for binary_sensor in states.binary_sensor if binary_sensor.attributes.battery_level %}
      {%- if binary_sensor.attributes.battery_level | int < 60 -%}
      {{true}}
      {%- endif -%}
      {%- endfor -%}
      action:
    • service: notify.ios_iphone
      data_template:
      message: >
      {{ trigger.to_state.attributes.friendly_name }} needs new batteries.

have you ever figured this out?

This use case is covered in the topic below.

1 Like

The automation posted in this topic was helpful, however it was only triggering once and it wasn’t sending the correct entity id in the notifications.

This automation will trigger every day at a certain time and it will send the correct friendly names and current battery levels in the notification.

- alias: 'Low Battery Notification'
  trigger:
    platform: time
    at: '17:30:00'
  condition:
    condition: template
    value_template: >
      {%- for zwave in states.zwave if zwave.attributes.battery_level is defined and zwave.attributes.battery_level | int < 25 -%}
        {%- if loop.index == 1 -%} {{ True }} {%- endif -%}
      {%- endfor -%}
  action:
    - service: notify.ios_chris_iphone
      data_template:
        message: >
          {%- for zwave in states.zwave if zwave.attributes.battery_level is defined and zwave.attributes.battery_level | int < 25 -%}
            The {{zwave.attributes.friendly_name | replace('_', ' ') }} battery is at {{ zwave.attributes.battery_level }}%!{{'\n'}}
          {%- endfor -%}
3 Likes

I have a similar config that runs att 06, 12 and 18:00 every day.

Still, When I’m planning to be out of the house for some days, I have also created a group on the frontend showing me all the current battery levels.

Yeah after I created that automation, I too ended up creating a group in the front end that shows the battery status of all devices.

1 Like