Can I use results from ping or polling with Z-Wave JS to see if the network is functioning?

I have for several years been toggling a separate switch every minute to see if the Z-Wave network is functioning (an automation triggered by the switch toggling has sendt a “pulse” message to the main “keep alive” system, which is EventGhost). And the switch is still ticking along every minute. But with Z-Wave JS, is there a way to use a ping to one device that’s always there (like a Heat It! thermostat) instead?

The problem is that if I query the thermostat the regular way in Hass I’m pretty sure that it will answer with the info that’s already in Hass, not go directly on the thermostat. At least that’s what I was told when I first wanted to set up a pulse syste like this, which is why I went for a separate switch. The thermostats sends a message every now and then, but only if there are changes in temperature, I believe. I’ve seen it go 4-5 minutes without any of the five thermostats sending anything. That’s far too long. Kind of annoying for my wife to wait five minutes to get the tv on because the Pi needs a reboot,. and when something annoys my wife it usually means that “nothing in this stupid system of yours is ever working” isn’t far away. :scream: , I ideally would like to know within ten seconds if something’s gone wrong, but with a physical switch that seemed too much, I figured it wouldn’t last long with so many toggles. So is there another thing I can use for this?

I do not understand why you need this. You need it to just see the state of the thermostats and your current solution is to restart? Are you actually having problems with your network? In 6 years, I’ve never had my network go down or have issues with devices. But I have a very strong mesh. So I’m very confused by your post.

I have around 50 devices, and every now and then Hass or the Pi with the Z-Stick has locked up. With the switch toggling it does a reboot maybe once every second month or so. So I guess technically it’s not the network itself, but the Pi. If I can’t see a dvice I know is always there (the best would of course be to poll two different thermostats on different power circuits, so it won’t reboot if the fuse is flipped for some reason), I want a reboot of the Pi with a custom Python script I use, and if that isn’t happening (so the system is up again within a couple of minutes) I want the keep alive system to use the secondary Z-Wave setup (through a Tellstick Z-Wave device) to turn off the power on the Z-Wave plug the Pi is plugged into and then turn it on again, since it means that the Z-Wave Pi has locked up hard.

Im with Petro, something rlse is wrong in your install.

I recently fought through stalls in my ZWave mesh and it was due tonanknown issue with 700-chip based conttollers. So I used the item below until I could fix the problem.

right or wrong, here are a couple things i do:

zwavejs_status:
  value_template: >-
    {% set total = (states|selectattr('entity_id', 'search', 'node_status')|list|count) %}
    {% set good = (states|selectattr('entity_id', 'search', 'node_status')|selectattr('state', 'in', 'alive, asleep, awake')|list|count) %}
    {% set dead = (states|selectattr('entity_id', 'search', 'node_status')|selectattr('state', 'in', 'dead, unavailable, unknown')|list|count) %}
    {%- if (total == good) and (dead == 0) -%}
      on
    {%- elif (total != good) or (dead >=1) -%}
      off 
    {%- elif (good == 20) -%}
      starting
    {%- endif %}

and

- id: 'j1'
  alias: Z-Wave Network Ready Notification
  trigger:
    - platform: homeassistant
      event: start
    - platform: state
      entity_id: sensor.zwavejs_status
  mode: queued
  action:
    service_template:  >-
      {%- if is_state('input_boolean.onehome', 'off') or
             not is_state('device_tracker.one_iphone', 'home') and
             is_state('sensor.two_s_ipad_ssid', 'ItBurnsWhenIP') -%}
            notify.mobile_app_one_iphone
      {% else %}
            notify.ios_one
      {% endif %}
    data:
      message: >-
        The Zwavejs Network {% if is_state('sensor.zwavejs_status', 'on') %}is operational.
        {% elif is_state('sensor.zwavejs_status', 'off') %}is down or some nodes are having issues.
        {% elif is_state('sensor.zwavejs_status', 'starting') %}has started and looks to be progressing towards operational.
        {% else %}is totally borked!!!
        {% endif %} 
        {%- set total = (states|selectattr('entity_id', 'search', 'node_status')|list|count) -%}
        {% set good = (states|selectattr('entity_id', 'search', 'node_status')|selectattr('state', 'in', 'alive, asleep, awake')|list|count) -%}
        {% set dead = (states|selectattr('entity_id', 'search', 'node_status')|selectattr('state', 'in', 'dead, unavailable, unknown')|list|count) -%}
          Total={{ total }} Good={{ good }} Dead={{ dead }}
      title: "Home Assistant Z-Wave JS Network"

