diff --git a/README.md b/README.md index 397acfa..3dc29be 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,8 @@ At the moment following sensor data can be read: - HECA_humidity - HPM_P1 - HPM_P2 +- SHT3X_temperature +- SHT3X_humidity Sensor type `signal` gives the wifi signal strength of the sensor device. diff --git a/custom_components/local_luftdaten/const.py b/custom_components/local_luftdaten/const.py index 6592756..721be03 100644 --- a/custom_components/local_luftdaten/const.py +++ b/custom_components/local_luftdaten/const.py @@ -54,6 +54,8 @@ SENSOR_HECA_HUMIDITY = 'HECA_humidity' SENSOR_HPM_P1 = 'HPM_P1' SENSOR_HPM_P2 = 'HPM_P2' +SENSOR_SHT3X_TEMPERATURE = 'SHT3X_temperature' +SENSOR_SHT3X_HUMIDITY = 'SHT3X_humidity' SENSOR_TYPES = { SENSOR_TEMPERATURE: ['Temperature', TEMP_CELSIUS, DEVICE_CLASS_TEMPERATURE], @@ -81,4 +83,6 @@ SENSOR_HECA_HUMIDITY: ['Humidity', PERCENTAGE, DEVICE_CLASS_HUMIDITY], SENSOR_HPM_P1: ['PM10', CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, None], SENSOR_HPM_P2: ['PM2.5', CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, None], + SENSOR_SHT3X_TEMPERATURE: ['Temperature', TEMP_CELSIUS, DEVICE_CLASS_TEMPERATURE], + SENSOR_SHT3X_HUMIDITY: ['Humidity', PERCENTAGE, DEVICE_CLASS_HUMIDITY], } diff --git a/custom_components/local_luftdaten/sensor.py b/custom_components/local_luftdaten/sensor.py index 2bac5d3..f38cda9 100644 --- a/custom_components/local_luftdaten/sensor.py +++ b/custom_components/local_luftdaten/sensor.py @@ -54,7 +54,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= resource = config.get(CONF_RESOURCE).format(host) session = async_get_clientsession(hass, verify_ssl) - rest_client = LuftdatenClient(hass.loop, session, resource, scan_interval) + rest_client = LuftdatenClient(session, resource, scan_interval) devices = [] for variable in config[CONF_MONITORED_CONDITIONS]: @@ -132,9 +132,8 @@ class LuftdatenError(Exception): class LuftdatenClient(object): """Class for handling the data retrieval.""" - def __init__(self, loop, session, resource, scan_interval): + def __init__(self, session, resource, scan_interval): """Initialize the data object.""" - self._loop = loop self._session = session self._resource = resource self.lastUpdate = datetime.datetime.now() @@ -160,7 +159,7 @@ async def async_update(self): responseData = None try: _LOGGER.debug("Get data from %s", str(self._resource)) - with async_timeout.timeout(30, loop=self._loop): + with async_timeout.timeout(30): response = await self._session.get(self._resource) responseData = await response.text() _LOGGER.debug("Received data: %s", str(self.data))