Improve lists for MQTT integration (#113184)
* Improve lists for MQTT integration * Extra diagnostics tests * Revert changes where the original version was probably faster * Revert change to gather and await in series
This commit is contained in:
parent
b1346f3ccd
commit
488dae43d4
11 changed files with 144 additions and 116 deletions
|
@ -239,11 +239,14 @@ def info_for_config_entry(hass: HomeAssistant) -> dict[str, list[Any]]:
|
|||
mqtt_data = get_mqtt_data(hass)
|
||||
mqtt_info: dict[str, list[Any]] = {"entities": [], "triggers": []}
|
||||
|
||||
for entity_id in mqtt_data.debug_info_entities:
|
||||
mqtt_info["entities"].append(_info_for_entity(hass, entity_id))
|
||||
mqtt_info["entities"].extend(
|
||||
_info_for_entity(hass, entity_id) for entity_id in mqtt_data.debug_info_entities
|
||||
)
|
||||
|
||||
for trigger_key in mqtt_data.debug_info_triggers:
|
||||
mqtt_info["triggers"].append(_info_for_trigger(hass, trigger_key))
|
||||
mqtt_info["triggers"].extend(
|
||||
_info_for_trigger(hass, trigger_key)
|
||||
for trigger_key in mqtt_data.debug_info_triggers
|
||||
)
|
||||
|
||||
return mqtt_info
|
||||
|
||||
|
@ -259,16 +262,16 @@ def info_for_device(hass: HomeAssistant, device_id: str) -> dict[str, list[Any]]
|
|||
entries = er.async_entries_for_device(
|
||||
entity_registry, device_id, include_disabled_entities=True
|
||||
)
|
||||
for entry in entries:
|
||||
if entry.entity_id not in mqtt_data.debug_info_entities:
|
||||
continue
|
||||
mqtt_info["entities"].extend(
|
||||
_info_for_entity(hass, entry.entity_id)
|
||||
for entry in entries
|
||||
if entry.entity_id in mqtt_data.debug_info_entities
|
||||
)
|
||||
|
||||
mqtt_info["entities"].append(_info_for_entity(hass, entry.entity_id))
|
||||
|
||||
for trigger_key, trigger in mqtt_data.debug_info_triggers.items():
|
||||
if trigger["device_id"] != device_id:
|
||||
continue
|
||||
|
||||
mqtt_info["triggers"].append(_info_for_trigger(hass, trigger_key))
|
||||
mqtt_info["triggers"].extend(
|
||||
_info_for_trigger(hass, trigger_key)
|
||||
for trigger_key, trigger in mqtt_data.debug_info_triggers.items()
|
||||
if trigger["device_id"] == device_id
|
||||
)
|
||||
|
||||
return mqtt_info
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue