diff options
Diffstat (limited to 'src/home/mqtt/module/temphum.py')
-rw-r--r-- | src/home/mqtt/module/temphum.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/home/mqtt/module/temphum.py b/src/home/mqtt/module/temphum.py index e1c4567..0e43f1b 100644 --- a/src/home/mqtt/module/temphum.py +++ b/src/home/mqtt/module/temphum.py @@ -3,13 +3,14 @@ from .._node import MqttNode from .._module import MqttModule from .._payload import MqttPayload from ...util import HashableEnum +from typing import Optional two_digits_precision = lambda x: round(x, 2) MODULE_NAME = 'MqttTempHumModule' -class TempHumDataPayload(MqttPayload): +class MqttTemphumDataPayload(MqttPayload): FORMAT = '=ddb' UNPACKER = { 'temp': two_digits_precision, @@ -49,7 +50,8 @@ class MqttTempHumModule(MqttModule): def handle_payload(self, mqtt: MqttNode, topic: str, - payload: bytes): + payload: bytes) -> Optional[MqttPayload]: if topic == 'temphum/data': - message = TempHumDataPayload.unpack(payload) - self._logger.debug(message)
\ No newline at end of file + message = MqttTemphumDataPayload.unpack(payload) + self._logger.debug(message) + return message
\ No newline at end of file |