OpenZWave / Zwave2Mqtt

Fully configurable Zwave to MQTT gateway and Control Panel using NodeJS and Vue
MIT License
352 stars 93 forks source link

[bug] Automatically Clear Events is lost after restart #92

Closed sjorge closed 4 years ago

sjorge commented 5 years ago

Version

Build/Run method

Zwave2Mqtt version: 2.0.2-master 20190809 Openzwave Version: 1.6

Describe the bug Imgur

This is a new thing introduce in ozw 1.6, it will automatically reset security sensors that trip after X ms (default being 5000), this has something to do with old devices not resetting it.

The value can be change to say 30000 (30 sec), this works fine until z2m is restarted. The setting defaults to 5000 again afterwards.

I'm not sure if the problem is in z2m, the node binding or open zwave. Since it is presented as a parameter that is not read-only I would expect it to be saved.

To Reproduce

Expected behavior I expect the new value to be remembered between restarts

Additional context

Newer Devices support "clearing" notifications back to their idle state after a pre-determined timeframe. For devices that don't support this clearing, OZW will reset the Notification back to the idle state after 5 seconds by default. This can be changed via the "Automatically Clear Events" ValueID exposed on devices that don't clear events. -- https://github.com/OpenZWave/open-zwave/wiki/OpenZWave-1.6-Release-Notes

petergebruers commented 5 years ago

The Notification class and how events/states are generated might be trickier than you think. I talk a bit about that in this issue started by gizmocuz, Domoticz maintainer:

"COMMAND_CLASS_ALARM "magic" clear issue"

https://github.com/OpenZWave/open-zwave/issues/1889

petergebruers commented 5 years ago

Forgot to mention... I haven't tested this but because OpenZWave does not write the timers to disk, a restart will indeed drop the auto clear event. But as explained in that issue, not all devices have this auto clear, it depends on the age of the device (to be precise: the version of the Notification CC implemented by the manufacturer).

On a side note ... I would argue that whenever OpenZWave stops for more than a few 10s of seconds... You are going to miss events from Z-Wave devices, because they do not keep retrying forever. So for example you trigger a Fibaro motion sensor, 30 seconds after last motion event it will clear the notification (aka Alarm). If you are "in reboot" at that time, you won't know there is "no motion", and because it is a battery device you cannot poll it. That error situation is probably going to last until it detects motion again (wake up interval is several hours by default).

robertsLando commented 5 years ago

@sjorge In my opinion this is something that the device should handle itself (if it receives the value it should also store it in his memory).

I think it is not a problem with z2m or underlying libs at all... For sure nothing about z2m.

Please open an issue on Openzwave project. What do you think @Fishwaldo ?

sjorge commented 5 years ago

In my case, the device handles it just fine. There is a parameter that can be set, the device sends the motion alarm state, after the time defined in the parameter passes, it sends the clear state.

This worked fine on 1.4, but on 1.6 open-zwave sends the clear after 5 seconds, the another clear arrives later once the device has left the alarm state.

So there are potentially 2 things broken here I think

  1. the ZW100 clearly support clearing the alarm on its own... so maybe the config is broken in ozw?
  2. When we change the default form 5 sec to something else, say 30 or even 60 sec... it should still remain set after z2m restores. Maybe the node binding is not properly storing the setting or reapplying it at startup. Or maybe ozw doesn't store it at all in the cache...

For nr 2 it might be a binding or ozw bug/missing feature like you said.

robertsLando commented 5 years ago

I have no idea... try to check what @Fishwaldo says about this

darkpainy commented 4 years ago

I have the same issue, my Aeotec Multisensor 6's support clearing there own motion alarm, set to 2 minutes going from motion to no motion (if it is not retriggered within those 2 minutes). But the Automatically clear events setting clear is after 5 seconds. I can set this higher but it is not saved after reboot. Also for these sensors which support clearing on their own it is not a usefull thing, right?

robertsLando commented 4 years ago

@Fishwaldo

robertsLando commented 4 years ago

@darkpainy This is more likely a issue with ozw lib and not mqtt. Could you open the issue there?

I can set this higher but it is not saved after reboot

Are you sure? If it is a configuration parameter (command class 112) You should ask for updateConfiguration to get the actual value after a reboot, with latest version of z2m there is a button for this purpose on configuration section of node values

darkpainy commented 4 years ago

Hi @robertsLando I managed to disable this behavior for my sensors by setting the value of the automatic clear to 0. I use my sensors for lights automations and they send one innitial "detected motion" on first motion and don't send a "clear" event untill they have not seen anything for 3 minutes. This way the light stays on for as long as needed. with the automatic clear, even if i set it to for example 10 minutes, after 10 minutes the MQTT event was cleared triggering my HA to switch of the light while the motion sensor is still detecting motion but does not send anything since his first event was not realy cleared as far as the sensor knows. so untill the motion sensor had not detected motion for 3 minutes for it to "reset" to clear position, the light wouldn't turn on again.

Anyway you say it is a zwave command class option but I don't think my sensors do anything with it nor save it. For me it really seems just like a clear MQTT value timer (but I can be wrong ofc).

Kind regards

Fishwaldo commented 4 years ago

In this case you should set to false the compatibility flag EnableNotificationClear in the device config file. Please see https://github.com/OpenZWave/open-zwave/wiki/CommandClass-Compatibility-Flags#notification-commanclass

darkpainy commented 4 years ago

Hi @Fishwaldo , I will try that thank you. Is it normal that setting the clear event to 0 also has the same effect? I guess 0 means disable in this case aswell right. The Notification command you're reffering to, is something i need to manually add to the device class of all the sensors in the zwave file that is stored in my ZW2MQTT configuration folder right?

Kind regards

robertsLando commented 4 years ago

@darkpainy Here: https://github.com/OpenZWave/open-zwave/blob/master/config/aeotec/zw100.xml

Swiftnesses commented 3 years ago

I realise this is closed, but have the same issue with my previously working (1.4) ZW100.

Can someone point me in the right direction as to what I need to add to the ZW100 xml?

Many thanks.

robertsLando commented 3 years ago

@Swiftnesses GIve a try to https://github.com/zwave-js/zwavejs2mqtt

Swiftnesses commented 3 years ago

Hi @robertsLando and followers,

Tonight I've installed qt-openzwave on docker and got it up and running.

I'd like to know how I can apply 'EnableNotificationClear' to the zw100.xml (I am assuming I can do this via a custom file).

Any help would be greatly appreciated - I've recently migrated from the 'old' Home Assistant z-wave implementation and have found many of my nodes no longer work (or work with quirks!).

robertsLando commented 3 years ago

@Swiftnesses this is not qt-openzwave