diff --git a/README.md b/README.md index b0b8b43..3cd625e 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/custom_components/local_luftdaten/sensor.py b/custom_components/local_luftdaten/sensor.py index b3b8ba6..7386e80 100644 --- a/custom_components/local_luftdaten/sensor.py +++ b/custom_components/local_luftdaten/sensor.py @@ -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'], @@ -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' @@ -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: