|
43 | 43 | from .utils import ( |
44 | 44 | async_remove_orphaned_entities, |
45 | 45 | get_device_entry_gen, |
| 46 | + get_rpc_channel_name, |
46 | 47 | get_virtual_component_ids, |
47 | 48 | is_block_exclude_from_relay, |
48 | 49 | is_rpc_exclude_from_relay, |
@@ -470,6 +471,7 @@ def __init__( |
470 | 471 | """Initialize relay switch.""" |
471 | 472 | super().__init__(coordinator, block, attribute, description) |
472 | 473 | self.control_result: dict[str, Any] | None = None |
| 474 | + self._attr_name = None # Main device entity |
473 | 475 | self._attr_unique_id: str = f"{coordinator.mac}-{block.description}" |
474 | 476 |
|
475 | 477 | @property |
@@ -512,11 +514,9 @@ def __init__( |
512 | 514 | """Initialize select.""" |
513 | 515 | super().__init__(coordinator, key, attribute, description) |
514 | 516 |
|
515 | | - if ( |
516 | | - hasattr(self, "_attr_name") |
517 | | - and description.role != ROLE_GENERIC |
518 | | - and description.key not in ("switch", "script") |
519 | | - ): |
| 517 | + if description.role == ROLE_GENERIC or description.key in ("switch", "script"): |
| 518 | + self._attr_name = get_rpc_channel_name(coordinator.device, key) |
| 519 | + elif hasattr(self, "_attr_name"): |
520 | 520 | delattr(self, "_attr_name") |
521 | 521 |
|
522 | 522 | @property |
|
0 commit comments