2121from homeassistant .exceptions import HomeAssistantError
2222from homeassistant .helpers import entity_registry as er
2323from homeassistant .helpers .entity_platform import AddConfigEntryEntitiesCallback
24+ from homeassistant .helpers .entity_registry import RegistryEntry
2425from homeassistant .helpers .update_coordinator import CoordinatorEntity
2526
2627from .const import (
@@ -76,45 +77,41 @@ class RpcButtonDescription(RpcEntityDescription, ButtonEntityDescription):
7677BUTTONS : Final [list [ShellyButtonDescription [Any ]]] = [
7778 ShellyButtonDescription [ShellyBlockCoordinator | ShellyRpcCoordinator ](
7879 key = "reboot" ,
79- name = "Restart" ,
8080 device_class = ButtonDeviceClass .RESTART ,
8181 entity_category = EntityCategory .CONFIG ,
8282 press_action = "trigger_reboot" ,
8383 ),
8484 ShellyButtonDescription [ShellyBlockCoordinator ](
8585 key = "self_test" ,
86- name = "Self test" ,
8786 translation_key = "self_test" ,
8887 entity_category = EntityCategory .DIAGNOSTIC ,
8988 press_action = "trigger_shelly_gas_self_test" ,
9089 supported = lambda coordinator : coordinator .model in SHELLY_GAS_MODELS ,
9190 ),
9291 ShellyButtonDescription [ShellyBlockCoordinator ](
9392 key = "mute" ,
94- name = "Mute" ,
95- translation_key = "mute" ,
93+ translation_key = "mute_alarm" ,
9694 entity_category = EntityCategory .CONFIG ,
9795 press_action = "trigger_shelly_gas_mute" ,
9896 supported = lambda coordinator : coordinator .model in SHELLY_GAS_MODELS ,
9997 ),
10098 ShellyButtonDescription [ShellyBlockCoordinator ](
10199 key = "unmute" ,
102- name = "Unmute" ,
103- translation_key = "unmute" ,
100+ translation_key = "unmute_alarm" ,
104101 entity_category = EntityCategory .CONFIG ,
105102 press_action = "trigger_shelly_gas_unmute" ,
106103 supported = lambda coordinator : coordinator .model in SHELLY_GAS_MODELS ,
107104 ),
108105 ShellyButtonDescription [ShellyRpcCoordinator ](
109106 key = "turn_on_screen" ,
110- name = "Turn on the screen " ,
107+ translation_key = "turn_on_the_screen " ,
111108 press_action = "wall_display_set_screen" ,
112109 params = {"value" : True },
113110 supported = lambda coordinator : coordinator .model in SHELLY_WALL_DISPLAY_MODELS ,
114111 ),
115112 ShellyButtonDescription [ShellyRpcCoordinator ](
116113 key = "turn_off_screen" ,
117- name = "Turn off the screen " ,
114+ translation_key = "turn_off_the_screen " ,
118115 press_action = "wall_display_set_screen" ,
119116 params = {"value" : False },
120117 supported = lambda coordinator : coordinator .model in SHELLY_WALL_DISPLAY_MODELS ,
@@ -347,7 +344,7 @@ def __init__(
347344 coordinator : ShellyRpcCoordinator ,
348345 key : str ,
349346 attribute : str ,
350- description : RpcEntityDescription ,
347+ description : RpcButtonDescription ,
351348 ) -> None :
352349 """Initialize button."""
353350 super ().__init__ (coordinator , key , attribute , description )
@@ -361,6 +358,9 @@ def __init__(
361358 config , ble_addr , coordinator .mac , fw_ver
362359 )
363360
361+ if hasattr (self , "_attr_name" ) and description .role != ROLE_GENERIC :
362+ delattr (self , "_attr_name" )
363+
364364 @rpc_call
365365 async def async_press (self ) -> None :
366366 """Triggers the Shelly button press service."""
@@ -373,6 +373,19 @@ class RpcVirtualButton(ShellyRpcAttributeEntity, ButtonEntity):
373373 entity_description : RpcButtonDescription
374374 _id : int
375375
376+ def __init__ (
377+ self ,
378+ coordinator : ShellyRpcCoordinator ,
379+ key : str ,
380+ attribute : str ,
381+ description : RpcButtonDescription ,
382+ ) -> None :
383+ """Initialize select."""
384+ super ().__init__ (coordinator , key , attribute , description )
385+
386+ if hasattr (self , "_attr_name" ) and description .role != ROLE_GENERIC :
387+ delattr (self , "_attr_name" )
388+
376389 @rpc_call
377390 async def async_press (self ) -> None :
378391 """Triggers the Shelly button press service."""
@@ -387,6 +400,20 @@ class RpcSleepingSmokeMuteButton(ShellySleepingRpcAttributeEntity, ButtonEntity)
387400
388401 entity_description : RpcButtonDescription
389402
403+ def __init__ (
404+ self ,
405+ coordinator : ShellyRpcCoordinator ,
406+ key : str ,
407+ attribute : str ,
408+ description : RpcButtonDescription ,
409+ entry : RegistryEntry | None = None ,
410+ ) -> None :
411+ """Initialize the sleeping sensor."""
412+ super ().__init__ (coordinator , key , attribute , description , entry )
413+
414+ if hasattr (self , "_attr_name" ):
415+ delattr (self , "_attr_name" )
416+
390417 @rpc_call
391418 async def async_press (self ) -> None :
392419 """Triggers the Shelly button press service."""
@@ -414,19 +441,20 @@ def available(self) -> bool:
414441 ),
415442 "button_open" : RpcButtonDescription (
416443 key = "button" ,
444+ translation_key = "open" ,
417445 entity_registry_enabled_default = False ,
418446 role = "open" ,
419447 models = {MODEL_FRANKEVER_WATER_VALVE },
420448 ),
421449 "button_close" : RpcButtonDescription (
422450 key = "button" ,
451+ translation_key = "close" ,
423452 entity_registry_enabled_default = False ,
424453 role = "close" ,
425454 models = {MODEL_FRANKEVER_WATER_VALVE },
426455 ),
427456 "calibrate" : RpcButtonDescription (
428457 key = "blutrv" ,
429- name = "Calibrate" ,
430458 translation_key = "calibrate" ,
431459 entity_category = EntityCategory .CONFIG ,
432460 entity_class = ShellyBluTrvButton ,
@@ -435,7 +463,6 @@ def available(self) -> bool:
435463 "smoke_mute" : RpcButtonDescription (
436464 key = "smoke" ,
437465 sub_key = "mute" ,
438- name = "Mute alarm" ,
439- translation_key = "mute" ,
466+ translation_key = "mute_alarm" ,
440467 ),
441468}
0 commit comments