diff --git a/src/thermostat/sensor.py b/src/thermostat/sensor.py index 96f6864..7ef1c0d 100644 --- a/src/thermostat/sensor.py +++ b/src/thermostat/sensor.py @@ -96,9 +96,9 @@ class Daemon: while 1: data = bme280.sample(bus, SENSOR_ADDR, params) values = { - "temperature": int(data.temperature), - "pressure": int(data.pressure), - "humidity": int(data.humidity), + "temperature": adj(data.temperature), + "pressure": adj(data.pressure), + "humidity": adj(data.humidity), } client.publish(TOPIC, json.dumps(values)) ready = select.select((self.quitpipe[0],), (), (), 10)[0] @@ -142,6 +142,10 @@ class Daemon: print("Message", client, userdata, msg) +def adj(value, p=10): + return int(value * p) / p + + def main(): logging.basicConfig(level=logging.DEBUG) daemon = Daemon()