Skip to content

Commit

Permalink
Merge pull request #44 from lichtteil/dev
Browse files Browse the repository at this point in the history
Support for SHT3X and fix for deprecated function
  • Loading branch information
lichtteil authored Feb 5, 2022
2 parents 539be1c + b9f981c commit 159fb86
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 4 additions & 0 deletions custom_components/local_luftdaten/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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],
}
7 changes: 3 additions & 4 deletions custom_components/local_luftdaten/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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()
Expand All @@ -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))
Expand Down

0 comments on commit 159fb86

Please sign in to comment.