Fix instability with HomeKit trigger accessories (#80703)

fixes https://github.com/home-assistant/core/issues/78774
fixes https://github.com/home-assistant/core/issues/81685
This commit is contained in:
J. Nick Koston 2022-11-15 11:41:55 -06:00 committed by GitHub
parent 1331a3771a
commit ade4b62aec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 450 additions and 32 deletions

View file

@ -67,13 +67,16 @@ def _get_accessory_diagnostics(
hass: HomeAssistant, accessory: HomeAccessory
) -> dict[str, Any]:
"""Return diagnostics for an accessory."""
return {
entity_state = None
if accessory.entity_id:
entity_state = hass.states.get(accessory.entity_id)
data = {
"aid": accessory.aid,
"config": accessory.config,
"category": accessory.category,
"name": accessory.display_name,
"entity_id": accessory.entity_id,
"entity_state": async_redact_data(
hass.states.get(accessory.entity_id), TO_REDACT
),
}
if entity_state:
data["entity_state"] = async_redact_data(entity_state, TO_REDACT)
return data