Fix unique_id for service entities in Alexa Devices (#181526)

This commit is contained in:
Simone Chemelli
2026-09-11 18:26:48 +00:00
committed by Franck Nijhof
parent 2016397fc9
commit 726741e4ca
2 changed files with 20 additions and 14 deletions
@@ -66,24 +66,26 @@ async def async_setup_entry(
new_devices = current_devices - known_devices
if new_devices:
known_devices.update(new_devices)
select_entities = [
AmazonSelectEntity(coordinator, serial_num, select_desc)
for select_desc in SELECTS
for serial_num in new_devices
if select_desc.is_available_fn(coordinator.data[serial_num])
]
select_service_entites = [
AmazonSelectServiceEntity(coordinator, select_desc)
for select_desc in SERVICE_SELECTS
for serial_num in new_devices
if select_desc.is_available_fn(coordinator.data[serial_num])
]
async_add_entities(select_entities)
async_add_entities(select_service_entites)
async_add_entities(
[
AmazonSelectEntity(coordinator, serial_num, select_desc)
for select_desc in SELECTS
for serial_num in new_devices
if select_desc.is_available_fn(coordinator.data[serial_num])
]
)
_check_device()
entry.async_on_unload(coordinator.async_add_listener(_check_device))
# Service entities
async_add_entities(
[
AmazonSelectServiceEntity(coordinator, select_desc)
for select_desc in SERVICE_SELECTS
]
)
class AmazonSelectEntity(AmazonEntity, SelectEntity):
"""Representation of a select entity."""
@@ -108,6 +108,7 @@ async def test_offline_device(
async def test_service_select_option(
hass: HomeAssistant,
caplog: pytest.LogCaptureFixture,
mock_amazon_devices_client: AsyncMock,
mock_config_entry: MockConfigEntry,
) -> None:
@@ -119,6 +120,9 @@ async def test_service_select_option(
await setup_integration(hass, mock_config_entry)
# A single account-wide entity is created regardless of the number of devices
assert "does not generate unique IDs" not in caplog.text
assert (state := hass.states.get(ENTITY_ID_2))
assert state.state == TEST_DEVICE_1.account_name