Have you ever had trouble with your Fibaro battery powered devices not updating thir battery state after changing the battery? Or any other battery powered Z-wave devices suddenly dying, even if you thought they had 100% battery?

That's probably because for some strange reason, the Z-Wave JS integration doesn't request battery updates from all battery powered devices on (each) wake up, and not all battery powered devices will send battery state unsolicited. To get a battery update, you need to explicitly ask for it!

There is a request for this in the Z-Wave JS project, so maybe it'll be fixed sometime soon. But luckily, there is a quick you can apply right now. I wrote an automation that will run every night requesting a battery update the next time your battery powered zwave-js devices wake up.

automation:
- alias: Nightly request for update on Z-Wave battery levels
  trigger:
  - platform: time
    at: 03:00:00
  condition: []
  action:
  - service: zwave_js.refresh_value
    data:
      entity_id: >
        {%- set find_integration = 'zwave_js' %} 
        {% set entities = states | map(attribute='entity_id') | list %}
        {%- set ns = namespace(entities = []) %}
        {%- for entity_id in entities %}
          {% if 'battery' in entity_id %}
            {%- set ids = device_attr(entity_id, 'identifiers') %}
            {%- if ids %}
              {%- set ids = ids | list | first %}
              {%- if ids and ids | length == 2 and ids[0] == find_integration %}
                {%- set ns.entities = ns.entities + [ entity_id ] %}
              {%- endif %}
            {%- endif %}
          {%- endif %}
        {%- endfor %}
        {{ ns.entities }}
      refresh_all_values: true
  mode: single

Previous Post Next Post