@NathanCu When it happens about once every two months? I don’t really see any point in doing an open heart surgery for a papercut on my finger, I prefer a band-aid for that… :rofl: Oh, not to mention that I did a full setup from ground up in the fall (when moving to Z-Wave JS to MQTT) only keeping my Hass automatioms and settings, and Node-RED flows, and that didn’t change the frequency of the lockups.

@pdobrien3 Thanks for answering my actual question, Dan! I will look at those two! :+1:

Hass shouldn’t be locking up either. I feel like you should fix the problem, not band aide it. Just my 2 cents.

This ZWaveJS is different than the old Zwave. It runs in a separate container, next to HA. Your zwave network will stay in tact if hass locks up.

As for hass locking up, I recommend moving your database to the mariadb addon or put the database on a separate computer.

You shouldn’t have to restart HA at all and adding these bandaides masks the problem instead of fixing it.

1 Like

Not “all these band aids”. Only one. And I’m not even sure if it’s in Hass, it may be something deep inside the Node-RED flows that does this. It’s just too many moving parts to even bother to try to solve. I would probably have tried if it suddenly changed to once a day or more, but when it’s so infrequent and the band-aids work for me, I can’t justify spending any time on it. Time is something I don’t really have much of at all.

Oh, and there’s no container here, I don’t use Docker.

It’s impossible to run ZwaveJS without running in a container unless you manually installed the server via commandline on your pi. Are you running hassOS? If yes, then you’re running ZwaveJS in a container.

Personally it would drive me insane to have a system that locks up every few weeks / months, but OK that’s me. I get that you don’t want to spend time on it and prefer to auto-reboot it, fair enough. What I don’t get is why do you need to constantly ping a zwave switch (and generate totally unneeded network traffic on an already low bandwidth mesh) to check if your Pi/HA crashed ? That’s the textbook use case for a watchdog. The exact type would depend on what exactly crashes, which is not very clear from your posts.

1 Like

Yep, “set it and forget it” is the way of the production environment.

2 Likes

Just to clarify what my sensor and automation does. It uses the node_status entity_id to check the state of all the nodes in your mesh. If one of your devices goes dead, unavailable, or unknown, it will notify you. It also runs the automation at HAss start to tell you the status of your mesh. I also have a sensor that checks the status of the zwavejs UI to see if it is up or down. If you use my sensors, and the issue happens, and you don’t get notified, the problem is not your mesh.

As a throw it out there and see if it sticks, I had issues recently that I ultimately attributed to a failing hard drive. I run zwavejs on a raspi3 with usb boot. Through dmesg I was able to see drive issues and confirm them through smartctl. Have you checked the status of your sd card?

@petro It’s actually easy: You start with an official, bare bones image from Raspberrypi.com, update it, activate VNC interface and then do the rest from a workstation: Install what you want and not what some developer thinks you should want, like Node-RED, latest stable Python, Hass, Z-Wave JS to MQTT (mostly because of the GUI, which I like better for inclusion, groups and stuff like that), Geany (for YAML editing) and a few other things. I had my first experience with Linux in the very early 90’s (after some years with Atari 520ST, MS-DOS, OS/2 and Windows), and I still prefer to do it that way. But I must admit I’m mostly a Windows guy, I run my servers on Win Server 2019 and my VMs for different purposes are mostly Win 7 (I do have some Win 10, but I really don’t like it, it’s turning my PC into a cell phone for the millenium generation, luckily I can retire in six years and won’t have to be a part of that ride anymore).

And my way IS set and forget, as I said all of the bimonthly problems are caught within a minute or two and then fixed right away. I do suspect my Norwegian made ID Lock or one of the mentioned Swedish made Heat it! thermostats (some of the around 20 constants in the system since I set it up, the rest are basically simple switches, and I can’t imagine those will misbehave) has a problem, but as long as it doesn’t bother me more than this I won’t take the time to solve it. Not to mention that it will cost me at least 200 dollars if I find that it’s a thermostat, because I will need an electrician to replace it, and they are expensive in Norway.

