Ping Z-Wave Device To See If It's Unavailable

I have a smart switch connected to a GFCI outlet. I want to determine if the circuit has been tripped, causing the outlet to stop providing power. I was thinking that I could just check to see if the smart switch became unavailable. It doesn’t have a battery so I would expect it to become unavailable when power is removed. I think I know how to check this status. What I’m struggling with is how to force it to change status as soon as power disappears (or soon after). Right now, the status shows “alive” long after I unplug it. I thought about using the z-wave ping but that seems to require the device ID For the life of me, I can’t seem to figure out how to determine that. I’ve seen several other posts about this but none of them match the HA I am using.
I’m also not sure if this is the right approach either. Basically, I want to send something to the switch periodically that causes it to update its node status so I can check it.
Sorry if this has been answered. I searched but couldn’t find a solution that seemed to fit. I’d appreciate some guidance.
I have the latest version of HA and would like to use Node Red although if an automation is a lot easier, I could do that too.

I think you’re asking how to determine the z-wave id easily? Open the integration, select a device, and in the “Device Info” box there is a menu drop-down that says “Z-wave Info”. Click the down arrow next to that to show the device id. See the example after clicking the arrow.

Ok, I saw that. But is that the ID I would use in the ping? I believe this is the node ID, not the device ID. I thought the device ID was a long string that was specific to the device itself. Maybe I’m wrong though.

If it’s just one specific device, use the ping button.

I actually tried that too. But, I let it run for about 10 mins and the device status never changed.

Ping is instant. You would need to run an automation that pings at N interval.

Sorry, that’s what I did. I used node red to press the ping button once per minute. I never saw a change in status

Then the device is still alive. Are you sure tripping the GFCI doesn’t take down the Z-Wave portion? I would assume that continues to work, it’s only the outlets that are offline.

N/M, Sorry, I misread. It’s not a smart outlet.

To test this, I’m unplugging the device :slight_smile:

Then a Ping will work. Are you sure it’s not a node-red problem? Did you try it in HA?

Ok, trying it in HA is a good idea. Node Red has been great for me so far, but I suppose there could be an issue specific to this. Maybe I’m using the action node wrong. I’m using the input_button.press action on the entity button.node_101_ping, which corresponds to the switch.

That sounds correct to me.

If the device is unplugged and has no power, a ping should detect that, change the device to dead, and the entities will become unavailable.

Ok, thanks. This shouldn’t be this hard :). Very weird…
I’ll mess around some more and report back.

You’re right, it shouldn’t be that hard. If the problem persists, I’d start to look at the debug logs.

https://www.home-assistant.io/integrations/zwave_js/#how-do-i-access-the-z-wave-logs

1 Like

Ok, update…
Ironically, I managed to figure out the device ID even though I really wasn’t looking for it right now :). As it turns out, when I select the device (in the Devices tab of the Devices and Services section in Settings), the URL that is in the browser URL bar contains the device ID. If I use this device ID and zwave_js.ping, everything works as expected. The device comes back as dead when I try to ping it.
So, either the button press action isn’t working or it’s not doing what I thought it would. It’s ok though. I have the functionality I need.
As an aside, I’m puzzled as to why the device ID isn’t just included in the z-wave info of the device. This would have made things a lot easier for me.
Thanks for the help.

You don’t need the device ID to use the ping action. You can use the ID of any entity that belongs to the device.

The button and action are identical in implementation, so not sure why you’d see a difference.

OK, great. Thanks for that. Yeah, I just confirmed I can just pass:
{ “entity_id”: “switch.freezer_smart_plug” }

aka using the friendly name for the entity.

The other irony here is that we’ve had this freezer for at least 5 years and the GFCI tripped just once when some HVAC installers forgot to turn off power when messing with the circuit. What’s annoying (and unrelated to HA) is that there’s only one outlet on this circuit that has the reset button and it’s not the one connected to the freezer :). It’s one that is hidden inside of a cabinet on another wall of the garage. It took us 15 mins to find the reset when it tripped.
So, now that I have this automation to detect the issue, I’m sure it will never happen. But I’m sure I’m not the only person who has HA and spends time looking for excuses to automate stuff :).

As for why the button press approach doesn’t work, that’s still a mystery. Maybe I’ll experiment more when I’m bored.

I use the button.press action (in HA automation), not input_button.press to perform the ping. Is that action available in Node Red?

Like you, I use HA to monitor my breaker panel box. I took it a step further and decided to monitor everything possible for each circuit. The end result looks like this.

I wanted this page to be comprehensive, easy to use, and be very customizable depending on my needs. Every circuit can be changed from ‘Active & Enabled’ to either ‘Active & Muted’, ‘Tripped’, ‘Suppressed’ or ‘Unmonitored’. It ended up be a fair amount of code in the template and the underlying page, but it works perfectly for both Z-Wave and WiFi devices. This page uses the SIDEBAR layout, and each circuit has a conditional page that displays the devices and their status.


