OpenZWave / open-zwave

a C++ library to control Z-Wave Networks via a USB Z-Wave Controller.
http://www.openzwave.net/
GNU Lesser General Public License v3.0
1.05k stars 918 forks source link

Set Values are not getting refreshed after commit 0c82d4b0831b197c88c56e75270c423c9eee24cb #2637

Open aerofeev2k opened 2 years ago

aerofeev2k commented 2 years ago

Hi, @markruys

What is the purpose of this change in Value.cpp?

if (!IsWriteOnly())
{
-       // queue a "RequestValue" message to update the value
-       if (m_refreshAfterSet) {
-               cc->RequestValue( 0, m_id.GetIndex(), m_id.GetInstance(), Driver::MsgQueue_Send );
+       if (m_refreshAfterSet)
+       {
+           if (!node->GetCommandClass(Internal::CC::Supervision::StaticGetCommandClassId()))
+           {
+               // queue a "RequestValue" message to update the value
+               cc->RequestValue( 0, m_id.GetIndex(), m_id.GetInstance(), Driver::MsgQueue_Send );
+           }
        }
}

It broke setting LEDs in Homeseer HS-WD200+. Now whenever a LED is turned ON or OFF, the command is delivered to the Homeseer, but the value in the OZW memory is not updated. And since Domoticz checks current value before setting a new one, this causes problems for sequences like this:

1) Turn LED1 to Red (works if current value is Off) 2) Turn LED1 to Off (doesn't do anything because the value is still Off in OZW memory).

I checked what GetCommandClass() returns in my case, and it's not NULL, so RequestValue() is not getting called.

I wonder if this entire "skip refresh" logic should be accounted for here:

https://github.com/OpenZWave/open-zwave/blob/f150a985de47ddcaca5fdba97bda71688c4a4069/cpp/src/value_classes/ValueInt.cpp#L116-L129

where the code is just creating a temporary value and is sending it to the device, apparently expecting that a refresh will happen in the end.

markruys commented 2 years ago

If I recall correctly, the logic is when a device supports the Supervision CC, you should not request the set value immediately. This is problematic because many devices need some time to process the setter and an immediate get would result in the old value. So for these devices Domoticz would not update the GUI. This is where the Supervision CC comes in handy: it will notify the application when a change occurs. But again, it's a long time ago and I'm not deep into ZWave internals.

So my guess is to check whether the Supervision CC report is handled correctly for your device.