mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Handle situations where action is part of a deCONZ event but has the value None (#53373)
* Handle situations where action is part of an event but has the value None * Cover more possible permutations of what a bad action string is
This commit is contained in:
parent
0d5e480397
commit
d0bef97453
@ -163,11 +163,13 @@ class DeconzAlarmEvent(DeconzEvent):
|
||||
if (
|
||||
self.gateway.ignore_state_updates
|
||||
or "action" not in self._device.changed_keys
|
||||
or self._device.action == ""
|
||||
):
|
||||
return
|
||||
|
||||
state, code, _area = self._device.action.split(",")
|
||||
try:
|
||||
state, code, _area = self._device.action.split(",")
|
||||
except (AttributeError, ValueError):
|
||||
return
|
||||
|
||||
if state not in DECONZ_TO_ALARM_STATE:
|
||||
return
|
||||
|
@ -267,6 +267,50 @@ async def test_deconz_alarm_events(hass, aioclient_mock, mock_deconz_websocket):
|
||||
|
||||
# Unsupported events
|
||||
|
||||
# Bad action string; string is None
|
||||
|
||||
event_changed_sensor = {
|
||||
"t": "event",
|
||||
"e": "changed",
|
||||
"r": "sensors",
|
||||
"id": "1",
|
||||
"state": {"action": None},
|
||||
}
|
||||
await mock_deconz_websocket(data=event_changed_sensor)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(captured_events) == 1
|
||||
|
||||
# Bad action string; empty string
|
||||
|
||||
event_changed_sensor = {
|
||||
"t": "event",
|
||||
"e": "changed",
|
||||
"r": "sensors",
|
||||
"id": "1",
|
||||
"state": {"action": ""},
|
||||
}
|
||||
await mock_deconz_websocket(data=event_changed_sensor)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(captured_events) == 1
|
||||
|
||||
# Bad action string; too few ","
|
||||
|
||||
event_changed_sensor = {
|
||||
"t": "event",
|
||||
"e": "changed",
|
||||
"r": "sensors",
|
||||
"id": "1",
|
||||
"state": {"action": "armed_away,1234"},
|
||||
}
|
||||
await mock_deconz_websocket(data=event_changed_sensor)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(captured_events) == 1
|
||||
|
||||
# Bad action string; unsupported command
|
||||
|
||||
event_changed_sensor = {
|
||||
"t": "event",
|
||||
"e": "changed",
|
||||
@ -279,6 +323,8 @@ async def test_deconz_alarm_events(hass, aioclient_mock, mock_deconz_websocket):
|
||||
|
||||
assert len(captured_events) == 1
|
||||
|
||||
# Only care for changes to action
|
||||
|
||||
event_changed_sensor = {
|
||||
"t": "event",
|
||||
"e": "changed",
|
||||
|
Loading…
x
Reference in New Issue
Block a user