From 656ef143daf5184a8aa340d320dca7d36473566e Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Wed, 6 Mar 2024 16:27:13 +0100 Subject: [PATCH] Add icon translations to Wallbox (#112350) * Add icon translations to Wallbox * fix --- homeassistant/components/wallbox/icons.json | 27 +++++++++++++++++++++ homeassistant/components/wallbox/sensor.py | 7 ------ tests/components/wallbox/test_sensor.py | 3 +-- 3 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 homeassistant/components/wallbox/icons.json diff --git a/homeassistant/components/wallbox/icons.json b/homeassistant/components/wallbox/icons.json new file mode 100644 index 00000000000..359e05cb441 --- /dev/null +++ b/homeassistant/components/wallbox/icons.json @@ -0,0 +1,27 @@ +{ + "entity": { + "sensor": { + "charging_speed": { + "default": "mdi:speedometer" + }, + "added_range": { + "default": "mdi:map-marker-distance" + }, + "cost": { + "default": "mdi:ev-station" + }, + "current_mode": { + "default": "mdi:ev-station" + }, + "depot_price": { + "default": "mdi:ev-station" + }, + "energy_price": { + "default": "mdi:ev-station" + }, + "status_description": { + "default": "mdi:ev-station" + } + } + } +} diff --git a/homeassistant/components/wallbox/sensor.py b/homeassistant/components/wallbox/sensor.py index 50312487e15..7fb9a488244 100644 --- a/homeassistant/components/wallbox/sensor.py +++ b/homeassistant/components/wallbox/sensor.py @@ -78,14 +78,12 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = { CHARGER_CHARGING_SPEED_KEY: WallboxSensorEntityDescription( key=CHARGER_CHARGING_SPEED_KEY, translation_key=CHARGER_CHARGING_SPEED_KEY, - icon="mdi:speedometer", precision=0, state_class=SensorStateClass.MEASUREMENT, ), CHARGER_ADDED_RANGE_KEY: WallboxSensorEntityDescription( key=CHARGER_ADDED_RANGE_KEY, translation_key=CHARGER_ADDED_RANGE_KEY, - icon="mdi:map-marker-distance", precision=0, native_unit_of_measurement=UnitOfLength.KILOMETERS, device_class=SensorDeviceClass.DISTANCE, @@ -110,7 +108,6 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = { CHARGER_COST_KEY: WallboxSensorEntityDescription( key=CHARGER_COST_KEY, translation_key=CHARGER_COST_KEY, - icon="mdi:ev-station", state_class=SensorStateClass.TOTAL_INCREASING, ), CHARGER_STATE_OF_CHARGE_KEY: WallboxSensorEntityDescription( @@ -123,26 +120,22 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = { CHARGER_CURRENT_MODE_KEY: WallboxSensorEntityDescription( key=CHARGER_CURRENT_MODE_KEY, translation_key=CHARGER_CURRENT_MODE_KEY, - icon="mdi:ev-station", ), CHARGER_DEPOT_PRICE_KEY: WallboxSensorEntityDescription( key=CHARGER_DEPOT_PRICE_KEY, translation_key=CHARGER_DEPOT_PRICE_KEY, - icon="mdi:ev-station", precision=2, state_class=SensorStateClass.MEASUREMENT, ), CHARGER_ENERGY_PRICE_KEY: WallboxSensorEntityDescription( key=CHARGER_ENERGY_PRICE_KEY, translation_key=CHARGER_ENERGY_PRICE_KEY, - icon="mdi:ev-station", precision=2, state_class=SensorStateClass.MEASUREMENT, ), CHARGER_STATUS_DESCRIPTION_KEY: WallboxSensorEntityDescription( key=CHARGER_STATUS_DESCRIPTION_KEY, translation_key=CHARGER_STATUS_DESCRIPTION_KEY, - icon="mdi:ev-station", ), CHARGER_MAX_CHARGING_CURRENT_KEY: WallboxSensorEntityDescription( key=CHARGER_MAX_CHARGING_CURRENT_KEY, diff --git a/tests/components/wallbox/test_sensor.py b/tests/components/wallbox/test_sensor.py index ca12e1d9ac3..ad9ed6c0706 100644 --- a/tests/components/wallbox/test_sensor.py +++ b/tests/components/wallbox/test_sensor.py @@ -1,5 +1,5 @@ """Test Wallbox Switch component.""" -from homeassistant.const import CONF_ICON, CONF_UNIT_OF_MEASUREMENT, UnitOfPower +from homeassistant.const import CONF_UNIT_OF_MEASUREMENT, UnitOfPower from homeassistant.core import HomeAssistant from . import setup_integration @@ -24,7 +24,6 @@ async def test_wallbox_sensor_class( assert state.name == "Wallbox WallboxName Charging power" state = hass.states.get(MOCK_SENSOR_CHARGING_SPEED_ID) - assert state.attributes[CONF_ICON] == "mdi:speedometer" assert state.name == "Wallbox WallboxName Charging speed" # Test round with precision '0' works