@@ -67,7 +67,7 @@ class BlockSwitchDescription(BlockEntityDescription, SwitchEntityDescription):
6767BLOCK_SLEEPING_MOTION_SWITCH = {
6868 ("sensor" , "motionActive" ): BlockSwitchDescription (
6969 key = "sensor|motionActive" ,
70- name = "Motion detection " ,
70+ translation_key = "motion_detection " ,
7171 entity_category = EntityCategory .CONFIG ,
7272 )
7373}
@@ -99,7 +99,7 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
9999 "boolean_generic" : RpcSwitchDescription (
100100 key = "boolean" ,
101101 sub_key = "value" ,
102- removal_condition = lambda config , _status , key : not is_view_for_platform (
102+ removal_condition = lambda config , _ , key : not is_view_for_platform (
103103 config , key , SWITCH_PLATFORM
104104 ),
105105 is_on = lambda status : bool (status ["value" ]),
@@ -111,6 +111,7 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
111111 "boolean_anti_freeze" : RpcSwitchDescription (
112112 key = "boolean" ,
113113 sub_key = "value" ,
114+ translation_key = "frost_protection" ,
114115 entity_registry_enabled_default = False ,
115116 is_on = lambda status : bool (status ["value" ]),
116117 method_on = "boolean_set" ,
@@ -122,6 +123,7 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
122123 "boolean_child_lock" : RpcSwitchDescription (
123124 key = "boolean" ,
124125 sub_key = "value" ,
126+ translation_key = "child_lock" ,
125127 is_on = lambda status : bool (status ["value" ]),
126128 method_on = "boolean_set" ,
127129 method_off = "boolean_set" ,
@@ -132,6 +134,7 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
132134 "boolean_enable" : RpcSwitchDescription (
133135 key = "boolean" ,
134136 sub_key = "value" ,
137+ translation_key = "thermostat_enabled" ,
135138 entity_registry_enabled_default = False ,
136139 is_on = lambda status : bool (status ["value" ]),
137140 method_on = "boolean_set" ,
@@ -143,7 +146,7 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
143146 "boolean_start_charging" : RpcSwitchDescription (
144147 key = "boolean" ,
145148 sub_key = "value" ,
146- name = "Charging " ,
149+ translation_key = "charging " ,
147150 is_on = lambda status : bool (status ["value" ]),
148151 method_on = "boolean_set" ,
149152 method_off = "boolean_set" ,
@@ -154,6 +157,7 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
154157 "boolean_state" : RpcSwitchDescription (
155158 key = "boolean" ,
156159 sub_key = "value" ,
160+ translation_key = "valve_opened" ,
157161 entity_registry_enabled_default = False ,
158162 is_on = lambda status : bool (status ["value" ]),
159163 method_on = "boolean_set" ,
@@ -165,6 +169,8 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
165169 "boolean_zone0" : RpcSwitchDescription (
166170 key = "boolean" ,
167171 sub_key = "value" ,
172+ translation_key = "zone_with_number" ,
173+ translation_placeholders = {"zone_number" : "1" },
168174 entity_registry_enabled_default = False ,
169175 is_on = lambda status : bool (status ["value" ]),
170176 method_on = "boolean_set" ,
@@ -176,6 +182,8 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
176182 "boolean_zone1" : RpcSwitchDescription (
177183 key = "boolean" ,
178184 sub_key = "value" ,
185+ translation_key = "zone_with_number" ,
186+ translation_placeholders = {"zone_number" : "2" },
179187 entity_registry_enabled_default = False ,
180188 is_on = lambda status : bool (status ["value" ]),
181189 method_on = "boolean_set" ,
@@ -187,6 +195,8 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
187195 "boolean_zone2" : RpcSwitchDescription (
188196 key = "boolean" ,
189197 sub_key = "value" ,
198+ translation_key = "zone_with_number" ,
199+ translation_placeholders = {"zone_number" : "3" },
190200 entity_registry_enabled_default = False ,
191201 is_on = lambda status : bool (status ["value" ]),
192202 method_on = "boolean_set" ,
@@ -198,6 +208,8 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
198208 "boolean_zone3" : RpcSwitchDescription (
199209 key = "boolean" ,
200210 sub_key = "value" ,
211+ translation_key = "zone_with_number" ,
212+ translation_placeholders = {"zone_number" : "4" },
201213 entity_registry_enabled_default = False ,
202214 is_on = lambda status : bool (status ["value" ]),
203215 method_on = "boolean_set" ,
@@ -209,6 +221,8 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
209221 "boolean_zone4" : RpcSwitchDescription (
210222 key = "boolean" ,
211223 sub_key = "value" ,
224+ translation_key = "zone_with_number" ,
225+ translation_placeholders = {"zone_number" : "5" },
212226 entity_registry_enabled_default = False ,
213227 is_on = lambda status : bool (status ["value" ]),
214228 method_on = "boolean_set" ,
@@ -220,6 +234,8 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
220234 "boolean_zone5" : RpcSwitchDescription (
221235 key = "boolean" ,
222236 sub_key = "value" ,
237+ translation_key = "zone_with_number" ,
238+ translation_placeholders = {"zone_number" : "6" },
223239 entity_registry_enabled_default = False ,
224240 is_on = lambda status : bool (status ["value" ]),
225241 method_on = "boolean_set" ,
@@ -241,8 +257,7 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
241257 "cury_left" : RpcSwitchDescription (
242258 key = "cury" ,
243259 sub_key = "slots" ,
244- name = "Left slot" ,
245- translation_key = "cury_slot" ,
260+ translation_key = "left_slot" ,
246261 is_on = lambda status : bool (status ["slots" ]["left" ]["on" ]),
247262 method_on = "cury_set" ,
248263 method_off = "cury_set" ,
@@ -254,8 +269,7 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
254269 "cury_left_boost" : RpcSwitchDescription (
255270 key = "cury" ,
256271 sub_key = "slots" ,
257- name = "Left slot boost" ,
258- translation_key = "cury_boost" ,
272+ translation_key = "left_slot_boost" ,
259273 is_on = lambda status : status ["slots" ]["left" ]["boost" ] is not None ,
260274 method_on = "cury_boost" ,
261275 method_off = "cury_stop_boost" ,
@@ -267,8 +281,7 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
267281 "cury_right" : RpcSwitchDescription (
268282 key = "cury" ,
269283 sub_key = "slots" ,
270- name = "Right slot" ,
271- translation_key = "cury_slot" ,
284+ translation_key = "right_slot" ,
272285 is_on = lambda status : bool (status ["slots" ]["right" ]["on" ]),
273286 method_on = "cury_set" ,
274287 method_off = "cury_set" ,
@@ -280,8 +293,7 @@ class RpcSwitchDescription(RpcEntityDescription, SwitchEntityDescription):
280293 "cury_right_boost" : RpcSwitchDescription (
281294 key = "cury" ,
282295 sub_key = "slots" ,
283- name = "Right slot boost" ,
284- translation_key = "cury_boost" ,
296+ translation_key = "right_slot_boost" ,
285297 is_on = lambda status : status ["slots" ]["right" ]["boost" ] is not None ,
286298 method_on = "cury_boost" ,
287299 method_off = "cury_stop_boost" ,
@@ -399,7 +411,6 @@ class BlockSleepingMotionSwitch(
399411 """Entity that controls Motion Sensor on Block based Shelly devices."""
400412
401413 entity_description : BlockSwitchDescription
402- _attr_translation_key = "motion_switch"
403414
404415 def __init__ (
405416 self ,
@@ -413,6 +424,9 @@ def __init__(
413424 super ().__init__ (coordinator , block , attribute , description , entry )
414425 self .last_state : State | None = None
415426
427+ if hasattr (self , "_attr_name" ):
428+ delattr (self , "_attr_name" )
429+
416430 @property
417431 def is_on (self ) -> bool | None :
418432 """If motion is active."""
@@ -488,6 +502,23 @@ class RpcSwitch(ShellyRpcAttributeEntity, SwitchEntity):
488502
489503 entity_description : RpcSwitchDescription
490504
505+ def __init__ (
506+ self ,
507+ coordinator : ShellyRpcCoordinator ,
508+ key : str ,
509+ attribute : str ,
510+ description : RpcSwitchDescription ,
511+ ) -> None :
512+ """Initialize select."""
513+ super ().__init__ (coordinator , key , attribute , description )
514+
515+ if (
516+ hasattr (self , "_attr_name" )
517+ and description .role != ROLE_GENERIC
518+ and description .key not in ("switch" , "script" )
519+ ):
520+ delattr (self , "_attr_name" )
521+
491522 @property
492523 def is_on (self ) -> bool :
493524 """If switch is on."""
@@ -524,7 +555,7 @@ def __init__(
524555 coordinator : ShellyRpcCoordinator ,
525556 key : str ,
526557 attribute : str ,
527- description : RpcEntityDescription ,
558+ description : RpcSwitchDescription ,
528559 ) -> None :
529560 """Initialize the switch."""
530561 super ().__init__ (coordinator , key , attribute , description )
0 commit comments