ZwaveJS - obtaining device / node status ("Ready" etc)

I’ve switched across to the zwavejs integration this morning in a relatively smooth fashion, however I’m struggling with the last piece of the puzzle.

I like to display z-wave network and device status on my dashboard which I did previously by reading the zwave.* entities.

Is there an equivalent way of retrieving this from the new integration someone can point me to?

I’m using zwavejsmqtt (with mqtt disabled) over websocket to homeassistant container (core running in docker).

1 Like

I think what I’m after ideally is the same information as displayed against the integration details, namely a count of the total number of nodes and the number of ready nodes.

Looks like Node status is on the roadmap:

Some form of network health check, make it easier to point out dead nodes or nodes that are slow to respond or having communication failures.

In the meantime I guess there is currently no way to retrieve the node status:

So unless there is a stop gap method of either showing node status or simply integration status I’ll have to drop this element from my dashboard.

You can use curl to monitor Zwavejs2Mqtt as shown here. This will show you if the Z-Wave server is healthy.

Add the following binary sensor to you configuration.yaml, make sure the IP address matches your Zwavejs2Mqtt docker container.

binary_sensor:
  - platform: command_line
    command: 'curl 192.168.10.100:8091/health/zwave -H "Accept: text/plain" > nul && (echo "Ok") || (echo "Error")'
    name: "Z-Wave JS Status"
    device_class: connectivity
    scan_interval: 30
    payload_on: "Ok"
    payload_off: "Error"

This will at least allow you to monitor the health of the Z-Wave JS Server.

4 Likes

That looks rather neat, thank you.

I wound up building a workaround template sensor that depends on having a group with all my zwave devices which I nearly added to this thread the other day.

#groups.yaml
zwave_devices:
  name: "zwave Devices"
  entities:
    - switch.spare_room_lamp_switch
    - switch.kitchen_lamp_switch
    - sensor.spare_room_trisensor_sensor
    - sensor.kitche_trisensor_sensor
    - sensor.dining_room_trisensor_sensor
    - switch.living_room_lamp_switch
    - binary_sensor.garden_gate
    - binary_sensor.doorbell_sensor
    - switch.network_modem

#sensors.yaml
- platform: template
  sensors:
    summary_zwave:
       friendly_name: "Zwave Overview"
       value_template: >
            {% if states('group.zwave_devices') not in ['unavailable', 'none', 'unknown'] %}
                  {% set total = (state_attr('group.zwave_devices','entity_id') | count) %}
                  {% set unavail = (states | selectattr('entity_id','in', state_attr('group.zwave_devices','entity_id')) | selectattr('state','eq','unavailable') | list | count) %}
                  {{ total - unavail }}/{{ total }}
            {% else %}
                Unknown
            {% endif %}
       icon_template: >
            {% if states('group.zwave_devices') not in ['unavailable', 'none', 'unknown'] %}
                  {% set total = (state_attr('group.zwave_devices','entity_id') | count) %}
                  {% set unavail = (states | selectattr('entity_id','in', state_attr('group.zwave_devices','entity_id')) | selectattr('state','eq','unavailable') | list | count) %}
                  {% if unavail == 0 %}
                        mdi:z-wave
                  {% elif unvail == total %}
                        mdi:alert-circle-outline
                  {% else %}
                        mdi:cached
                  {% endif %}
            {% else %}
                   mdi:alert-circle-outline
            {% endif %}

Screenshot 2021-05-30 12.59.17

1 Like

Since the addition of the “node status” in the latest release I’ve updated my sensor to the following:

group:
  zwavejs_devices:
    name: "ZwaveJS Devices"
    entities:
      - sensor.computer_room_motion_node_status_js
      - sensor.deck_camera_outlet_node_status_js
      - sensor.doorbell_node_status_js
      - sensor.east_livingroom_lights_node_status_js
      - sensor.foyer_door_sensor_node_status_js
      - sensor.west_livingroom_lights_node_status_js
      - sensor.z_stick_gen5_usb_controller_node_status_js

sensor:
  - platform: template
    sensors:
      summary_zwavejs:
        friendly_name: "ZwaveJS Overview"
        value_template: >
          {% set total = (state_attr('group.zwavejs_devices','entity_id') | count) %}
          {% set dead = expand('group.zwavejs_devices')|selectattr('state', 'eq', 'dead')|map(attribute='entity_id')|list|count %}
          {{ total - dead }}/{{ total }}
        icon_template: >
          {% set total = (state_attr('group.zwavejs_devices','entity_id') | count) %}
          {% set dead = expand('group.zwavejs_devices')|selectattr('state', 'eq', 'dead')|map(attribute='entity_id')|list|count %}
          {% if dead == 0 %}
            mdi:z-wave
          {% elif dead == total %}
            mdi:emoticon-dead-outline
          {% else %}
            mdi:alert-outline
          {% endif %}
2 Likes

Actually…I just realized that there could be a couple more states that the devices could be in.

So here is the updated template:

