Add context to scripts and automations (#16415)
* Add context to script helper * Update script component * Add context to automations * Lint
This commit is contained in:
parent
e1501c83f8
commit
746f4ac158
17 changed files with 164 additions and 144 deletions
|
@ -32,12 +32,12 @@ def async_trigger(hass, config, action):
|
|||
@callback
|
||||
def hass_shutdown(event):
|
||||
"""Execute when Home Assistant is shutting down."""
|
||||
hass.async_run_job(action, {
|
||||
hass.async_run_job(action({
|
||||
'trigger': {
|
||||
'platform': 'homeassistant',
|
||||
'event': event,
|
||||
},
|
||||
})
|
||||
}, context=event.context))
|
||||
|
||||
return hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP,
|
||||
hass_shutdown)
|
||||
|
@ -45,11 +45,11 @@ def async_trigger(hass, config, action):
|
|||
# Automation are enabled while hass is starting up, fire right away
|
||||
# Check state because a config reload shouldn't trigger it.
|
||||
if hass.state == CoreState.starting:
|
||||
hass.async_run_job(action, {
|
||||
hass.async_run_job(action({
|
||||
'trigger': {
|
||||
'platform': 'homeassistant',
|
||||
'event': event,
|
||||
},
|
||||
})
|
||||
}))
|
||||
|
||||
return lambda: None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue