Skip to content

Commit

Permalink
Pass on origin correctly when executing command from server side
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamaTheHutt committed Feb 20, 2020
1 parent cb55ca0 commit f2ca952
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions telldus/src/telldus/DeviceManager.py
Expand Up @@ -320,6 +320,9 @@ def stateUpdated(self, device, ackId=None, origin=None):
msg.append(extras)
self.live.send(msg)

"""
Send report to Live server that state change failed
"""
def stateUpdatedFail(self, device, state, stateValue, reason, origin):
if not self.live.registered:
return
Expand Down Expand Up @@ -347,12 +350,15 @@ def __handleCommand(self, msg):
action = args['action']
value = args['value'] if 'value' in args else None
deviceId = args['id']
originId = None
extras = msg.argument(1).toNative()
if extras and 'origin' in extras:
originId = extras['origin']
device = None
for dev in self.devices:
if dev.id() == deviceId:
device = dev
break

def success(state, stateValue):
if 'ACK' in args:
device.setState(state, stateValue, ack=args['ACK'])
Expand All @@ -373,7 +379,7 @@ def fail(reason):
# Abort the DeviceEvent this triggered
raise DeviceAbortException()

device.command(action, value, success=success, failure=fail)
device.command(action, value, success=success, failure=fail, origin=originId)

@TelldusLive.handler('device')
def __handleDeviceCommand(self, msg):
Expand Down

0 comments on commit f2ca952

Please sign in to comment.