mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
deCONZ - Fix device automations (#30577)
This commit is contained in:
parent
0d48d682dc
commit
84a1afc785
@ -297,7 +297,7 @@ TRIGGER_SCHEMA = TRIGGER_BASE_SCHEMA.extend(
|
||||
|
||||
def _get_deconz_event_from_device_id(hass, device_id):
|
||||
"""Resolve deconz event from device id."""
|
||||
for gateway in hass.data.get(DOMAIN):
|
||||
for gateway in hass.data.get(DOMAIN, {}).values():
|
||||
|
||||
for deconz_event in gateway.events:
|
||||
|
||||
|
@ -91,3 +91,26 @@ async def test_get_triggers(hass):
|
||||
]
|
||||
|
||||
assert_lists_same(triggers, expected_triggers)
|
||||
|
||||
|
||||
async def test_helper_successful(hass):
|
||||
"""Verify trigger helper."""
|
||||
data = deepcopy(DECONZ_WEB_REQUEST)
|
||||
data["sensors"] = deepcopy(SENSORS)
|
||||
gateway = await setup_deconz_integration(hass, get_state_response=data)
|
||||
device_id = gateway.events[0].device_id
|
||||
deconz_event = device_trigger._get_deconz_event_from_device_id(hass, device_id)
|
||||
assert deconz_event == gateway.events[0]
|
||||
|
||||
|
||||
async def test_helper_no_match(hass):
|
||||
"""Verify trigger helper returns None when no event could be matched."""
|
||||
await setup_deconz_integration(hass)
|
||||
deconz_event = device_trigger._get_deconz_event_from_device_id(hass, "mock-id")
|
||||
assert deconz_event is None
|
||||
|
||||
|
||||
async def test_helper_no_gateway_exist(hass):
|
||||
"""Verify trigger helper returns None when no gateway exist."""
|
||||
deconz_event = device_trigger._get_deconz_event_from_device_id(hass, "mock-id")
|
||||
assert deconz_event is None
|
||||
|
Loading…
x
Reference in New Issue
Block a user