From 6af0df9efd72bd41d4d5ae2b70eda4c69cc6b0fc Mon Sep 17 00:00:00 2001 From: Jens Thomas Date: Mon, 5 Aug 2024 16:35:49 +0100 Subject: [PATCH] Fix types --- mqtt_io/modules/sensor/dfr0300.py | 13 +++++++++---- .../drivers/DFRobot_RaspberryPi_Expansion_Board.py | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/mqtt_io/modules/sensor/dfr0300.py b/mqtt_io/modules/sensor/dfr0300.py index 4235fdeb..c58b6590 100644 --- a/mqtt_io/modules/sensor/dfr0300.py +++ b/mqtt_io/modules/sensor/dfr0300.py @@ -180,10 +180,15 @@ def setup_sensor(self, sens_conf: ConfigType, event_bus: EventBus) -> None: _LOG.info("dfr0300: No temperature sensor configured") return - def on_sensor_read(data: SensorReadEvent) -> None: - """Callback for sensor read event""" - if data.sensor_name == sens_conf[TEMPSENSOR_ID] and data.value is not None: - self.temperature = data.value + async def on_sensor_read(event: SensorReadEvent) -> None: + """Callback for sensor read event + Sets self.temperature from the temperature sensor + """ + if ( + event.sensor_name == sens_conf[TEMPSENSOR_ID] + and event.value is not None + ): + self.temperature = event.value event_bus.subscribe(SensorReadEvent, on_sensor_read) diff --git a/mqtt_io/modules/sensor/drivers/DFRobot_RaspberryPi_Expansion_Board.py b/mqtt_io/modules/sensor/drivers/DFRobot_RaspberryPi_Expansion_Board.py index 9d2fe4bb..2176e926 100644 --- a/mqtt_io/modules/sensor/drivers/DFRobot_RaspberryPi_Expansion_Board.py +++ b/mqtt_io/modules/sensor/drivers/DFRobot_RaspberryPi_Expansion_Board.py @@ -133,7 +133,7 @@ def set_adc_disable(self) -> None: """ self._write_bytes(self._REG_ADC_CTRL, [0x00]) - def get_adc_value(self, chan: int) -> Union[List[float], float]: + def get_adc_value(self, chan: int) -> float: """ Return the ADC value for the given channel. """