Teach homekit about entity registry ids in device triggers (#95009)
parent
235f50a341
commit
f10256169b
|
@ -47,10 +47,12 @@ class DeviceTriggerAccessory(HomeAccessory):
|
||||||
type_: str = trigger["type"]
|
type_: str = trigger["type"]
|
||||||
subtype: str | None = trigger.get("subtype")
|
subtype: str | None = trigger.get("subtype")
|
||||||
unique_id = f'{type_}-{subtype or ""}'
|
unique_id = f'{type_}-{subtype or ""}'
|
||||||
if (entity_id := trigger.get("entity_id")) and (
|
entity_id: str | None = None
|
||||||
entry := ent_reg.async_get(entity_id)
|
if (entity_id_or_uuid := trigger.get("entity_id")) and (
|
||||||
|
entry := ent_reg.async_get(entity_id_or_uuid)
|
||||||
):
|
):
|
||||||
unique_id += f"-entity_unique_id:{get_system_unique_id(entry)}"
|
unique_id += f"-entity_unique_id:{get_system_unique_id(entry)}"
|
||||||
|
entity_id = entry.entity_id
|
||||||
trigger_name_parts = []
|
trigger_name_parts = []
|
||||||
if entity_id and (state := self.hass.states.get(entity_id)):
|
if entity_id and (state := self.hass.states.get(entity_id)):
|
||||||
trigger_name_parts.append(state.name)
|
trigger_name_parts.append(state.name)
|
||||||
|
|
Loading…
Reference in New Issue