Open mihadoo opened 2 years ago
this is how i fixed that i also formated the output to F dont change that part if you dont want it.
for the experts HEAD 23f7b7474952f0c75960b74d709423233a67baed
git diff
--- a/mqtt_io/modules/sensor/aht20.py
+++ b/mqtt_io/modules/sensor/aht20.py
@@ -9,6 +9,9 @@ from . import GenericSensor
from ...exceptions import RuntimeConfigError
REQUIREMENTS = ("adafruit-circuitpython-ahtx0",)
+CONFIG_SCHEMA = {
+ "chip_addr": {"type": "integer", "required": True, "empty": False},
+}
class Sensor(GenericSensor):
@@ -33,11 +36,12 @@ class Sensor(GenericSensor):
import busio # type: ignore
i2c = busio.I2C(board.SCL, board.SDA)
- self.sensor = adafruit_ahtx0.AHTx0(i2c)
+ self.address: int = self.config["chip_addr"]
+ self.sensor = adafruit_ahtx0.AHTx0(i2c, self.address)
@property
def _temperature(self) -> SensorValueType:
- return cast(SensorValueType, self.sensor.temperature)
+ return cast(SensorValueType, (self.sensor.temperature * 1.8) + 32)
@property
def _humidity(self) -> SensorValueType:
Thanks
i2c_bus_num in yml is supported for lm75. However it is not supported for example for aht20.
Please add support for i2c_bus_num to all supported i2c devices.