Only return the sensor data whose value has changed on the envirophat
backend
This commit is contained in:
parent
f06a851b61
commit
a3271f0522
1 changed files with 3 additions and 1 deletions
|
@ -27,6 +27,7 @@ class SensorEnvirophatBackend(SensorBackend):
|
||||||
super().__init__(self, **kwargs)
|
super().__init__(self, **kwargs)
|
||||||
|
|
||||||
self.qnh = qnh
|
self.qnh = qnh
|
||||||
|
self._last_read = {}
|
||||||
self.enabled_sensors = {
|
self.enabled_sensors = {
|
||||||
'temperature': temperature,
|
'temperature': temperature,
|
||||||
'pressure': pressure,
|
'pressure': pressure,
|
||||||
|
@ -43,9 +44,10 @@ class SensorEnvirophatBackend(SensorBackend):
|
||||||
ret = {
|
ret = {
|
||||||
sensor: sensors[sensor]
|
sensor: sensors[sensor]
|
||||||
for sensor, enabled in self.enabled_sensors.items()
|
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
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue