bloob00k / domoticz

0 stars 0 forks source link

Don't crash when updating devices with which connection has been lost. #2

Closed nhale25 closed 3 years ago

nhale25 commented 3 years ago

It seems that the Wiser hub returns JSON containing different property names for a device if it's lost it's connection to that device.

Specifically, for me, I had a SmartPlug device which had lost its connection to the hub. The hub reported the plug's status without an "OutputState" property, but with a property called "ManualState" instead.

This commit makes the plugin more resilient to the expected property name being missing.

bloob00k commented 3 years ago

Thanks for this, definitely in favour of being more defensive and reducing assumptions. However it looks to me like this won't completely fix the problem, because of this line in each function: if Devices[Unit].nValue != nValue:

nValue will be undefined if I'm not mistaken, so we still need to add some logic to avoid this path if the relevant property name was is missing.

Have you been able to teest this code path?

nhale25 commented 3 years ago

If the property name is missing, the 'else' clause prints a message to the log and then returns. So control never reaches the line you mentioned.

bloob00k commented 3 years ago

Oops, so it does. Thanks.