From a3271f0522d24b21264456e1a0d47aece608283b Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 1 Aug 2019 23:33:36 +0200 Subject: [PATCH] Only return the sensor data whose value has changed on the envirophat backend --- platypush/backend/sensor/envirophat.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platypush/backend/sensor/envirophat.py b/platypush/backend/sensor/envirophat.py index 03f9cbc5..2d7711ab 100644 --- a/platypush/backend/sensor/envirophat.py +++ b/platypush/backend/sensor/envirophat.py @@ -27,6 +27,7 @@ class SensorEnvirophatBackend(SensorBackend): super().__init__(self, **kwargs) self.qnh = qnh + self._last_read = {} self.enabled_sensors = { 'temperature': temperature, 'pressure': pressure, @@ -43,9 +44,10 @@ class SensorEnvirophatBackend(SensorBackend): ret = { sensor: sensors[sensor] for sensor, enabled in self.enabled_sensors.items() - if enabled and sensor in sensors + if enabled and sensor in sensors and sensors[sensor] != self._last_read.get(sensor) } + self._last_read = ret return ret