Skip to content

New Events and Context Fixes#18765

Merged
balloob merged 3 commits intohome-assistant:devfrom
hunterjm:automation_script_events
Dec 4, 2018
Merged

New Events and Context Fixes#18765
balloob merged 3 commits intohome-assistant:devfrom
hunterjm:automation_script_events

Conversation

@hunterjm
Copy link
Copy Markdown
Member

Description:

Adds new core events for automation trigger and script run per discord conversation with @balloob.

Removes custom logbook event for automations and adds the new automation event to the logbook. Also fixes carrying over context for image processing from the service call.

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

"""Turn the script on."""
context = kwargs.get('context')
self.async_set_context(context)
self.hass.bus.async_fire(EVENT_SCRIPT_RUN, {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, then that's not a problem then !

@balloob balloob merged commit b900005 into home-assistant:dev Dec 4, 2018
@ghost ghost removed the in progress label Dec 4, 2018
@luca-angemi
Copy link
Copy Markdown
Contributor

luca-angemi commented Dec 12, 2018

Is this a breaking change?
I tested in 0.84.0b4 and the automation triggered entries are not appearing anymore in the logbook.

@balloob balloob mentioned this pull request Dec 12, 2018
@hunterjm hunterjm deleted the automation_script_events branch May 1, 2020 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants