From 0e0c1d337ff6767253723e1e7e0f90744cf5c72f Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Tue, 5 Mar 2024 08:50:46 +0100 Subject: [PATCH] Add icon translations to P1 monitor (#111998) * Add icon translations to P1 monitor * Add icon translations to P1 monitor --- homeassistant/components/p1_monitor/icons.json | 9 +++++++++ homeassistant/components/p1_monitor/sensor.py | 1 - tests/components/p1_monitor/test_sensor.py | 7 ------- 3 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 homeassistant/components/p1_monitor/icons.json diff --git a/homeassistant/components/p1_monitor/icons.json b/homeassistant/components/p1_monitor/icons.json new file mode 100644 index 00000000000..d95084ca0e6 --- /dev/null +++ b/homeassistant/components/p1_monitor/icons.json @@ -0,0 +1,9 @@ +{ + "entity": { + "sensor": { + "energy_tariff_period": { + "default": "mdi:calendar-clock" + } + } + } +} diff --git a/homeassistant/components/p1_monitor/sensor.py b/homeassistant/components/p1_monitor/sensor.py index 587dc980e41..4108194aced 100644 --- a/homeassistant/components/p1_monitor/sensor.py +++ b/homeassistant/components/p1_monitor/sensor.py @@ -88,7 +88,6 @@ SENSORS_SMARTMETER: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="energy_tariff_period", translation_key="energy_tariff_period", - icon="mdi:calendar-clock", ), ) diff --git a/tests/components/p1_monitor/test_sensor.py b/tests/components/p1_monitor/test_sensor.py index f84df458d4b..4e6b7580319 100644 --- a/tests/components/p1_monitor/test_sensor.py +++ b/tests/components/p1_monitor/test_sensor.py @@ -13,7 +13,6 @@ from homeassistant.components.sensor import ( from homeassistant.const import ( ATTR_DEVICE_CLASS, ATTR_FRIENDLY_NAME, - ATTR_ICON, ATTR_UNIT_OF_MEASUREMENT, CURRENCY_EURO, UnitOfElectricCurrent, @@ -47,7 +46,6 @@ async def test_smartmeter( assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.WATT assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.POWER - assert ATTR_ICON not in state.attributes state = hass.states.get("sensor.smartmeter_energy_consumption_high_tariff") entry = entity_registry.async_get( @@ -64,7 +62,6 @@ async def test_smartmeter( assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL_INCREASING assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfEnergy.KILO_WATT_HOUR assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY - assert ATTR_ICON not in state.attributes state = hass.states.get("sensor.smartmeter_energy_tariff_period") entry = entity_registry.async_get("sensor.smartmeter_energy_tariff_period") @@ -73,7 +70,6 @@ async def test_smartmeter( assert entry.unique_id == f"{entry_id}_smartmeter_energy_tariff_period" assert state.state == "high" assert state.attributes.get(ATTR_FRIENDLY_NAME) == "SmartMeter Energy tariff period" - assert state.attributes.get(ATTR_ICON) == "mdi:calendar-clock" assert ATTR_UNIT_OF_MEASUREMENT not in state.attributes assert ATTR_DEVICE_CLASS not in state.attributes @@ -109,7 +105,6 @@ async def test_phases( state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfElectricPotential.VOLT ) assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.VOLTAGE - assert ATTR_ICON not in state.attributes state = hass.states.get("sensor.phases_current_phase_l1") entry = entity_registry.async_get("sensor.phases_current_phase_l1") @@ -123,7 +118,6 @@ async def test_phases( state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfElectricCurrent.AMPERE ) assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.CURRENT - assert ATTR_ICON not in state.attributes state = hass.states.get("sensor.phases_power_consumed_phase_l1") entry = entity_registry.async_get("sensor.phases_power_consumed_phase_l1") @@ -135,7 +129,6 @@ async def test_phases( assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.WATT assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.POWER - assert ATTR_ICON not in state.attributes assert entry.device_id device_entry = device_registry.async_get(entry.device_id)