Catch bad devices when Google Sync (#39377)

This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2020-08-29 13:09:50 +02:00
1 parent b882304ec2
commit 8302a7879e
2 files changed
+72 -4

No files matched your search

@@ -83,15 +83,24 @@ async def async_devices_sync(hass, data, payload):
)
agent_user_id = data.config.get_agent_user_id(data.context)
devices = await asyncio.gather(
entities = async_get_entities(hass, data.config)
results = await asyncio.gather(
*(
entity.sync_serialize(agent_user_id)
for entity in async_get_entities(hass, data.config)
for entity in entities
if entity.should_expose()
)
),
return_exceptions=True,
)
devices = []
for entity, result in zip(entities, results):
if isinstance(result, Exception):
_LOGGER.error("Error serializing %s", entity.entity_id, exc_info=result)
else:
devices.append(result)
response = {"agentUserId": agent_user_id, "devices": devices}
await data.config.async_connect_agent_user(agent_user_id)