-
-
Notifications
You must be signed in to change notification settings - Fork 38.2k
New Events and Context Fixes #18765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Events and Context Fixes #18765
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,9 +12,11 @@ | |
|
|
||
| import voluptuous as vol | ||
|
|
||
| from homeassistant.core import EventOrigin | ||
| from homeassistant.const import ( | ||
| ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_TURN_ON, | ||
| SERVICE_TOGGLE, SERVICE_RELOAD, STATE_ON, CONF_ALIAS) | ||
| SERVICE_TOGGLE, SERVICE_RELOAD, STATE_ON, CONF_ALIAS, | ||
| EVENT_SCRIPT_RUN, ATTR_DOMAIN, ATTR_NAME) | ||
| from homeassistant.loader import bind_hass | ||
| from homeassistant.helpers.entity import ToggleEntity | ||
| from homeassistant.helpers.entity_component import EntityComponent | ||
|
|
@@ -170,8 +172,15 @@ def is_on(self): | |
|
|
||
| async def async_turn_on(self, **kwargs): | ||
| """Turn the script on.""" | ||
| context = kwargs.get('context') | ||
| self.async_set_context(context) | ||
| self.hass.bus.async_fire(EVENT_SCRIPT_RUN, { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we have a bit of a weird thing right now with scripts that include a delay that get turned on . It means that we don't always start a new script, but sometimes just continue it. (it's kinda weird honestly). So we might want to check that.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add an attribute to the event data to determine if it is a new run or a continuation based on self.script.is_running in the component, then add it to logbook for "{{name}} started" and "{{name}} continued" for scripts. I currently only added automations to logbook.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like scripts running again to bypass delay has been disabled based on this: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/script.py#L118-L119
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, then that's not a problem then ! |
||
| ATTR_NAME: self.script.name, | ||
| ATTR_DOMAIN: DOMAIN, | ||
| ATTR_ENTITY_ID: self.entity_id, | ||
| }, EventOrigin.local, context) | ||
|
hunterjm marked this conversation as resolved.
Outdated
|
||
| await self.script.async_run( | ||
| kwargs.get(ATTR_VARIABLES), kwargs.get('context')) | ||
| kwargs.get(ATTR_VARIABLES), context) | ||
|
|
||
| async def async_turn_off(self, **kwargs): | ||
| """Turn script off.""" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.