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:
1 parent
84a1afc785
commit
3d7488d188
4 files changed
+33
-5
No files matched your search
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -225,6 +225,22 @@ async def test_trigger_service_ignoring_condition(hass, calls):
|
||||
)
|
||||
assert len(calls) == 1
|
||||
|
||||
await hass.services.async_call(
|
||||
"automation",
|
||||
"trigger",
|
||||
{"entity_id": "automation.test", "skip_condition": True},
|
||||
blocking=True,
|
||||
)
|
||||
assert len(calls) == 2
|
||||
|
||||
await hass.services.async_call(
|
||||
"automation",
|
||||
"trigger",
|
||||
{"entity_id": "automation.test", "skip_condition": False},
|
||||
blocking=True,
|
||||
)
|
||||
assert len(calls) == 2
|
||||
|
||||
|
||||
async def test_two_conditions_with_and(hass, calls):
|
||||
"""Test two and conditions."""
|
||||
|
||||
Reference in new issue
Block a user