Closed ZachBenz closed 7 years ago
Thanks for catching this! Since we've always had the light in our fan it never occurred to me that this might do something strange like return a literal string as an error condition...
If you submit a pull request with the changes you made I'll gladly incorporate it into the project.
Yeah, their API seems to employ a strange mixing of types willy nilly (ints, literals, etc)! Working on testing out a patch now. Should have a pull request to your shortly. To make Indigo work smoothly with upgrading the plugin, my pull request will have the version number bumped to 0.5.
Note to myself to also address: another consequence of this issue is that the updateStatusString method incorrectly can interpret the light as being 'on' when it doesn't exist, because it checks for a light_level of '0' to say the light is 'off', which of course means 'NOT PRESENT' will fall through to the else and get called 'on'.
The problem is in lines 127-131 of SenseME-Indigo-Plugin/SenseME.indigoPlugin/Contents/Server Plugin/plugin.py:
The self.queryFan call succeeds, but the result returned when there is no light installed is the literal 'NOT PRESENT'. Thus, on line 131, the call to int(res) throws an exception as a result:
SenseME Fan Error exception in deviceStartComm(Master Bedroom Fan): invalid literal for int() with base 10: 'NOT PRESENT'
This is because 'NOT PRESENT' can't be interpreted as an int. An exception handler would deal with this situation, as would an explicit check for 'NOT PRESENT'
P.S. Thanks for making this plugin!!