Skip to content

Commit 5556fb9

Browse files
davidrapanthecode
andauthored
Remove Shelly event name removal (home-assistant#157067)
Signed-off-by: David Rapan <[email protected]> Co-authored-by: Shay Levy <[email protected]>
1 parent 16669e3 commit 5556fb9

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

homeassistant/components/shelly/event.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
get_block_custom_name,
3636
get_block_number_of_channels,
3737
get_device_entry_gen,
38-
get_rpc_channel_name,
3938
get_rpc_custom_name,
4039
get_rpc_key,
4140
get_rpc_key_id,
@@ -160,8 +159,7 @@ def _async_setup_rpc_entry(
160159
)
161160
script_events = config_entry.runtime_data.rpc_script_events
162161
for script in script_instances:
163-
script_name = get_rpc_channel_name(coordinator.device, script)
164-
if script_name == BLE_SCRIPT_NAME:
162+
if get_rpc_custom_name(coordinator.device, script) == BLE_SCRIPT_NAME:
165163
continue
166164

167165
if script_events and (event_types := script_events[get_rpc_key_id(script)]):
@@ -212,9 +210,6 @@ def __init__(
212210
and get_block_number_of_channels(coordinator.device, block) > 1
213211
else ""
214212
}
215-
216-
if hasattr(self, "_attr_name"):
217-
delattr(self, "_attr_name")
218213
else:
219214
self._attr_name = get_block_channel_name(coordinator.device, block)
220215

@@ -253,17 +248,17 @@ def __init__(
253248

254249
if description.key == "input":
255250
_, component, component_id = get_rpc_key(key)
256-
if not get_rpc_custom_name(coordinator.device, key):
251+
if custom_name := get_rpc_custom_name(coordinator.device, key):
252+
self._attr_name = custom_name
253+
else:
257254
self._attr_translation_placeholders = {
258255
"input_number": component_id
259256
if get_rpc_number_of_channels(coordinator.device, component) > 1
260257
else ""
261258
}
262-
else:
263-
self._attr_name = get_rpc_channel_name(coordinator.device, key)
264259
self.event_id = int(component_id)
265260
elif description.key == "script":
266-
self._attr_name = get_rpc_channel_name(coordinator.device, key)
261+
self._attr_name = get_rpc_custom_name(coordinator.device, key)
267262
self.event_id = get_rpc_key_id(key)
268263

269264
async def async_added_to_hass(self) -> None:

0 commit comments

Comments
 (0)