mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Dont create coroutine until acting on it (#27907)
This commit is contained in:
parent
37b23e9205
commit
6303117354
@ -49,23 +49,23 @@ def async_enable_report_state(hass: HomeAssistant, google_config: AbstractConfig
|
|||||||
{"devices": {"states": {changed_entity: entity_data}}}
|
{"devices": {"states": {changed_entity: entity_data}}}
|
||||||
)
|
)
|
||||||
|
|
||||||
async_call_later(
|
async def inital_report(_now):
|
||||||
hass, INITIAL_REPORT_DELAY, _async_report_all_states(hass, google_config)
|
"""Report initially all states."""
|
||||||
)
|
|
||||||
|
|
||||||
return hass.helpers.event.async_track_state_change(
|
|
||||||
MATCH_ALL, async_entity_state_listener
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def _async_report_all_states(hass: HomeAssistant, google_config: AbstractConfig):
|
|
||||||
"""Report all states."""
|
|
||||||
entities = {}
|
entities = {}
|
||||||
|
|
||||||
for entity in async_get_entities(hass, google_config):
|
for entity in async_get_entities(hass, google_config):
|
||||||
if not entity.should_expose():
|
if not entity.should_expose():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
entities[entity.entity_id] = entity.query_serialize()
|
entities[entity.entity_id] = entity.query_serialize()
|
||||||
|
except SmartHomeError:
|
||||||
|
continue
|
||||||
|
|
||||||
await google_config.async_report_state({"devices": {"states": entities}})
|
await google_config.async_report_state({"devices": {"states": entities}})
|
||||||
|
|
||||||
|
async_call_later(hass, INITIAL_REPORT_DELAY, inital_report)
|
||||||
|
|
||||||
|
return hass.helpers.event.async_track_state_change(
|
||||||
|
MATCH_ALL, async_entity_state_listener
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user