I get an audible and visual alert if a breaker trips, using ChimeTTS with Sonos speakers and various LED lighting strips (TV backlights & Kitchen cabinets). I can turn off the alert if I need to or it gets cleared automatically when the breaker is reset and the devices come back online. In addition, I did not want some circuits to wake us up in the middle of the night if just the wifi went offline for a reboot or some other issue, so all alerts can be muted. Any suppressed notification is added to my morning briefings.

As you can see, circuit 19 is currently MUTED, as I am in the process of changing the two fans on one switch to two fans, each on their own Sonoff controller. I will update the code after the second controller is installed later today.

There is also the ability to turn off the entire system. This is helpful during ZW JS UI updates, router outages, ESPHome updates and other things. Each of these automated processes can turn off the critical alerts boolean before starting the update, and turn it back on upon completion.

If you’d like to see the code behind this system, I’d be happy to share it with you. For inspiration, I’ve included a small chunk of code that can be placed in a Markdown Card to identify offline devices, both Z-Wave and Wifi. Just change the sensors to match those in your configuration.

type: markdown
content: >-
  {% set count = namespace(value=0) %}
  {% set zwave_sensors = [
    'sensor.3d_printer_group_node_status',
    'sensor.bench_light_node_status',
    'sensor.china_cabinet_node_status',
    'sensor.coffee_bar_leds_node_status',
    'sensor.entertainment_center_node_status',
    'sensor.front_porch_master_node_status',
    'sensor.garage_master_node_status',
    'sensor.garage_relay_1_node_status',
    'sensor.garage_relay_2_node_status',
    'sensor.guest_br_light_node_status',
    'sensor.house_floods_node_status',
    'sensor.kitchen_4in1_node_status',
    'sensor.kitchen_cans_node_status',
    'sensor.kitchen_pendants_node_status',
    'sensor.kitchen_uc_leds_node_status',
    'sensor.living_room_4in1_node_status',
    'sensor.living_room_cans_node_status',
    'sensor.lr_fan_node_status',
    'sensor.master_bath_fan_node_status',
    'sensor.master_bath_lights_node_status',
    'sensor.master_bath_shower_node_status',
    'sensor.master_br_cans_node_status',
    'sensor.office_4in1_node_status',
    'sensor.office_desk_lamp_node_status',
    'sensor.office_light_node_status',
    'sensor.outdoor_plug_3_node_status',
    'sensor.outside_amp_group_node_status',
    'sensor.pergola_node_status',
    'sensor.screenroom_lights_node_status',
    'sensor.soffit_west_node_status',
    'sensor.stairway_xmas_tree_node_status',
    'sensor.sunroom_4in1_node_status',
    'sensor.sunroom_floods_node_status',
    'sensor.sunroom_lights_node_status',
    'sensor.tstat1_node_status',
    'sensor.tstat2_node_status',
    'sensor.tv_nook_lights_node_status'
    ] %}
  {%- for zwave_sensor in zwave_sensors -%}
  {%- if states(zwave_sensor)|lower in ['','unknown','unavailable','off','dead']
  %}
  {%- set count.value = count.value + 1 %}
  [{{ zwave_sensor }}]  
  {%- endif -%}
  {%- endfor %}
  {%- if count.value > 0 %}
  **{{ count.value }} Z-Wave devices offline!**
  {%- endif -%}
  {%- if count.value < 1 %}
  **No Z-Wave devices are offline at this time.**
  {%- endif -%}

  {% set count = namespace(value=0) %}
  {% set wifi_sensors = [
    'fan.sunroom_1',
    'fan.sunroom_2',
    'binary_sensor.esp_kitchen',
    'binary_sensor.esp_livingroom',
    'binary_sensor.esp_sunroom',
    'binary_sensor.esp_master_bed_bath',
    'binary_sensor.esp_office',
    'climate.sr_minisplit',
    'binary_sensor.miscale_status',
    'sensor.ultrasonic_distance',
    'binary_sensor.ping_kitchen_roku_tv',
    'binary_sensor.ping_garage_roku_tv',
    'light.wled_house_master',
    'light.desk_keyboard'
    ] %}
  {%- for wifi_sensor in wifi_sensors -%}
  {%- if states(wifi_sensor)|lower in ['','unknown','unavailable','dead'] %}
  {%- set count.value = count.value + 1 %}
  {{ state_attr(wifi_sensor, 'friendly_name') }} is {{ states(wifi_sensor)|upper
  }}   
  {%- endif -%}
  {%- endfor %}
  {%- if count.value > 0 %}
  **{{ count.value }} WiFi devices offline!**
  {%- endif -%}
  {%- if count.value < 1 %}
  **No WiFi devices are offline at this time.**
  {%- endif -%}
view_layout:
  position: sidebar
title: Offline Devices

Even though this turned out to be a pretty big undertaking, I’m really happy with how it works and I have the peace of mind knowing that a tripped breaker will not go unnoticed.

Art - aka kartcon

Whoops, this is the correct answer. The ping button would use button.press action. Pressing the button from the UI would do the same thing.