Trigger automation without skipping condition (#28484)

* Trigger automation without skipping condition

* [] instead of .get()

* Update __init__.py

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
SantobertandPaulus Schoutsen authored and Franck Nijhof committed 2020-01-08 10:36:11 +01:00
1 parent 84a1afc785
commit 3d7488d188
4 files changed
+33 -5

No files matched your search

+7 -2
View File
@@ -3,7 +3,11 @@
All containing methods are legacy helpers that should not be used by new
components. Instead call the service directly.
"""
from homeassistant.components.automation import DOMAIN, SERVICE_TRIGGER
from homeassistant.components.automation import (
CONF_SKIP_CONDITION,
DOMAIN,
SERVICE_TRIGGER,
)
from homeassistant.const import (
ATTR_ENTITY_ID,
ENTITY_MATCH_ALL,
@@ -37,9 +41,10 @@ async def async_toggle(hass, entity_id=ENTITY_MATCH_ALL):
@bind_hass
async def async_trigger(hass, entity_id=ENTITY_MATCH_ALL):
async def async_trigger(hass, entity_id=ENTITY_MATCH_ALL, skip_condition=True):
"""Trigger specified automation or all."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else {}
data[CONF_SKIP_CONDITION] = skip_condition
await hass.services.async_call(DOMAIN, SERVICE_TRIGGER, data)