mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Google: Recover from an entity raising while serializing query (#39381)
Co-authored-by: Joakim Plate <elupus@ecce.se>
This commit is contained in:
parent
854e33025b
commit
ab7b42c022
@ -137,7 +137,11 @@ async def async_devices_query(hass, data, payload):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
entity = GoogleEntity(hass, data.config, state)
|
entity = GoogleEntity(hass, data.config, state)
|
||||||
devices[devid] = entity.query_serialize()
|
try:
|
||||||
|
devices[devid] = entity.query_serialize()
|
||||||
|
except Exception: # pylint: disable=broad-except
|
||||||
|
_LOGGER.exception("Unexpected error serializing query for %s", state)
|
||||||
|
devices[devid] = {"online": False}
|
||||||
|
|
||||||
return {"devices": devices}
|
return {"devices": devices}
|
||||||
|
|
||||||
|
@ -1188,3 +1188,59 @@ async def test_sync_message_recovery(hass, caplog):
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert "Error serializing light.bad_light" in caplog.text
|
assert "Error serializing light.bad_light" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
|
async def test_query_recover(hass, caplog):
|
||||||
|
"""Test that we recover if an entity raises during query."""
|
||||||
|
|
||||||
|
hass.states.async_set(
|
||||||
|
"light.good",
|
||||||
|
"on",
|
||||||
|
{
|
||||||
|
"supported_features": hass.components.light.SUPPORT_BRIGHTNESS,
|
||||||
|
"brightness": 50,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
hass.states.async_set(
|
||||||
|
"light.bad",
|
||||||
|
"on",
|
||||||
|
{
|
||||||
|
"supported_features": hass.components.light.SUPPORT_BRIGHTNESS,
|
||||||
|
"brightness": "shoe",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
result = await sh.async_handle_message(
|
||||||
|
hass,
|
||||||
|
BASIC_CONFIG,
|
||||||
|
"test-agent",
|
||||||
|
{
|
||||||
|
"requestId": REQ_ID,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"intent": "action.devices.QUERY",
|
||||||
|
"payload": {
|
||||||
|
"devices": [
|
||||||
|
{"id": "light.good"},
|
||||||
|
{"id": "light.bad"},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
const.SOURCE_CLOUD,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert (
|
||||||
|
f"Unexpected error serializing query for {hass.states.get('light.bad')}"
|
||||||
|
in caplog.text
|
||||||
|
)
|
||||||
|
assert result == {
|
||||||
|
"requestId": REQ_ID,
|
||||||
|
"payload": {
|
||||||
|
"devices": {
|
||||||
|
"light.bad": {"online": False},
|
||||||
|
"light.good": {"on": True, "online": True, "brightness": 19},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user