Add new sensors to GIOS integration (#148510)

This commit is contained in:
Maciej Bieniek 2025-07-09 21:43:02 +02:00 committed by GitHub
parent e42ca06173
commit ce5f06b1e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 181 additions and 2 deletions

View File

@ -19,6 +19,8 @@ API_TIMEOUT: Final = 30
ATTR_C6H6: Final = "c6h6"
ATTR_CO: Final = "co"
ATTR_NO: Final = "no"
ATTR_NOX: Final = "nox"
ATTR_NO2: Final = "no2"
ATTR_O3: Final = "o3"
ATTR_PM10: Final = "pm10"

View File

@ -13,6 +13,9 @@
"no2_index": {
"default": "mdi:molecule"
},
"nox": {
"default": "mdi:molecule"
},
"o3_index": {
"default": "mdi:molecule"
},

View File

@ -27,7 +27,9 @@ from .const import (
ATTR_AQI,
ATTR_C6H6,
ATTR_CO,
ATTR_NO,
ATTR_NO2,
ATTR_NOX,
ATTR_O3,
ATTR_PM10,
ATTR_PM25,
@ -74,6 +76,14 @@ SENSOR_TYPES: tuple[GiosSensorEntityDescription, ...] = (
state_class=SensorStateClass.MEASUREMENT,
translation_key="co",
),
GiosSensorEntityDescription(
key=ATTR_NO,
value=lambda sensors: sensors.no.value if sensors.no else None,
suggested_display_precision=0,
device_class=SensorDeviceClass.NITROGEN_MONOXIDE,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
),
GiosSensorEntityDescription(
key=ATTR_NO2,
value=lambda sensors: sensors.no2.value if sensors.no2 else None,
@ -90,6 +100,14 @@ SENSOR_TYPES: tuple[GiosSensorEntityDescription, ...] = (
options=["very_bad", "bad", "sufficient", "moderate", "good", "very_good"],
translation_key="no2_index",
),
GiosSensorEntityDescription(
key=ATTR_NOX,
translation_key=ATTR_NOX,
value=lambda sensors: sensors.nox.value if sensors.nox else None,
suggested_display_precision=0,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
),
GiosSensorEntityDescription(
key=ATTR_O3,
value=lambda sensors: sensors.o3.value if sensors.o3 else None,

View File

@ -77,6 +77,9 @@
}
}
},
"nox": {
"name": "Nitrogen oxides"
},
"o3_index": {
"name": "Ozone index",
"state": {

View File

@ -20,6 +20,13 @@
{ "Data": "2020-07-31 13:00:00", "Wartość": 251.097 }
]
},
"no": {
"Lista danych pomiarowych": [
{ "Data": "2020-07-31 15:00:00", "Wartość": 5.1 },
{ "Data": "2020-07-31 14:00:00", "Wartość": 4.0 },
{ "Data": "2020-07-31 13:00:00", "Wartość": 5.2 }
]
},
"no2": {
"Lista danych pomiarowych": [
{ "Data": "2020-07-31 15:00:00", "Wartość": 7.13411 },
@ -27,6 +34,13 @@
{ "Data": "2020-07-31 13:00:00", "Wartość": 9.32578 }
]
},
"nox": {
"Lista danych pomiarowych": [
{ "Data": "2020-07-31 15:00:00", "Wartość": 5.5 },
{ "Data": "2020-07-31 14:00:00", "Wartość": 6.3 },
{ "Data": "2020-07-31 13:00:00", "Wartość": 4.9 }
]
},
"o3": {
"Lista danych pomiarowych": [
{ "Data": "2020-07-31 15:00:00", "Wartość": 95.7768 },

View File

@ -23,6 +23,14 @@
"Wskaźnik - kod": "CO",
"Id wskaźnika": 8
},
{
"Identyfikator stanowiska": 664,
"Identyfikator stacji": 117,
"Wskaźnik": "tlenek azotu",
"Wskaźnik - wzór": "NO",
"Wskaźnik - kod": "NO",
"Id wskaźnika": 16
},
{
"Identyfikator stanowiska": 665,
"Identyfikator stacji": 117,
@ -31,6 +39,14 @@
"Wskaźnik - kod": "NO2",
"Id wskaźnika": 6
},
{
"Identyfikator stanowiska": 666,
"Identyfikator stacji": 117,
"Wskaźnik": "tlenki azotu",
"Wskaźnik - wzór": "NOx",
"Wskaźnik - kod": "NOx",
"Id wskaźnika": 7
},
{
"Identyfikator stanowiska": 667,
"Identyfikator stacji": 117,

View File

@ -42,14 +42,24 @@
'name': 'carbon monoxide',
'value': 251.874,
}),
'no': None,
'no': dict({
'id': 664,
'index': None,
'name': 'nitrogen monoxide',
'value': 5.1,
}),
'no2': dict({
'id': 665,
'index': 'good',
'name': 'nitrogen dioxide',
'value': 7.13411,
}),
'nox': None,
'nox': dict({
'id': 666,
'index': None,
'name': 'nitrogen oxides',
'value': 5.5,
}),
'o3': dict({
'id': 667,
'index': 'good',

View File

@ -302,6 +302,119 @@
'state': 'good',
})
# ---
# name: test_sensor[sensor.home_nitrogen_monoxide-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.home_nitrogen_monoxide',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 0,
}),
}),
'original_device_class': <SensorDeviceClass.NITROGEN_MONOXIDE: 'nitrogen_monoxide'>,
'original_icon': None,
'original_name': 'Nitrogen monoxide',
'platform': 'gios',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '123-no',
'unit_of_measurement': 'µg/m³',
})
# ---
# name: test_sensor[sensor.home_nitrogen_monoxide-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by GIOŚ',
'device_class': 'nitrogen_monoxide',
'friendly_name': 'Home Nitrogen monoxide',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': 'µg/m³',
}),
'context': <ANY>,
'entity_id': 'sensor.home_nitrogen_monoxide',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '5.1',
})
# ---
# name: test_sensor[sensor.home_nitrogen_oxides-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.home_nitrogen_oxides',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 0,
}),
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Nitrogen oxides',
'platform': 'gios',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'nox',
'unique_id': '123-nox',
'unit_of_measurement': 'µg/m³',
})
# ---
# name: test_sensor[sensor.home_nitrogen_oxides-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by GIOŚ',
'friendly_name': 'Home Nitrogen oxides',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': 'µg/m³',
}),
'context': <ANY>,
'entity_id': 'sensor.home_nitrogen_oxides',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '5.5',
})
# ---
# name: test_sensor[sensor.home_ozone-entry]
EntityRegistryEntrySnapshot({
'aliases': set({