summaryrefslogtreecommitdiff
path: root/src/home
diff options
context:
space:
mode:
Diffstat (limited to 'src/home')
-rw-r--r--src/home/mqtt/relay.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/home/mqtt/relay.py b/src/home/mqtt/relay.py
index 0c6084f..53d43e4 100644
--- a/src/home/mqtt/relay.py
+++ b/src/home/mqtt/relay.py
@@ -86,11 +86,13 @@ class MQTTRelay(MQTTBase):
except Exception as e:
self._logger.exception(str(e))
- def set_power(self, device_id, enable: bool):
+ def set_power(self, device_id, enable: bool, secret=None):
device = next(d for d in self._devices if d.id == device_id)
- assert device.secret is not None, 'device secret not specified'
+ secret = secret if secret else device.secret
+
+ assert secret is not None, 'device secret not specified'
- payload = PowerPayload(secret=device.secret,
+ payload = PowerPayload(secret=secret,
state=enable)
self._client.publish(f'hk/{device.id}/relay/power',
payload=payload.pack(),