diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-12-18 05:33:54 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-12-18 05:33:54 +0300 |
commit | 9af0e28b94fd44d2340b0b9ddf2dcccc11d48271 (patch) | |
tree | b27dea0aee4226a802e641070b202eaa88b9455a /src/home/mqtt/payload/sensors.py | |
parent | 09a6b8d1ed6ac97a044023987cb40dbd16d45bcb (diff) |
mqtt refactoring (wip)
Diffstat (limited to 'src/home/mqtt/payload/sensors.py')
-rw-r--r-- | src/home/mqtt/payload/sensors.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/home/mqtt/payload/sensors.py b/src/home/mqtt/payload/sensors.py new file mode 100644 index 0000000..3ecc243 --- /dev/null +++ b/src/home/mqtt/payload/sensors.py @@ -0,0 +1,20 @@ +from .base_payload import MQTTPayload + +_mult_100 = lambda n: int(n*100) +_div_100 = lambda n: n/100 + + +class Temperature(MQTTPayload): + FORMAT = 'IhH' + PACKER = { + 'temp': _mult_100, + 'rh': _mult_100, + } + UNPACKER = { + 'temp': _div_100, + 'rh': _div_100, + } + + time: int + temp: float + rh: float |