diff --git a/homeassistant/components/shelly/button.py b/homeassistant/components/shelly/button.py index 6dd97731ab5..f4294dee9ee 100644 --- a/homeassistant/components/shelly/button.py +++ b/homeassistant/components/shelly/button.py @@ -58,7 +58,7 @@ BUTTONS: Final[list[ShellyButtonDescription[Any]]] = [ ShellyButtonDescription[ShellyBlockCoordinator]( key="self_test", name="Self test", - icon="mdi:progress-wrench", + translation_key="self_test", entity_category=EntityCategory.DIAGNOSTIC, press_action=lambda coordinator: coordinator.device.trigger_shelly_gas_self_test(), supported=lambda coordinator: coordinator.device.model in SHELLY_GAS_MODELS, @@ -66,7 +66,7 @@ BUTTONS: Final[list[ShellyButtonDescription[Any]]] = [ ShellyButtonDescription[ShellyBlockCoordinator]( key="mute", name="Mute", - icon="mdi:volume-mute", + translation_key="mute", entity_category=EntityCategory.CONFIG, press_action=lambda coordinator: coordinator.device.trigger_shelly_gas_mute(), supported=lambda coordinator: coordinator.device.model in SHELLY_GAS_MODELS, @@ -74,7 +74,7 @@ BUTTONS: Final[list[ShellyButtonDescription[Any]]] = [ ShellyButtonDescription[ShellyBlockCoordinator]( key="unmute", name="Unmute", - icon="mdi:volume-high", + translation_key="unmute", entity_category=EntityCategory.CONFIG, press_action=lambda coordinator: coordinator.device.trigger_shelly_gas_unmute(), supported=lambda coordinator: coordinator.device.model in SHELLY_GAS_MODELS, diff --git a/homeassistant/components/shelly/climate.py b/homeassistant/components/shelly/climate.py index 59343ca6d2f..ef0e4879540 100644 --- a/homeassistant/components/shelly/climate.py +++ b/homeassistant/components/shelly/climate.py @@ -156,7 +156,6 @@ class BlockSleepingClimate( """Representation of a Shelly climate device.""" _attr_hvac_modes = [HVACMode.OFF, HVACMode.HEAT] - _attr_icon = "mdi:thermostat" _attr_max_temp = SHTRV_01_TEMPERATURE_SETTINGS["max"] _attr_min_temp = SHTRV_01_TEMPERATURE_SETTINGS["min"] _attr_supported_features = ( @@ -439,7 +438,6 @@ class BlockSleepingClimate( class RpcClimate(ShellyRpcEntity, ClimateEntity): """Entity that controls a thermostat on RPC based Shelly devices.""" - _attr_icon = "mdi:thermostat" _attr_max_temp = RPC_THERMOSTAT_SETTINGS["max"] _attr_min_temp = RPC_THERMOSTAT_SETTINGS["min"] _attr_supported_features = ( diff --git a/homeassistant/components/shelly/entity.py b/homeassistant/components/shelly/entity.py index 3dd156e9e30..846c527a5f8 100644 --- a/homeassistant/components/shelly/entity.py +++ b/homeassistant/components/shelly/entity.py @@ -273,7 +273,6 @@ class BlockEntityDescription(EntityDescription): # restrict the type to str. name: str = "" - icon_fn: Callable[[dict], str] | None = None unit_fn: Callable[[dict], str] | None = None value: Callable[[Any], Any] = lambda val: val available: Callable[[Block], bool] | None = None diff --git a/homeassistant/components/shelly/icons.json b/homeassistant/components/shelly/icons.json new file mode 100644 index 00000000000..1baf61acf3b --- /dev/null +++ b/homeassistant/components/shelly/icons.json @@ -0,0 +1,46 @@ +{ + "entity": { + "button": { + "mute": { + "default": "mdi:volume-mute" + }, + "self_test": { + "default": "mdi:progress-wrench" + }, + "unmute": { + "default": "mdi:volume-high" + } + }, + "number": { + "valve_position": { + "default": "mdi:pipe-valve" + } + }, + "sensor": { + "gas_concentration": { + "default": "mdi:gauge" + }, + "lamp_life": { + "default": "mdi:progress-wrench" + }, + "operation": { + "default": "mdi:cog-transfer" + }, + "tilt": { + "default": "mdi:angle-acute" + }, + "valve_status": { + "default": "mdi:valve" + } + }, + "switch": { + "valve_switch": { + "default": "mdi:valve", + "state": { + "off": "mdi:valve-closed", + "on": "mdi:valve-open" + } + } + } + } +} diff --git a/homeassistant/components/shelly/number.py b/homeassistant/components/shelly/number.py index 4cab817e67c..ef3963c53c3 100644 --- a/homeassistant/components/shelly/number.py +++ b/homeassistant/components/shelly/number.py @@ -40,7 +40,7 @@ class BlockNumberDescription(BlockEntityDescription, NumberEntityDescription): NUMBERS: dict[tuple[str, str], BlockNumberDescription] = { ("device", "valvePos"): BlockNumberDescription( key="device|valvepos", - icon="mdi:pipe-valve", + translation_key="valve_position", name="Valve position", native_unit_of_measurement=PERCENTAGE, available=lambda block: cast(int, block.valveError) != 1, diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index 824b7264f26..8dde2d323f0 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -235,7 +235,7 @@ SENSORS: dict[tuple[str, str], BlockSensorDescription] = { key="sensor|concentration", name="Gas concentration", native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION, - icon="mdi:gauge", + translation_key="gas_concentration", state_class=SensorStateClass.MEASUREMENT, ), ("sensor", "temp"): BlockSensorDescription( @@ -279,14 +279,14 @@ SENSORS: dict[tuple[str, str], BlockSensorDescription] = { key="sensor|tilt", name="Tilt", native_unit_of_measurement=DEGREE, - icon="mdi:angle-acute", + translation_key="tilt", state_class=SensorStateClass.MEASUREMENT, ), ("relay", "totalWorkTime"): BlockSensorDescription( key="relay|totalWorkTime", name="Lamp life", native_unit_of_measurement=PERCENTAGE, - icon="mdi:progress-wrench", + translation_key="lamp_life", value=lambda value: 100 - (value / 3600 / SHAIR_MAX_WORK_HOURS), suggested_display_precision=1, extra_state_attributes=lambda block: { @@ -308,7 +308,6 @@ SENSORS: dict[tuple[str, str], BlockSensorDescription] = { device_class=SensorDeviceClass.ENUM, options=["unknown", "warmup", "normal", "fault"], translation_key="operation", - icon="mdi:cog-transfer", value=lambda value: value, extra_state_attributes=lambda block: {"self_test": block.selfTest}, ), @@ -316,7 +315,6 @@ SENSORS: dict[tuple[str, str], BlockSensorDescription] = { key="valve|valve", name="Valve status", translation_key="valve_status", - icon="mdi:valve", device_class=SensorDeviceClass.ENUM, options=[ "checking", diff --git a/homeassistant/components/shelly/switch.py b/homeassistant/components/shelly/switch.py index e5d91943a55..60f4c581f49 100644 --- a/homeassistant/components/shelly/switch.py +++ b/homeassistant/components/shelly/switch.py @@ -153,6 +153,7 @@ class BlockValveSwitch(ShellyBlockAttributeEntity, SwitchEntity): """ entity_description: BlockSwitchDescription + _attr_translation_key = "valve_switch" def __init__( self, @@ -173,11 +174,6 @@ class BlockValveSwitch(ShellyBlockAttributeEntity, SwitchEntity): return self.attribute_value in GAS_VALVE_OPEN_STATES - @property - def icon(self) -> str: - """Return the icon.""" - return "mdi:valve-open" if self.is_on else "mdi:valve-closed" - async def async_turn_on(self, **kwargs: Any) -> None: """Open valve.""" async_create_issue( diff --git a/tests/components/shelly/test_switch.py b/tests/components/shelly/test_switch.py index 8a0cefe3ae0..d7cbcc75439 100644 --- a/tests/components/shelly/test_switch.py +++ b/tests/components/shelly/test_switch.py @@ -15,7 +15,6 @@ from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState from homeassistant.const import ( ATTR_ENTITY_ID, - ATTR_ICON, SERVICE_TURN_OFF, SERVICE_TURN_ON, STATE_OFF, @@ -290,7 +289,6 @@ async def test_block_device_gas_valve( state = hass.states.get(entity_id) assert state assert state.state == STATE_ON # valve is open - assert state.attributes.get(ATTR_ICON) == "mdi:valve-open" await hass.services.async_call( SWITCH_DOMAIN, @@ -302,7 +300,6 @@ async def test_block_device_gas_valve( state = hass.states.get(entity_id) assert state assert state.state == STATE_OFF # valve is closed - assert state.attributes.get(ATTR_ICON) == "mdi:valve-closed" monkeypatch.setattr(mock_block_device.blocks[GAS_VALVE_BLOCK_ID], "valve", "opened") mock_block_device.mock_update() @@ -311,7 +308,6 @@ async def test_block_device_gas_valve( state = hass.states.get(entity_id) assert state assert state.state == STATE_ON # valve is open - assert state.attributes.get(ATTR_ICON) == "mdi:valve-open" async def test_wall_display_thermostat_mode(