Skip to content

Commit

Permalink
Merge pull request #60 from lichtteil/dev
Browse files Browse the repository at this point in the history
Compatibility and Sensirion SEN5X sensors
  • Loading branch information
lichtteil authored Jun 12, 2023
2 parents 16fa73f + be92331 commit 798c7d4
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ At the moment following sensor data can be read:
- SPS30_P1
- SPS30_P2
- SPS30_P4
- SEN5X_P0
- SEN5X_P1
- SEN5X_P2
- SEN5X_P4
- SEN5X_NOX
- SEN5X_VOC
- temperature
- signal
Expand Down
58 changes: 54 additions & 4 deletions custom_components/local_luftdaten/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
PERCENTAGE,
PRESSURE_PA,
UnitOfPressure,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS,
)
Expand Down Expand Up @@ -48,6 +48,12 @@
SENSOR_SPS30_P1 = 'SPS30_P1'
SENSOR_SPS30_P2 = 'SPS30_P2'
SENSOR_SPS30_P4 = 'SPS30_P4'
SENSOR_SEN5X_P0 = 'SEN5X_P0'
SENSOR_SEN5X_P1 = 'SEN5X_P1'
SENSOR_SEN5X_P2 = 'SEN5X_P2'
SENSOR_SEN5X_P4 = 'SEN5X_P4'
SENSOR_SEN5X_NOX = 'SEN5X_NOX'
SENSOR_SEN5X_VOC = 'SEN5X_VOC'
SENSOR_TEMPERATURE = 'temperature'
SENSOR_WIFI_SIGNAL = 'signal'

Expand All @@ -63,7 +69,7 @@
device_class=SensorDeviceClass.PRESSURE,
key=SENSOR_BME280_PRESSURE,
name='Pressure',
native_unit_of_measurement=PRESSURE_PA,
native_unit_of_measurement=UnitOfPressure.PA,
state_class=SensorStateClass.MEASUREMENT,
),
SENSOR_BME280_TEMPERATURE: SensorEntityDescription(
Expand All @@ -77,7 +83,7 @@
device_class=SensorDeviceClass.PRESSURE,
key=SENSOR_BMP_PRESSURE,
name='Pressure',
native_unit_of_measurement=PRESSURE_PA,
native_unit_of_measurement=UnitOfPressure.PA,
state_class=SensorStateClass.MEASUREMENT,
),
SENSOR_BMP_TEMPERATURE: SensorEntityDescription(
Expand All @@ -98,7 +104,7 @@
device_class=SensorDeviceClass.PRESSURE,
key=SENSOR_BMP280_PRESSURE,
name='Pressure',
native_unit_of_measurement=PRESSURE_PA,
native_unit_of_measurement=UnitOfPressure.PA,
state_class=SensorStateClass.MEASUREMENT,
),
SENSOR_DS18B20_TEMPERATURE: SensorEntityDescription(
Expand Down Expand Up @@ -234,6 +240,50 @@
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
),
SENSOR_SEN5X_P0: SensorEntityDescription(
device_class=SensorDeviceClass.PM1,
key=SENSOR_SEN5X_P0,
name='PM1',
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
),
SENSOR_SEN5X_P1: SensorEntityDescription(
device_class=SensorDeviceClass.PM10,
key=SENSOR_SEN5X_P1,
name='PM10',
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
),
SENSOR_SEN5X_P2: SensorEntityDescription(
device_class=SensorDeviceClass.PM25,
key=SENSOR_SEN5X_P2,
name='PM2.5',
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
),
SENSOR_SEN5X_P4: SensorEntityDescription(
device_class=SensorDeviceClass.PM25, # SensorDeviceClass.PM4 not supported.
key=SENSOR_SEN5X_P4,
name='PM4',
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
),
SENSOR_SEN5X_NOX: SensorEntityDescription(
device_class=SensorDeviceClass.AQI,
# SensorDeviceClass.NOX_INDEX is not supported
# SensorDeviceClass.NITROGEN_MONOXIDE and .NITROGEN_DIOXIDE are supported, but require a unit of ug/m3 which is not appropriate for a unitless index
key=SENSOR_SEN5X_NOX,
name='NOX',
state_class=SensorStateClass.MEASUREMENT,
),
SENSOR_SEN5X_VOC: SensorEntityDescription(
device_class=SensorDeviceClass.AQI,
# SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_INDEX is not supported
# SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS is supported, but requires a unit of ug/m3 which is not appropriate for a unitless index
key=SENSOR_SEN5X_VOC,
name='VOC',
state_class=SensorStateClass.MEASUREMENT,
),
SENSOR_TEMPERATURE: SensorEntityDescription(
device_class=SensorDeviceClass.TEMPERATURE,
key=SENSOR_TEMPERATURE,
Expand Down
2 changes: 0 additions & 2 deletions custom_components/local_luftdaten/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,13 @@
})


@asyncio.coroutine
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Luftdaten sensor."""
name = config.get(CONF_NAME)
host = config.get(CONF_HOST)
scan_interval = config.get(CONF_SCAN_INTERVAL)

verify_ssl = config.get(CONF_VERIFY_SSL)


resource = config.get(CONF_RESOURCE).format(host)

Expand Down

0 comments on commit 798c7d4

Please sign in to comment.