Zwave autodiscovery stops working after Domoticz restart

For devices supporting the Auto Discovery feature. Like ZWaveJS2MQTT, Zigbee2MQTT.

Moderator: leecollings

Post Reply
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Zwave autodiscovery stops working after Domoticz restart

Post by Nautilus »

Hi,

I have a strange problem. Whenever Domoticz restarts (this happens usually once a week or so, I have monit in use so I don't always know right away when it happens), the zwave mqtt autodiscovery stops working. If I try to e.g. press a zwave switch after restart I get message with like something "incorrect ID" in Domoticz GUI. After I go to zwavejs2mqtt settings and press "Save" I can see in the log all the devices discovered and they start working again. So there are no new devices created, just the old ones start working again.

What do I need to do to keep them working through restarts (preferably without the need to recreate any devices)?

These are my settings:
domo2.PNG
domo2.PNG (37.26 KiB) Viewed 1659 times
domo3.PNG
domo3.PNG (58.55 KiB) Viewed 1659 times
The attachment domo3.PNG is no longer available
Attachments
domo.PNG
domo.PNG (367.42 KiB) Viewed 1659 times
Last edited by Nautilus on Tuesday 03 May 2022 7:47, edited 1 time in total.
mgugu
Posts: 220
Joined: Friday 04 November 2016 12:33
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: France
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by mgugu »

Try to set on "Retained Discovery"
The configuration which woeks for me:
Image
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by Nautilus »

Thanks - maybe I should try it as well. I was trying to follow these instructions:
MQTT config: best to switch OFF the retain flag (otherwise, deleted devices keep reappearing until you manually delete the messages from the broker)
https://www.domoticz.com/wiki/ZwaveJS2MQTT

And actually the retained flag was something I was fighting with in my early attempts to get things running:
Nautilus wrote: Tuesday 04 January 2022 9:42 All in all I have to say I'm very impressed about some of the changes with regards to stability and overall functionality observed now after running zwavejs2mqtt together with Domoticz for about a week. Maybe someone can help me with one question. Initially when zwavejs2mqtt discovers the devices, they do not have a name (of course). After adding some names, I noticed the devices stopped working in Domoticz (sort of - some did, most did not).

I configured zwavejs2mqtt with the help of these recommendations:
https://github.com/moroen/ZWave-MQTT-pl ... avejs2mqtt
Gateway configuration:
Use node names instead of numeric nodeIDs: Off
Ignore location: On
Include Node Info: On
Note: Specifying node names and locations in zwavejs2mqtt is not required, but recommended. This will generate somewhat sane names of the devices when they are added to domoticz.
But as mentioned couple of posts above:
Now, when I look at the topics in mqtt explorer, I can see only one ID under discovery node, yesterday I saw several of them. I can see them under zwave node though. Why have they disappeared from discovery? Can it be the fact that I enable OZW for a while to get my old device names? Since then I've restarted the system and everything so shouldn't it recover? Can I force the discovery topics to be populated somehow again?

edit. I turned the "retained discovery" switch on in zwavejs2mqtt to "on" and now I have the nodes back under discovery topic. Not sure if this is the right way to do as it was mentioned to best to keep it off...
So my retained flag was on. I took it off and everything started working again. I thought this was it. But then I needed to do one more change and when testing the device in Domoticz after the change, it did not work right away. And I'm not fully sure what I did to make it start working again :)

Now I wonder which is the best practice to change device name in zwavejs2mqtt and keep everything working in Domoticz. Is it just this:
Hint: To add all devices at once, enable the plugin in domoticz, and press "Save" in zwavejs2mqtt preferences. This will generate status messages for all devices.
So do I need to save preferences once after each name update to re-generate status messages? Or something else?
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by Nautilus »

Well, I wanted go through the setting one more just in case (I think I did this already a few times :)) to see if there is anything to explain this. And yes, I could not find any justification on having the "clean" flag true under mqtt settings. So I disabled that and let's see if that changes things. I did not find any particular documentation about it's significance (except: "Sets the clean flag when connecting to the broker"), but it kinda sounds that any disconnect from mqtt broker might result into to the kind of behavior I am seeing...
rezzalex
Posts: 49
Joined: Thursday 24 September 2020 14:30
Target OS: NAS (Synology & others)
Domoticz version: Beta
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by rezzalex »

Hello,

I had a big struggle with the same symptoms... but I am using DZ MQTT Auto discovery hardware, not the same as you.
in ZwaveJs2MQTT, I have the "clean" option checked (ON), and it works well. Also, the retained discovery is checked (ON).

Maybe there is an attention to have on connexion to your MQTT broker by observing its logs, crossing that with DZ logs. In my case, DZ MQTT AD used to always lose its connection to the broker and restart a discovery that did not work well... now it seems to be solved.

Hope it can help a bit
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by Nautilus »

rezzalex wrote: Tuesday 03 May 2022 8:42 Hello,

I had a big struggle with the same symptoms... but I am using DZ MQTT Auto discovery hardware, not the same as you.
in ZwaveJs2MQTT, I have the "clean" option checked (ON), and it works well. Also, the retained discovery is checked (ON).

