Thanks! It seems I did in fact have an older version, even though I downloaded from the user contribution library a few days ago. I reinstalled the plugin, and the error messages disappeared, although "dim by %" and "brighten by %" did not seem to work. I took the liberty of playing with your code, the following seems to work, at least for me.
For plugin.py I replaced
- Code: Select all
###### BRIGHTEN BY ######
elif action.deviceAction == indigo.kDeviceAction.BrightenBy:
if self.RFXTRX.TurnBright(action, dev, 0) == True:
sendSuccess = True # Set to False if it failed.
newBrightness = dev.brightness + action.actionValue
if newBrightness > 100:
newBrightness = 100
sendSuccess = True # Set to False if it failed.
if sendSuccess:
# If success then log that the command was successfully sent.
self.debugLog(u"sent \"%s\" %s to %d" % (dev.name, "brighten", newBrightness))
# And then tell the Indigo Server to update the state:
dev.updateStateOnServer("brightnessLevel", newBrightness)
else:
# Else log failure but do NOT update state on Indigo Server.
self.debugLog(u"send \"%s\" %s to %d failed" % (dev.name, "brighten", newBrightness), isError=True)
###### DIM BY ######
elif action.deviceAction == indigo.kDeviceAction.DimBy:
if self.RFXTRX.TurnDim(action, dev) == True:
sendSuccess = True # Set to False if it failed.
newBrightness = dev.brightness - action.actionValue
if newBrightness < 0:
newBrightness = 0
sendSuccess = True # Set to False if it failed.
if sendSuccess:
# If success then log that the command was successfully sent.
self.debugLog(u"sent \"%s\" %s to %d" % (dev.name, "dim", newBrightness))
# And then tell the Indigo Server to update the state:
dev.updateStateOnServer("brightnessLevel", newBrightness)
else:
# Else log failure but do NOT update state on Indigo Server.
indigo.server.log(u"send \"%s\" %s to %d failed" % (dev.name, "dim", newBrightness), isError=True)
with
- Code: Select all
###### BRIGHTEN BY ######
elif action.deviceAction == indigo.kDeviceAction.BrightenBy:
#if self.RFXTRX.TurnBright(action, dev, 0) == True:
newBrightness = dev.brightness + action.actionValue
if newBrightness > 100:
newBrightness = 100
if self.RFXTRX.TurnBright(action, dev, newBrightness) == True:
sendSuccess = True # Set to False if it failed.
sendSuccess = True # Set to False if it failed.
if sendSuccess:
# If success then log that the command was successfully sent.
self.debugLog(u"sent \"%s\" %s to %d" % (dev.name, "brighten", newBrightness))
# And then tell the Indigo Server to update the state:
dev.updateStateOnServer("brightnessLevel", newBrightness)
else:
# Else log failure but do NOT update state on Indigo Server.
self.debugLog(u"send \"%s\" %s to %d failed" % (dev.name, "brighten", newBrightness), isError=True)
###### DIM BY ######
elif action.deviceAction == indigo.kDeviceAction.DimBy:
#if self.RFXTRX.TurnDim(action, dev) == True:
newBrightness = dev.brightness - action.actionValue
if newBrightness < 0:
newBrightness = 0
if self.RFXTRX.TurnDim(action, dev, newBrightness) == True:
sendSuccess = True # Set to False if it failed.
sendSuccess = True # Set to False if it failed.
if sendSuccess:
# If success then log that the command was successfully sent.
self.debugLog(u"sent \"%s\" %s to %d" % (dev.name, "dim", newBrightness))
# And then tell the Indigo Server to update the state:
dev.updateStateOnServer("brightnessLevel", newBrightness)
else:
# Else log failure but do NOT update state on Indigo Server.
indigo.server.log(u"send \"%s\" %s to %d failed" % (dev.name, "dim", newBrightness), isError=True)
and for RFXTRX.py I changed
- Code: Select all
def TurnBright(self, action, dev,BrightLevel):
return self.TurnDevice(action, dev, 'Bright', BrightLevel)
def TurnDim(self, action, dev):
return self.TurnDevice(action, dev, 'Dimm', 0)
to
- Code: Select all
def TurnBright(self, action, dev, BrightLevel):
return self.TurnDevice(action, dev, 'Bright', BrightLevel)
def TurnDim(self, action, dev, BrightLevel):
return self.TurnDevice(action, dev, 'Dimm', BrightLevel)
which seems to work.
BTW, it seems that the code in plugin.py will always set sendSuccess to true, regardless of result?