Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
lichtteil committed Jul 1, 2020
2 parents 3d2d7cc + e711465 commit 0981cde
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ At the moment following sensor data can be read:
- BMP280_temperature
- HTU21D_temperature
- HTU21D_humidity
- SPS30_P0
- SPS30_P2
- SPS30_P4
- SPS30_P1
Sensor type `signal` gives the wifi signal strength of the sensor device.

Expand Down
16 changes: 15 additions & 1 deletion custom_components/local_luftdaten/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
SENSOR_WIFI_SIGNAL = 'signal'
SENSOR_HTU21D_TEMPERATURE = 'HTU21D_temperature'
SENSOR_HTU21D_HUMIDITY = 'HTU21D_humidity'
SENSOR_SPS30_P0 = 'SPS30_P0'
SENSOR_SPS30_P2 = 'SPS30_P2'
SENSOR_SPS30_P4 = 'SPS30_P4'
SENSOR_SPS30_P1 = 'SPS30_P1'

SENSOR_TYPES = {
SENSOR_TEMPERATURE: ['Temperature', TEMP_CELSIUS, 'temperature'],
Expand All @@ -64,7 +68,11 @@
SENSOR_PM2: ['PM2.5', VOLUME_MICROGRAMS_PER_CUBIC_METER, None],
SENSOR_WIFI_SIGNAL: ['Wifi signal', 'dBm', 'signal_strength'],
SENSOR_HTU21D_TEMPERATURE: ['Temperature', TEMP_CELSIUS, 'temperature'],
SENSOR_HTU21D_HUMIDITY: ['Humidity', '%', 'humidity']
SENSOR_HTU21D_HUMIDITY: ['Humidity', '%', 'humidity'],
SENSOR_SPS30_P0: ['PM1', VOLUME_MICROGRAMS_PER_CUBIC_METER, None],
SENSOR_SPS30_P2: ['PM2.5', VOLUME_MICROGRAMS_PER_CUBIC_METER, None],
SENSOR_SPS30_P4: ['PM4', VOLUME_MICROGRAMS_PER_CUBIC_METER, None],
SENSOR_SPS30_P1: ['PM10', VOLUME_MICROGRAMS_PER_CUBIC_METER, None],
}

DEFAULT_NAME = 'Luftdaten Sensor'
Expand Down Expand Up @@ -136,6 +144,12 @@ def device_class(self):
"""Return the device class of this entity, if any."""
return self._device_class

@property
def icon(self):
"""Icon of the sensor, if class is None."""
if SENSOR_TYPES[self.sensor_type][2] == None:
return 'mdi:cloud-search-outline'

async def async_update(self):
"""Get the latest data from REST API and update the state."""
try:
Expand Down

0 comments on commit 0981cde

Please sign in to comment.