Maybe there is an attention to have on connexion to your MQTT broker by observing its logs, crossing that with DZ logs. In my case, DZ MQTT AD used to always lose its connection to the broker and restart a discovery that did not work well... now it seems to be solved.

Hope it can help a bit
Thanks for the reply. Sorry, but what do you mean with "DZ MQTT Auto discovery hardware"? I thought this is what I am using too, "MQTT Client Gateway with LAN interface" hardware with autodiscovery topic set to correspond what I have configure in zwavejs2mqtt?

I was just thinking that when it specifically says in wiki that retained flag should not be on, it would be best to avoid setting it on. At least it will then require old devices to be manually removed with mqtt explorer. Which is manageable, of course, in case it solves other issues.

Also, I did not find anywhere reference for setting "clean" as checked. Maybe it is checked by default and I just left it like that. But let's see, I will report back if clean = off, retained = off works for me. If not, will try to put both on...:)
rezzalex
Posts: 49
Joined: Thursday 24 September 2020 14:30
Target OS: NAS (Synology & others)
Domoticz version: Beta
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by rezzalex »

as you can see, not the same hardware :
Sans titre.png
Sans titre.png (56.67 KiB) Viewed 1601 times
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by Nautilus »

Ah, indeed - it was split into separate hardware a while back: https://github.com/domoticz/domoticz/co ... b9267bab6d

I wonder if this changes anything? At least the harware still works (except the restart thing) and the config seems identical.

I have not updated my Domoticz since beginning of this year due to changes in the Python plugin framwork which was causing issue with some plugins (viewtopic.php?t=38086&start=60). But maybe it would now be time to update...
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by Nautilus »

Well, Domoticz got restarted again today and zwave stopped working through autodiscovery. I have not set the retain flag on, clean on ==> let's see if it makes a difference....
Michalux
Posts: 27
Joined: Sunday 22 March 2020 17:46
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by Michalux »

I've made some tests on this. It looks like every MQTT Auto Discovery device change, that restarts the worker and makes it disconnect/reconnect to MQTT generates this problem. For what I've tested, either of below things fix it:
1. Save ZWavejs2MQTT config in GUI, which generates auto discovery broadcast to MQTT
2. Set Retained discovery to ON (against docs suggestions), that makes all auto discovery info available for MQTT Auto Discovery device on reconnect.
It seems, that MQTT Auto Discovery needs to get all discovery info after each restart (or even reconnect). So either it has to be available on MQTT server, or generated again (by zwavejs2mqtt).

BTW - setting Clean -> ON doesn't seem to make any difference.
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by Nautilus »

Thanks, good info. My observations support your finding of restart of the worker (which disconnect/reconnect it from MQTT) generates the problem. I have mostly observed it when whole Domoticz is restarted, but I've noticed that it is not always the case - happens sometimes without a Domoticz restart so worker disconnecting must be enough...

As said, I too have the set the retain flag on. Deleting old devices additionally from broker via MQTT explorer is much less of a hassle than finding few times a week that your zwave devices are not working :)
rezzalex
Posts: 49
Joined: Thursday 24 September 2020 14:30
Target OS: NAS (Synology & others)
Domoticz version: Beta
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by rezzalex »

are you using Mosquitto as mqqt broker ?

take a look at my experiments here : viewtopic.php?p=289477#p289477
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by Nautilus »

Yes, using Mosquitto. Interesting, will take a look...
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by Nautilus »

So I enabled the retain flag and at first things looked very promising. Z-wave was stable for about a week though I must add that during this time Domoticz did not restart. But unfortunately when the first (unplanned) restart came, Domoticz again lost all z-wave devices. Saving zwavejs2mqtt settings again brought them back.

Now I am thinking is there a way to automate this in someway. Domoticz restart would be the trigger and action would be basically equivalent to pressing the save button in zwavejs2mqtt settings. Has anyone tried something like this?
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by Nautilus »

Some progress, after two Domoticz restarts zwave has kept working without the need to save config. Changes since last message: I updated Domoticz to latest beta (my last update was around change of year, I was afraid to update due to issues with the new python plugin framework). I updated zwavejs2mqtt to the latest version (I think it was from around year change too) and at the same time changed it to be managed with docker compose (was managed by "plain" docker). Unfortunately no idea which update made the difference or was it something else.
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by Nautilus »

Update: the joy of previous message lasted for about two weeks or so. Now back to the usual "Domoticz restart -> Z-wave devices not operational (except after saving the config)". So back to plan B it is then...
User avatar
heggink
Posts: 980
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by heggink »

I have not updated zwavejs2mqtt in quite a while (probably longer than 6 months) since it's very stable for me.
There's 2 retain switches: the mqtt retain (which is "off" in my case) and the homeassistant retained discovery which I have had "On".
Other than that, my settings are the same as yours. I have persistence set to true in mosquitto.conf but I am not sure if that's the default.
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by Nautilus »

Thanks, I’ll try this config 👍
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by Nautilus »

So far, so good. Several restarts behind and zwavejs2mqtt keeps connected with Domoticz :D

I think the other retain flag was the key as suggested by @heggink. Had overlooked this option thus far. Thanks a lot!
User avatar
heggink
Posts: 980
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Zwave autodiscovery stops working after Domoticz restart

Post by heggink »

Nice!

Sent from my SM-G980F using Tapatalk

Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest