Closed nhale25 closed 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?
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.
Oops, so it does. Thanks.
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.