|
35 | 35 | get_block_custom_name, |
36 | 36 | get_block_number_of_channels, |
37 | 37 | get_device_entry_gen, |
38 | | - get_rpc_channel_name, |
39 | 38 | get_rpc_custom_name, |
40 | 39 | get_rpc_key, |
41 | 40 | get_rpc_key_id, |
@@ -160,8 +159,7 @@ def _async_setup_rpc_entry( |
160 | 159 | ) |
161 | 160 | script_events = config_entry.runtime_data.rpc_script_events |
162 | 161 | 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: |
165 | 163 | continue |
166 | 164 |
|
167 | 165 | if script_events and (event_types := script_events[get_rpc_key_id(script)]): |
@@ -212,9 +210,6 @@ def __init__( |
212 | 210 | and get_block_number_of_channels(coordinator.device, block) > 1 |
213 | 211 | else "" |
214 | 212 | } |
215 | | - |
216 | | - if hasattr(self, "_attr_name"): |
217 | | - delattr(self, "_attr_name") |
218 | 213 | else: |
219 | 214 | self._attr_name = get_block_channel_name(coordinator.device, block) |
220 | 215 |
|
@@ -253,17 +248,17 @@ def __init__( |
253 | 248 |
|
254 | 249 | if description.key == "input": |
255 | 250 | _, 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: |
257 | 254 | self._attr_translation_placeholders = { |
258 | 255 | "input_number": component_id |
259 | 256 | if get_rpc_number_of_channels(coordinator.device, component) > 1 |
260 | 257 | else "" |
261 | 258 | } |
262 | | - else: |
263 | | - self._attr_name = get_rpc_channel_name(coordinator.device, key) |
264 | 259 | self.event_id = int(component_id) |
265 | 260 | 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) |
267 | 262 | self.event_id = get_rpc_key_id(key) |
268 | 263 |
|
269 | 264 | async def async_added_to_hass(self) -> None: |
|
0 commit comments