@HeyImAlex I guess I’m a bit less OCD about this, if you excuse the expression, it’s meant psychologically, not as an insult. As I said it’s been running like this for years, with OZW and now with Z-Wave JS to MQTT, and as long as the band-aid always works I have no problems with it. Just trying to find a simpler bandaid.

@pdobrien3 Thanks for the further explanation, I may have to ask a question or two later, but we’ll take that when it happens. And in the years I’ve had this setup (and “problem”) I have gone from regular MicroSD to USB SSD and now back to Samsung Endurance MicroSD cards.

@pdobrien3 Dan, didn’t take long… :wink: I have put the second part in my Automations, but I don’t get a sensor in the GUI. I have one GUI page with everything automatically should appear (untouched GUI), so I don’t know why. But using the value template in the template function under Developer’s tools I do get the correct answer if I stop the Z-Wave to JS service.

Still I’m not sure this is exactly what I’m looking for, since I’d like to be able to poll one or a few devices directly and send the result of that as an MQTT message. Automation isn’t my strong side, I usually need help on those… :roll_eyes:

I don’t understand what your problem actually is and how you would solve it by polling a zwave switch all the time. Is it your Pi crashing ? Or HA ? Or a container ? Or the zwave stick ? Or a zwave device ? It’s all very unclear and confusing to be honest. But anyway, regardless of motivations, polling a low bandwidth mesh network like zwave on a regular schedule is never a good idea. It will do more damage than it will fix. Modern zwave is not designed to be polled and polling is actively discouraged by its developers. So outside of temporary debugging situations or having very old zwave devices that still required polling (replace them !), just don’t do it. There is always a better solution, whatever your actual problem is.

The first block I shared is the actual sensor. You need to enable the node_status entity_id for each of your devices, I can’t remember if they are enabled by default.

@HeyImAlex I don’t really care what’s crashing, as I said. Something is. And you don’t really bother to read my messages before you answer, it seems, I think that’s why you’re confused. For one thing I said I don’t use containers. And then I said that I’m not going to take the time to look around the system to find out what’s wrong, also because if it’s one of the thermostats or the door lock, as I suspect, it will be expensive to replace.

So to clarify I’m just looking for a way to query/ping/poll whatever you want to call it a device so it sends a status mesage back that can be received by Hass and then sendt out over MQTT to the central system, like I do now with the physical switch. Just trying to avoid the possibility of the switch dying. If it helps here’s a detailed list:

  1. EventGhost sends the “puls mesage” to the MQTT server on 192.168.10.101 every minute.
  2. Hass on Pi 192.168.10.103 receives the message and toggles the switch.
  3. The switch toggling triggers an automation that sends the “pulse received message” from Hass to the MQTT server, which sends it to EventGhost.
  4. EventGhost sees that it’s all running and then pauses the pulse for a minute.

If the pulse is not received back, EventGhost first tries to trigger the Python script to restart the Pi. If a “restart received” message isn’t sendt back within ten seconds it cuts the power to the Hass Pi with another Z-Wave system (on a Tellstick Z-Wave device) and gives it power again.

This works perfectly and has worked perfectly for yearas. It’s only the physical switch toggling I want to replace with something that isn’t physical, like reading a status of something directly from the Z-Wave device, not from what it said to Hass the last time it was up.

@pdobrien3 I see, thanks! I’ll look into that. So I have to create that sensor with YAML in the GUI, then?

Oh I did. It’s just that your way of approaching this is so convoluted and weird (you’re rebooting your Pi over a zwave switch ping from another zwave controller ?? What ??) that I’m having trouble wrapping my head around it. But don’t worry about it. Since you don’t want any help finding the actual root cause of your problem, I’ll leave you with your voodoo. Hope it works out for you.

I do a majority of my config in yaml, not through the GUI. With that being said, yes, you have to create the sensor first. How that is done in your situation, I am not familiar.

@HeyImAlex Thanks! Then the noise in the thread will be much lower. As I said when it has worked flawlessly with the band-aid for years, I have no intention of doing an open heart surgery.

@pdobrien3 Thanks! I will try that when I get the time. Maybe it can all be solved by polling that sensor.