AaronLionsheep/ShellyMQTT

Indigo action SetColorLevels float issue

Closed this issue · 0 comments

Report: https://forums.indigodomo.com/viewtopic.php?f=330&t=25176

if action.deviceAction == indigo.kDeviceAction.SetColorLevels:
if 'whiteLevel' in action.actionValue:
self.device.updateStateOnServer("whiteLevel", int(action.actionValue['whiteLevel']))
if 'redLevel' in action.actionValue:
self.device.updateStateOnServer("redLevel", int(action.actionValue['redLevel']))
if 'greenLevel' in action.actionValue:
self.device.updateStateOnServer("greenLevel", int(action.actionValue['greenLevel']))
if 'blueLevel' in action.actionValue:
self.device.updateStateOnServer("blueLevel", int(action.actionValue['blueLevel']))
self.set()
self.logCommandSent(u"color values RGBW to {}, {}, {}, {}".format(self.device.states['redLevel'], self.device.states['greenLevel'], self.device.states['blueLevel'], self.device.states['whiteLevel']))

Indigo will attempt to save color values as floats strings. Casting a float string as an int fails, so additional logic is needed to handle this case.

   Trigger                         new trigger
   ShellyMQTT Error                Error in plugin execution ExecuteAction:


Traceback (most recent call last):
  File "plugin.py", line 590, in actionControlDevice
  File "/Library/Application Support/Perceptive Automation/Indigo 7.4/Plugins/ShellyMQTT.indigoPlugin/Contents/Server Plugin/Devices/RGBW2/Shelly_RGBW2_Color.py", line 130, in handleAction
ValueError: invalid literal for int() with base 10: '100.00'

This following devices are impacted:

  • Shelly Bulb
  • Shelly Bulb Duo
  • Shelly RGBW2 (Color)