diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2023-01-01 18:47:56 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2023-01-01 18:47:56 +0300 |
commit | 1162a9cc5393cf614654ba763ccfd0298df0765f (patch) | |
tree | ab96d9a73c4bde08263a9f576a6c63bd94359f98 /src/home | |
parent | 5e39b5c7c0bbff7317576e72b591754192f98e23 (diff) |
mqtt relay: support OTAResult payload
Diffstat (limited to 'src/home')
-rw-r--r-- | src/home/mqtt/payload/relay.py | 7 | ||||
-rw-r--r-- | src/home/mqtt/relay.py | 5 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/home/mqtt/payload/relay.py b/src/home/mqtt/payload/relay.py index debc2c8..1a38201 100644 --- a/src/home/mqtt/payload/relay.py +++ b/src/home/mqtt/payload/relay.py @@ -62,6 +62,12 @@ class PowerPayload(MQTTPayload): state: bool +class OTAResultPayload(MQTTPayload): + FORMAT = '=BB' + result: int + error_code: int + + class OTAPayload(MQTTPayload): secret: str filename: str @@ -87,3 +93,4 @@ class OTAPayload(MQTTPayload): # secret = buf[:12].decode() # filename = buf[12:].decode() # return OTAPayload(secret=secret, filename=filename) + diff --git a/src/home/mqtt/relay.py b/src/home/mqtt/relay.py index 97a1689..2094b10 100644 --- a/src/home/mqtt/relay.py +++ b/src/home/mqtt/relay.py @@ -8,7 +8,8 @@ from .payload.relay import ( InitialStatPayload, StatPayload, PowerPayload, - OTAPayload + OTAPayload, + OTAResultPayload ) @@ -76,6 +77,8 @@ class MQTTRelay(MQTTBase): message = InitialStatPayload.unpack(msg.payload) elif subtopic == 'power': message = PowerPayload.unpack(msg.payload) + elif subtopic == 'otares': + message = OTAResultPayload.unpack(msg.payload) if message and self._message_callback: self._message_callback(device_id, message) |