Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/automation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ async def _async_process_trigger(hass, config, trigger_configs, name, action):
platform = importlib.import_module(".{}".format(conf[CONF_PLATFORM]), __name__)

try:
remove = await platform.async_trigger(hass, conf, action, info)
remove = await platform.async_attach_trigger(hass, conf, action, info)
except InvalidDeviceAutomationConfig:
remove = False

Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/automation/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
)


async def async_trigger(hass, config, action, automation_info):
async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for trigger."""
integration = await async_get_integration(hass, config[CONF_DOMAIN])
platform = integration.get_platform("device_automation")
return await platform.async_trigger(hass, config, action, automation_info)
platform = integration.get_platform("device_trigger")
return await platform.async_attach_trigger(hass, config, action, automation_info)
6 changes: 4 additions & 2 deletions homeassistant/components/automation/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
)


async def async_trigger(hass, config, action, automation_info):
async def async_attach_trigger(
hass, config, action, automation_info, *, platform_type="event"
):
"""Listen for events based on configuration."""
event_type = config.get(CONF_EVENT_TYPE)
event_data_schema = (
Expand All @@ -47,7 +49,7 @@ def handle_event(event):

hass.async_run_job(
action(
{"trigger": {"platform": "event", "event": event}},
{"trigger": {"platform": platform_type, "event": event}},
context=event.context,
)
)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/automation/geo_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def source_match(state, source):
return state and state.attributes.get("source") == source


async def async_trigger(hass, config, action, automation_info):
async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for state changes based on configuration."""
source = config.get(CONF_SOURCE).lower()
zone_entity_id = config.get(CONF_ZONE)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/automation/homeassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)


async def async_trigger(hass, config, action, automation_info):
async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for events based on configuration."""
event = config.get(CONF_EVENT)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/automation/litejet.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
)


async def async_trigger(hass, config, action, automation_info):
async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for events based on configuration."""
number = config.get(CONF_NUMBER)
held_more_than = config.get(CONF_HELD_MORE_THAN)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/automation/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)


async def async_trigger(hass, config, action, automation_info):
async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for state changes based on configuration."""
topic = config[CONF_TOPIC]
payload = config.get(CONF_PAYLOAD)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/automation/numeric_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
_LOGGER = logging.getLogger(__name__)


async def async_trigger(hass, config, action, automation_info):
async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for state changes based on configuration."""
entity_id = config.get(CONF_ENTITY_ID)
below = config.get(CONF_BELOW)
Expand Down
6 changes: 4 additions & 2 deletions homeassistant/components/automation/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
)


async def async_trigger(hass, config, action, automation_info):
async def async_attach_trigger(
hass, config, action, automation_info, *, platform_type="state"
):
"""Listen for state changes based on configuration."""
entity_id = config.get(CONF_ENTITY_ID)
from_state = config.get(CONF_FROM, MATCH_ALL)
Expand All @@ -59,7 +61,7 @@ def call_action():
action(
{
"trigger": {
"platform": "state",
"platform": platform_type,
"entity_id": entity,
"from_state": from_s,
"to_state": to_s,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/automation/sun.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)


async def async_trigger(hass, config, action, automation_info):
async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for events based on configuration."""
event = config.get(CONF_EVENT)
offset = config.get(CONF_OFFSET)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/automation/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)


async def async_trigger(hass, config, action, automation_info):
async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for state changes based on configuration."""
value_template = config.get(CONF_VALUE_TEMPLATE)
value_template.hass = hass
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/automation/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)


async def async_trigger(hass, config, action, automation_info):
async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for state changes based on configuration."""
at_time = config.get(CONF_AT)
hours, minutes, seconds = at_time.hour, at_time.minute, at_time.second
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/automation/time_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
)


async def async_trigger(hass, config, action, automation_info):
async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for state changes based on configuration."""
hours = config.get(CONF_HOURS)
minutes = config.get(CONF_MINUTES)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/automation/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def _handle_webhook(action, hass, webhook_id, request):
hass.async_run_job(action, {"trigger": result})


async def async_trigger(hass, config, action, automation_info):
async def async_attach_trigger(hass, config, action, automation_info):
"""Trigger based on incoming webhooks."""
webhook_id = config.get(CONF_WEBHOOK_ID)
hass.components.webhook.async_register(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/automation/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)


async def async_trigger(hass, config, action, automation_info):
async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for state changes based on configuration."""
entity_id = config.get(CONF_ENTITY_ID)
zone_entity_id = config.get(CONF_ZONE)
Expand Down
Loading