Add device triggers to cover (#28063)

* Add device triggers to cover

* Use numeric_state trigger instead of template trigger

* Tweak translations
This commit is contained in:
Erik Montnemery authored and GitHub committed 2019-10-30 20:49:01 +01:00
1 parent bda3aadbcf
commit 8ae43d2de3
4 files changed
+935 -14

No files matched your search

@@ -4,7 +4,7 @@ import logging
import voluptuous as vol
from homeassistant import exceptions
from homeassistant.core import callback
from homeassistant.core import CALLBACK_TYPE, callback
from homeassistant.const import (
CONF_VALUE_TEMPLATE,
CONF_PLATFORM,
@@ -17,7 +17,8 @@ from homeassistant.helpers.event import async_track_state_change, async_track_sa
from homeassistant.helpers import condition, config_validation as cv, template
# mypy: allow-untyped-defs, no-check-untyped-defs
# mypy: allow-incomplete-defs, allow-untyped-calls, allow-untyped-defs
# mypy: no-check-untyped-defs
TRIGGER_SCHEMA = vol.All(
vol.Schema(
@@ -42,7 +43,7 @@ _LOGGER = logging.getLogger(__name__)
async def async_attach_trigger(
hass, config, action, automation_info, *, platform_type="numeric_state"
):
) -> CALLBACK_TYPE:
"""Listen for state changes based on configuration."""
entity_id = config.get(CONF_ENTITY_ID)
below = config.get(CONF_BELOW)
@@ -52,7 +53,7 @@ async def async_attach_trigger(
value_template = config.get(CONF_VALUE_TEMPLATE)
unsub_track_same = {}
entities_triggered = set()
period = {}
period: dict = {}
if value_template is not None:
value_template.hass = hass