sensor:
  - platform: template
    sensors:
      summary_zwavejs:
        friendly_name: "ZwaveJS Overview"
        value_template: >
          {% set total = (state_attr('group.zwavejs_devices','entity_id') | count) %}
          {% set dead = expand('group.zwavejs_devices')|selectattr('state', 'in', 'dead, unavailable, unknown')|map(attribute='entity_id') | list | count %}
          {{ total - dead }}/{{ total }}
        icon_template: >
          {% set total = (state_attr('group.zwavejs_devices','entity_id') | count) %}
          {% set dead = expand('group.zwavejs_devices')|selectattr('state', 'in', 'dead, unavailable, unknown')|map(attribute='entity_id')|list|count %}
          {% if dead == 0 %}
            mdi:z-wave
          {% elif dead == total %}
            mdi:emoticon-dead-outline
          {% else %}
            mdi:alert-outline
          {% endif %}

Thank-you! How did you manage to have the Z-Wave sensors appear as entities in Home Assistant?

In Home Assistant, I can see all my Z-Wave devices and for each device I can see the Node Status as Alive and Node Ready as Yes but I cannot see the sensors as entities when I search Current entities in Developer Tools.

Is there anything I need to configure in Z-WaveJS2MQTT (I’m running version 5.5.4)? The Home Assistant documentation indicates “…the node status sensor (disabled by default) to track the node’s status” but I cannot find where to enable the node status sensor?

@wvella

If you go to the zwavejs integration page then click on the device.

on the left side at the bottom there will be something that says “+x disabled entities”.

click on it then click on the entity that is disabled and click the “enable entity” switch in the box that pops up.

1 Like

Amazing! Thank-you that worked

1 Like

One way to do it without having to list each device, though you DO need to manually enable the node_status entity in the integration config: make a template sensor that looks for entities with the name *node_status* in state dead/unavailable/unknown.

- platform: template
  sensors:
    failed_zwave:
      value_template: >
        {{ states | selectattr("entity_id", "search", "node_status") |
           selectattr('state', 'in', 'dead, unavailable, unknown') |
           map(attribute='entity_id') | list }}

Then do what you want when this sensor isn’t an empty list, example:

- alias: "Alert on failed Zwave Nodes"
  trigger:
    platform: state
    entity_id: sensor.failed_zwave
  condition:
    condition: template
    value_template: '{{ states.sensor.failed_zwave.state != "[]" }}'
  action:
    - service: notify.email
      data_template:
        title: "ZWave node failed"
        message: "{{ states.sensor.failed_zwave.state }}"
4 Likes

I tried adding your template sensor but I get this error in the log trying load it:

homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity ID: sensor.failed_zwave. State max length is 255 characters.

Well, I was testing with including ‘asleep’ sensors (since I don’t have any dead/unknown ones right now) and I think that’s why it was producing the error. Too many entities returned that maxed out that 255 character limit I guess.

Hello,
I’m trying to understand and spent a lot of time with my friend google but I did’nt manage to do it :frowning:
Here is what I have add in my configuration.yaml

binary_sensor:
  - platform: command_line
    command: 'curl 192.168.1.33:8091/health/zwave -H "Accept: text/plain" > nul && (echo "Ok") || (echo "Error")'
    name: "Z-Wave JS Status"
    device_class: connectivity
    scan_interval: 30
    payload_on: "Ok"
    payload_off: "Error"

But it’s always reported as disconnected

To be honnest I don’t uderstand the command with curl :frowning:
So I try and test to better understand but I guess I missed some point .

I tryed the curl command in a terminal

But without success.
I must admit I 'm not sure about the port but I don’t know how to check it …

Can someone help me or redirect me to some usefull information ?

Thanks, it seems to work well for me by simulating the state
it would be great to have this feature with #zigbee2mqtt

Just to add a bit more info here…

I just noticed a “new” file in my config directory and traced it back to the command_line binary sensor above. Apparently the “> nul…” portion tells it to create a file named nul and put the results into it (Ok or Error).

I found that part isn’t needed for the sensor to function (at least I’m pretty sure since it still seems to be working).

I changed it to this:

command: 'curl 192.168.1.11:8091/health/zwave -H "Accept: text/plain" '

And that matches the syntax of the example in the linked zwavejs docs as well.

no more mystery file. :slightly_smiling_face:

Hi all,

I come back to you because I progress a little bit but desperately need some help for some “basic” stuff like docker an HA supervised.

My config look like this (I have also tried without the “>null” and with the ip of HA instead of localhost

binary_sensor:
  - platform: command_line
    command: 'curl 127.0.0.1:44920/health/zwave -H "Accept: text/plain" > nul && (echo "Ok") || (echo "Error")'
    name: "Z-Wave JS Status"
    device_class: connectivity
    scan_interval: 30
    payload_on: "Ok"
    payload_off: "Error"

The entity is created but is 'disconnected"

One thing I did change is the port number from 8091 to 44920.
This is actually what I have found in the log of the supervised add-on

I also manage to use the curl command.
The curl command was not working from the ‘Terminal SSH’ add on

But is working if I launch it from the container console within Portainer

So I guess I missed some basic knowledge regarding ha supervised and docker
Actually I don’t know how to start to upskill myslef regarding this with a (not too long) tuto from A to Z

Or maybe there is just a little trick where you can help me :wink:

Hi and thanks for perfect templates! How do I make an automation that automatically pings the dead nodes that is in the “sensor-list”? I know how to use the zwave_js.ping service, but I don’t know how to reference a list instead of a single node.

How do you add name to the template list?