1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-08 17:49:37 +01:00

Add ice phenomena sensor to IMGW-PIB integration (#168548)

This commit is contained in:
Maciej Bieniek
2026-04-20 12:07:26 +02:00
committed by GitHub
parent a1cde0308a
commit 10fd51b34d
4 changed files with 78 additions and 1 deletions
@@ -4,6 +4,9 @@
"hydrological_alert": {
"default": "mdi:alert-octagon-outline"
},
"ice_phenomena": {
"default": "mdi:snowflake"
},
"water_flow": {
"default": "mdi:waves-arrow-right"
},
+14 -1
View File
@@ -16,7 +16,12 @@ from homeassistant.components.sensor import (
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.const import UnitOfLength, UnitOfTemperature, UnitOfVolumeFlowRate
from homeassistant.const import (
PERCENTAGE,
UnitOfLength,
UnitOfTemperature,
UnitOfVolumeFlowRate,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
@@ -60,6 +65,14 @@ SENSOR_TYPES: tuple[ImgwPibSensorEntityDescription, ...] = (
value=lambda data: data.hydrological_alert.value,
attrs=gen_alert_attributes,
),
ImgwPibSensorEntityDescription(
key="ice_phenomena",
translation_key="ice_phenomena",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
value=lambda data: data.ice_phenomena.value,
suggested_display_precision=0,
),
ImgwPibSensorEntityDescription(
key="water_flow",
translation_key="water_flow",
@@ -59,6 +59,9 @@
}
}
},
"ice_phenomena": {
"name": "Ice phenomena"
},
"water_flow": {
"name": "Water flow"
},
@@ -70,6 +70,64 @@
'state': 'rapid_water_level_rise',
})
# ---
# name: test_sensor[sensor.river_name_station_name_ice_phenomena-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'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.river_name_station_name_ice_phenomena',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Ice phenomena',
'options': dict({
'sensor': dict({
'suggested_display_precision': 0,
}),
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Ice phenomena',
'platform': 'imgw_pib',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'ice_phenomena',
'unique_id': '123_ice_phenomena',
'unit_of_measurement': '%',
})
# ---
# name: test_sensor[sensor.river_name_station_name_ice_phenomena-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by IMGW-PIB',
'friendly_name': 'River Name (Station Name) Ice phenomena',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': '%',
}),
'context': <ANY>,
'entity_id': 'sensor.river_name_station_name_ice_phenomena',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '20',
})
# ---
# name: test_sensor[sensor.river_name_station_name_water_flow-entry]
EntityRegistryEntrySnapshot({
'aliases': list([