Skip to content

Commit

Permalink
Handling device deletion better
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingDiver committed Mar 31, 2018
1 parent 76ca1a7 commit d881a99
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<MenuItems>
<MenuItem id="queryAll">
<Name>Query All Devices Now</Name>
<Name>Query All Devices</Name>
<CallbackMethod>queryAllDevices</CallbackMethod>
</MenuItem>
<MenuItem id="sendCommand">
Expand Down
32 changes: 19 additions & 13 deletions Lutron RadioRA 2.indigoPlugin/Contents/Server Plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,19 +538,23 @@ def validateDeviceConfigUi(self, valuesDict, typeId, devId):
self.logger.debug(u"validateDeviceConfigUi: forced PROP_KEYPADBUT_DISPLAY_LED_STATE to False for keypad # %s, button # %s" % (valuesDict[PROP_KEYPAD], valuesDict[PROP_KEYPADBUT]))

elif typeId == RA_LINKEDDEVICE:
buttonDevice = indigo.devices[int(valuesDict['buttonDevice'])]
valuesDict['buttonAddress'] = buttonDevice.address

parts = buttonDevice.address.split(".")
deviceID = parts[0]
componentID = parts[1]
buttonLEDAddress = "{}.{}".format(deviceID, int(componentID)+80)
valuesDict['buttonLEDAddress'] = buttonLEDAddress
buttonLEDDevice = self.keypads[buttonLEDAddress]
valuesDict['buttonLEDDevice'] = buttonLEDDevice.id
try:
buttonDevice = indigo.devices[int(valuesDict['buttonDevice'])]
valuesDict['buttonAddress'] = buttonDevice.address
except:
self.logger.debug(u"validateDeviceConfigUi: buttonDevice not found: {}".format(valuesDict['buttonDevice']))
errorsDict['buttonAddress'] = "Invalid Button Device - ID not found"
else:
parts = buttonDevice.address.split(".")
deviceID = parts[0]
componentID = parts[1]
buttonLEDAddress = "{}.{}".format(deviceID, int(componentID)+80)
valuesDict['buttonLEDAddress'] = buttonLEDAddress
buttonLEDDevice = self.keypads[buttonLEDAddress]
valuesDict['buttonLEDDevice'] = buttonLEDDevice.id

self.logger.debug(u"New Linked Device: buttonAddress = {}, buttonLEDAddress = {}, buttonDevice = {}, buttonLEDDevice = {}, controlledDevice = {}"\
.format(valuesDict['buttonAddress'], valuesDict['buttonLEDAddress'], valuesDict['buttonDevice'], valuesDict['buttonLEDDevice'], valuesDict['controlledDevice']))
self.logger.debug(u"New Linked Device: buttonAddress = {}, buttonLEDAddress = {}, buttonDevice = {}, buttonLEDDevice = {}, controlledDevice = {}"\
.format(valuesDict['buttonAddress'], valuesDict['buttonLEDAddress'], valuesDict['buttonDevice'], valuesDict['buttonLEDDevice'], valuesDict['controlledDevice']))

if len(errorsDict) > 0:
return (False, valuesDict, errorsDict)
Expand Down Expand Up @@ -741,11 +745,13 @@ def _processCommand(self, cmd):
self._cmdTimeClock(cmd)
elif "~MONITORING" in cmd:
self.logger.debug(u"Main repeater serial interface configured" + cmd)
elif "~ERROR" in cmd:
self.logger.debug(u"{} received".format(cmd))
elif 'GNET' in cmd:
#command prompt is ready
self.logger.threaddebug(u"Command prompt received. Device is ready.")
elif cmd != "!":
self.logger.error(u"Unrecognized command: " + cmd)
self.logger.debug(u"Unrecognized command: " + cmd)


def _sendCommand(self, cmd):
Expand Down

0 comments on commit d881a99

Please sign in to comment.