Add device trigger support to sensor entities (#27133)

* Add device trigger support to sensor entities

* Fix typing

* Fix tests, add test helper for comparing lists
This commit is contained in:
Erik Montnemery
2019-10-03 06:14:35 +02:00
committed by GitHub
parent e005f6f23a
commit 3e99743244
10 changed files with 689 additions and 11 deletions

View File

@@ -195,8 +195,8 @@ async def async_attach_trigger(hass, config, action, automation_info):
state_automation.CONF_FROM: from_state,
state_automation.CONF_TO: to_state,
}
if "for" in config:
state_config["for"] = config["for"]
if CONF_FOR in config:
state_config[CONF_FOR] = config[CONF_FOR]
return await state_automation.async_attach_trigger(
hass, state_config, action, automation_info, platform_type="device"
@@ -215,7 +215,7 @@ async def async_get_triggers(hass, device_id):
]
for entry in entries:
device_class = None
device_class = DEVICE_CLASS_NONE
state = hass.states.get(entry.entity_id)
if state:
device_class = state.attributes.get(ATTR_DEVICE_CLASS)