diff options
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 |