Filter out only selected sensors on the enviropHAT backend
This commit is contained in:
parent
bdadd2061c
commit
72d1b3cd2a
1 changed files with 18 additions and 1 deletions
|
@ -15,6 +15,16 @@ class SensorEnvirophatBackend(SensorBackend):
|
||||||
|
|
||||||
def __init__(self, temperature=True, pressure=True, altitude=True, luminosity=True,
|
def __init__(self, temperature=True, pressure=True, altitude=True, luminosity=True,
|
||||||
analog=True, accelerometer=True, magnetometer=True, qnh=1020, **kwargs):
|
analog=True, accelerometer=True, magnetometer=True, qnh=1020, **kwargs):
|
||||||
|
"""
|
||||||
|
:param temperature: Enable temperature sensor polling
|
||||||
|
:param pressure: Enable pressure sensor polling
|
||||||
|
:param altitude: Enable altitude sensor polling
|
||||||
|
:param luminosity: Enable luminosity sensor polling
|
||||||
|
:param analog: Enable analog sensors polling
|
||||||
|
:param accelerometer: Enable accelerometer polling
|
||||||
|
:param magnetometer: Enable magnetometer polling
|
||||||
|
:param qnh: Base reference for your sea level pressure (for altitude sensor)
|
||||||
|
"""
|
||||||
super().__init__(self, **kwargs)
|
super().__init__(self, **kwargs)
|
||||||
|
|
||||||
self.qnh = qnh
|
self.qnh = qnh
|
||||||
|
@ -30,7 +40,14 @@ class SensorEnvirophatBackend(SensorBackend):
|
||||||
|
|
||||||
def get_measurement(self):
|
def get_measurement(self):
|
||||||
plugin = get_plugin('gpio.sensor.envirophat')
|
plugin = get_plugin('gpio.sensor.envirophat')
|
||||||
return plugin.get_data(qnh=self.qnh).output
|
sensors = plugin.get_data(qnh=self.qnh).output
|
||||||
|
ret = {
|
||||||
|
sensors[sensor]
|
||||||
|
for sensor, enabled in self.enabled_sensors.items()
|
||||||
|
if enabled and sensor in sensors
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
# vim:sw=4:ts=4:et:
|
# vim:sw=4:ts=4:et:
|
||||||
|
|
Loading…
Reference in a new issue