Dont create coroutine until acting on it (#27907)
parent
37b23e9205
commit
6303117354
|
@ -49,23 +49,23 @@ def async_enable_report_state(hass: HomeAssistant, google_config: AbstractConfig
|
|||
{"devices": {"states": {changed_entity: entity_data}}}
|
||||
)
|
||||
|
||||
async_call_later(
|
||||
hass, INITIAL_REPORT_DELAY, _async_report_all_states(hass, google_config)
|
||||
)
|
||||
async def inital_report(_now):
|
||||
"""Report initially all states."""
|
||||
entities = {}
|
||||
|
||||
for entity in async_get_entities(hass, google_config):
|
||||
if not entity.should_expose():
|
||||
continue
|
||||
|
||||
try:
|
||||
entities[entity.entity_id] = entity.query_serialize()
|
||||
except SmartHomeError:
|
||||
continue
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
|
||||
async def _async_report_all_states(hass: HomeAssistant, google_config: AbstractConfig):
|
||||
"""Report all states."""
|
||||
entities = {}
|
||||
|
||||
for entity in async_get_entities(hass, google_config):
|
||||
if not entity.should_expose():
|
||||
continue
|
||||
|
||||
entities[entity.entity_id] = entity.query_serialize()
|
||||
|
||||
await google_config.async_report_state({"devices": {"states": entities}})
|
||||
|
|
Loading…
Reference in New Issue