From 10fd51b34d7ba5684fe00df2f192563eac78c078 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Mon, 20 Apr 2026 12:07:26 +0200 Subject: [PATCH] Add `ice phenomena` sensor to IMGW-PIB integration (#168548) --- homeassistant/components/imgw_pib/icons.json | 3 + homeassistant/components/imgw_pib/sensor.py | 15 ++++- .../components/imgw_pib/strings.json | 3 + .../imgw_pib/snapshots/test_sensor.ambr | 58 +++++++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/imgw_pib/icons.json b/homeassistant/components/imgw_pib/icons.json index 0265c6c2ec0..c394679056e 100644 --- a/homeassistant/components/imgw_pib/icons.json +++ b/homeassistant/components/imgw_pib/icons.json @@ -4,6 +4,9 @@ "hydrological_alert": { "default": "mdi:alert-octagon-outline" }, + "ice_phenomena": { + "default": "mdi:snowflake" + }, "water_flow": { "default": "mdi:waves-arrow-right" }, diff --git a/homeassistant/components/imgw_pib/sensor.py b/homeassistant/components/imgw_pib/sensor.py index 170736d8f6c..c474154a42f 100644 --- a/homeassistant/components/imgw_pib/sensor.py +++ b/homeassistant/components/imgw_pib/sensor.py @@ -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", diff --git a/homeassistant/components/imgw_pib/strings.json b/homeassistant/components/imgw_pib/strings.json index e746d66a945..15a14e4d6f2 100644 --- a/homeassistant/components/imgw_pib/strings.json +++ b/homeassistant/components/imgw_pib/strings.json @@ -59,6 +59,9 @@ } } }, + "ice_phenomena": { + "name": "Ice phenomena" + }, "water_flow": { "name": "Water flow" }, diff --git a/tests/components/imgw_pib/snapshots/test_sensor.ambr b/tests/components/imgw_pib/snapshots/test_sensor.ambr index 01cfc4de4b1..260dacbc7d0 100644 --- a/tests/components/imgw_pib/snapshots/test_sensor.ambr +++ b/tests/components/imgw_pib/snapshots/test_sensor.ambr @@ -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': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + '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': , + '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': , + 'unit_of_measurement': '%', + }), + 'context': , + 'entity_id': 'sensor.river_name_station_name_ice_phenomena', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '20', + }) +# --- # name: test_sensor[sensor.river_name_station_name_water_flow-entry] EntityRegistryEntrySnapshot({ 'aliases': list([