diff --git a/homeassistant/components/shelly/icons.json b/homeassistant/components/shelly/icons.json index 1e4e40287f49..cabef1d5c0a1 100644 --- a/homeassistant/components/shelly/icons.json +++ b/homeassistant/components/shelly/icons.json @@ -77,16 +77,26 @@ "on": "mdi:home-export-outline" } }, - "cury_boost": { - "default": "mdi:rocket-launch" - }, - "cury_slot": { + "left_slot": { "default": "mdi:scent", "state": { "off": "mdi:scent-off", "on": "mdi:scent" } }, + "left_slot_boost": { + "default": "mdi:rocket-launch" + }, + "right_slot": { + "default": "mdi:scent", + "state": { + "off": "mdi:scent-off", + "on": "mdi:scent" + } + }, + "right_slot_boost": { + "default": "mdi:rocket-launch" + }, "valve_switch": { "default": "mdi:valve", "state": { diff --git a/homeassistant/components/shelly/strings.json b/homeassistant/components/shelly/strings.json index 56e389f5023b..59fa41bbb2ec 100644 --- a/homeassistant/components/shelly/strings.json +++ b/homeassistant/components/shelly/strings.json @@ -463,6 +463,41 @@ "name": "Water temperature" } }, + "switch": { + "charging": { + "name": "Charging" + }, + "child_lock": { + "name": "Child lock" + }, + "frost_protection": { + "name": "[%key:component::shelly::entity::climate::thermostat::state_attributes::preset_mode::state::frost_protection%]" + }, + "left_slot": { + "name": "Left slot" + }, + "left_slot_boost": { + "name": "Left slot boost" + }, + "motion_detection": { + "name": "Motion detection" + }, + "right_slot": { + "name": "Right slot" + }, + "right_slot_boost": { + "name": "Right slot boost" + }, + "thermostat_enabled": { + "name": "Thermostat enabled" + }, + "valve_opened": { + "name": "Valve opened" + }, + "zone_with_number": { + "name": "Zone {zone_number}" + } + }, "update": { "beta_firmware": { "name": "Beta firmware" diff --git a/homeassistant/components/shelly/switch.py b/homeassistant/components/shelly/switch.py index 10fc7848ea89..401a17853834 100644 --- a/homeassistant/components/shelly/switch.py +++ b/homeassistant/components/shelly/switch.py @@ -67,7 +67,7 @@ BLOCK_RELAY_SWITCHES = { BLOCK_SLEEPING_MOTION_SWITCH = { ("sensor", "motionActive"): BlockSwitchDescription( key="sensor|motionActive", - name="Motion detection", + translation_key="motion_detection", entity_category=EntityCategory.CONFIG, ) } @@ -99,7 +99,7 @@ RPC_SWITCHES = { "boolean_generic": RpcSwitchDescription( key="boolean", sub_key="value", - removal_condition=lambda config, _status, key: not is_view_for_platform( + removal_condition=lambda config, _, key: not is_view_for_platform( config, key, SWITCH_PLATFORM ), is_on=lambda status: bool(status["value"]), @@ -111,6 +111,7 @@ RPC_SWITCHES = { "boolean_anti_freeze": RpcSwitchDescription( key="boolean", sub_key="value", + translation_key="frost_protection", entity_registry_enabled_default=False, is_on=lambda status: bool(status["value"]), method_on="boolean_set", @@ -122,6 +123,7 @@ RPC_SWITCHES = { "boolean_child_lock": RpcSwitchDescription( key="boolean", sub_key="value", + translation_key="child_lock", is_on=lambda status: bool(status["value"]), method_on="boolean_set", method_off="boolean_set", @@ -132,6 +134,7 @@ RPC_SWITCHES = { "boolean_enable": RpcSwitchDescription( key="boolean", sub_key="value", + translation_key="thermostat_enabled", entity_registry_enabled_default=False, is_on=lambda status: bool(status["value"]), method_on="boolean_set", @@ -143,7 +146,7 @@ RPC_SWITCHES = { "boolean_start_charging": RpcSwitchDescription( key="boolean", sub_key="value", - name="Charging", + translation_key="charging", is_on=lambda status: bool(status["value"]), method_on="boolean_set", method_off="boolean_set", @@ -154,6 +157,7 @@ RPC_SWITCHES = { "boolean_state": RpcSwitchDescription( key="boolean", sub_key="value", + translation_key="valve_opened", entity_registry_enabled_default=False, is_on=lambda status: bool(status["value"]), method_on="boolean_set", @@ -165,6 +169,8 @@ RPC_SWITCHES = { "boolean_zone0": RpcSwitchDescription( key="boolean", sub_key="value", + translation_key="zone_with_number", + translation_placeholders={"zone_number": "1"}, entity_registry_enabled_default=False, is_on=lambda status: bool(status["value"]), method_on="boolean_set", @@ -176,6 +182,8 @@ RPC_SWITCHES = { "boolean_zone1": RpcSwitchDescription( key="boolean", sub_key="value", + translation_key="zone_with_number", + translation_placeholders={"zone_number": "2"}, entity_registry_enabled_default=False, is_on=lambda status: bool(status["value"]), method_on="boolean_set", @@ -187,6 +195,8 @@ RPC_SWITCHES = { "boolean_zone2": RpcSwitchDescription( key="boolean", sub_key="value", + translation_key="zone_with_number", + translation_placeholders={"zone_number": "3"}, entity_registry_enabled_default=False, is_on=lambda status: bool(status["value"]), method_on="boolean_set", @@ -198,6 +208,8 @@ RPC_SWITCHES = { "boolean_zone3": RpcSwitchDescription( key="boolean", sub_key="value", + translation_key="zone_with_number", + translation_placeholders={"zone_number": "4"}, entity_registry_enabled_default=False, is_on=lambda status: bool(status["value"]), method_on="boolean_set", @@ -209,6 +221,8 @@ RPC_SWITCHES = { "boolean_zone4": RpcSwitchDescription( key="boolean", sub_key="value", + translation_key="zone_with_number", + translation_placeholders={"zone_number": "5"}, entity_registry_enabled_default=False, is_on=lambda status: bool(status["value"]), method_on="boolean_set", @@ -220,6 +234,8 @@ RPC_SWITCHES = { "boolean_zone5": RpcSwitchDescription( key="boolean", sub_key="value", + translation_key="zone_with_number", + translation_placeholders={"zone_number": "6"}, entity_registry_enabled_default=False, is_on=lambda status: bool(status["value"]), method_on="boolean_set", @@ -241,8 +257,7 @@ RPC_SWITCHES = { "cury_left": RpcSwitchDescription( key="cury", sub_key="slots", - name="Left slot", - translation_key="cury_slot", + translation_key="left_slot", is_on=lambda status: bool(status["slots"]["left"]["on"]), method_on="cury_set", method_off="cury_set", @@ -254,8 +269,7 @@ RPC_SWITCHES = { "cury_left_boost": RpcSwitchDescription( key="cury", sub_key="slots", - name="Left slot boost", - translation_key="cury_boost", + translation_key="left_slot_boost", is_on=lambda status: status["slots"]["left"]["boost"] is not None, method_on="cury_boost", method_off="cury_stop_boost", @@ -267,8 +281,7 @@ RPC_SWITCHES = { "cury_right": RpcSwitchDescription( key="cury", sub_key="slots", - name="Right slot", - translation_key="cury_slot", + translation_key="right_slot", is_on=lambda status: bool(status["slots"]["right"]["on"]), method_on="cury_set", method_off="cury_set", @@ -280,8 +293,7 @@ RPC_SWITCHES = { "cury_right_boost": RpcSwitchDescription( key="cury", sub_key="slots", - name="Right slot boost", - translation_key="cury_boost", + translation_key="right_slot_boost", is_on=lambda status: status["slots"]["right"]["boost"] is not None, method_on="cury_boost", method_off="cury_stop_boost", @@ -399,7 +411,6 @@ class BlockSleepingMotionSwitch( """Entity that controls Motion Sensor on Block based Shelly devices.""" entity_description: BlockSwitchDescription - _attr_translation_key = "motion_switch" def __init__( self, @@ -413,6 +424,9 @@ class BlockSleepingMotionSwitch( super().__init__(coordinator, block, attribute, description, entry) self.last_state: State | None = None + if hasattr(self, "_attr_name"): + delattr(self, "_attr_name") + @property def is_on(self) -> bool | None: """If motion is active.""" @@ -488,6 +502,23 @@ class RpcSwitch(ShellyRpcAttributeEntity, SwitchEntity): entity_description: RpcSwitchDescription + def __init__( + self, + coordinator: ShellyRpcCoordinator, + key: str, + attribute: str, + description: RpcSwitchDescription, + ) -> None: + """Initialize select.""" + super().__init__(coordinator, key, attribute, description) + + if ( + hasattr(self, "_attr_name") + and description.role != ROLE_GENERIC + and description.key not in ("switch", "script") + ): + delattr(self, "_attr_name") + @property def is_on(self) -> bool: """If switch is on.""" @@ -524,7 +555,7 @@ class RpcRelaySwitch(RpcSwitch): coordinator: ShellyRpcCoordinator, key: str, attribute: str, - description: RpcEntityDescription, + description: RpcSwitchDescription, ) -> None: """Initialize the switch.""" super().__init__(coordinator, key, attribute, description) diff --git a/tests/components/shelly/snapshots/test_devices.ambr b/tests/components/shelly/snapshots/test_devices.ambr index de93c1eea774..d24a3d0cd1c0 100644 --- a/tests/components/shelly/snapshots/test_devices.ambr +++ b/tests/components/shelly/snapshots/test_devices.ambr @@ -709,7 +709,7 @@ 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': 'cury_slot', + 'translation_key': 'left_slot', 'unique_id': '123456789ABC-cury:0-cury_left', 'unit_of_measurement': None, }) @@ -757,7 +757,7 @@ 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': 'cury_boost', + 'translation_key': 'left_slot_boost', 'unique_id': '123456789ABC-cury:0-cury_left_boost', 'unit_of_measurement': None, }) @@ -805,7 +805,7 @@ 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': 'cury_slot', + 'translation_key': 'right_slot', 'unique_id': '123456789ABC-cury:0-cury_right', 'unit_of_measurement': None, }) @@ -853,7 +853,7 @@ 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': 'cury_boost', + 'translation_key': 'right_slot_boost', 'unique_id': '123456789ABC-cury:0-cury_right_boost', 'unit_of_measurement': None, }) diff --git a/tests/components/shelly/snapshots/test_switch.ambr b/tests/components/shelly/snapshots/test_switch.ambr index 8d79f6904c61..e376b7c4ad62 100644 --- a/tests/components/shelly/snapshots/test_switch.ambr +++ b/tests/components/shelly/snapshots/test_switch.ambr @@ -77,7 +77,7 @@ 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': 'cury_slot', + 'translation_key': 'left_slot', 'unique_id': '123456789ABC-cury:0-cury_left', 'unit_of_measurement': None, }) @@ -125,7 +125,7 @@ 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': 'cury_boost', + 'translation_key': 'left_slot_boost', 'unique_id': '123456789ABC-cury:0-cury_left_boost', 'unit_of_measurement': None, }) @@ -173,7 +173,7 @@ 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': 'cury_slot', + 'translation_key': 'right_slot', 'unique_id': '123456789ABC-cury:0-cury_right', 'unit_of_measurement': None, }) @@ -221,7 +221,7 @@ 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': 'cury_boost', + 'translation_key': 'right_slot_boost', 'unique_id': '123456789ABC-cury:0-cury_right_boost', 'unit_of_measurement': None, })