diff --git a/platypush/backend/sensor/envirophat.py b/platypush/backend/sensor/envirophat.py index 5e98b4483..e261c9919 100644 --- a/platypush/backend/sensor/envirophat.py +++ b/platypush/backend/sensor/envirophat.py @@ -15,6 +15,16 @@ class SensorEnvirophatBackend(SensorBackend): def __init__(self, temperature=True, pressure=True, altitude=True, luminosity=True, 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) self.qnh = qnh @@ -30,7 +40,14 @@ class SensorEnvirophatBackend(SensorBackend): def get_measurement(self): 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: