summaryrefslogtreecommitdiff
path: root/src/home/mqtt/module/relay.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/home/mqtt/module/relay.py')
-rw-r--r--src/home/mqtt/module/relay.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/home/mqtt/module/relay.py b/src/home/mqtt/module/relay.py
index 721ceac..bf22bfe 100644
--- a/src/home/mqtt/module/relay.py
+++ b/src/home/mqtt/module/relay.py
@@ -60,6 +60,7 @@ class MqttRelayState:
class MqttRelayModule(MqttModule):
def init(self, mqtt: MqttNode):
mqtt.subscribe_module('relay/switch', self)
+ mqtt.subscribe_module('relay/status', self)
@staticmethod
def switchpower(mqtt: MqttNode,
@@ -69,10 +70,13 @@ class MqttRelayModule(MqttModule):
mqtt.publish('relay/switch', payload=payload.pack())
def handle_payload(self, mqtt: MqttNode, topic: str, payload: bytes) -> Optional[MqttPayload]:
- if topic != 'relay/switch':
- return
+ message = None
- message = MqttPowerSwitchPayload.unpack(payload)
- self._logger.debug(message)
+ if topic == 'relay/switch':
+ message = MqttPowerSwitchPayload.unpack(payload)
+ elif topic == 'relay/status':
+ message = MqttPowerStatusPayload.unpack(payload)
- return message \ No newline at end of file
+ if message is not None:
+ self._logger.debug(message)
+ return message