Skip to content

Ignore attribute changes in automation trigger from/to#7651

Merged
emlove merged 3 commits into
home-assistant:devfrom
amelchio:trigger-on-attributes-not
May 20, 2017
Merged

Ignore attribute changes in automation trigger from/to#7651
emlove merged 3 commits into
home-assistant:devfrom
amelchio:trigger-on-attributes-not

Conversation

@amelchio
Copy link
Copy Markdown
Contributor

@amelchio amelchio commented May 18, 2017

Description:

This changes from/to filters on automation triggers to only consider actual state changes, not attribute updates. The change only makes a difference if just one of from/to is specified.

Using state as an alias of to is deprecated because it is ambiguous.

These changes were agreed upon in #7556.

Related issue (if applicable): fixes #6299 #7556

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#2665

Breaking change note 1: An automation state trigger that had only from or to (but not both) used to be triggered whenever state attributes changed, even if the actual from/to state remained the same. This has been changed so that from and to will only match when the state actually changes from or to the specified state.

Breaking change note 2: The automation state trigger used to allow state as an alias for to. This naming was a bit confusing and state has now been deprecated.

Example entry for configuration.yaml (if applicable):

This example no longer arms the alarm when GPS coordinates are updated while the device is home:

automation:
  - alias: ‘Arm alarm when leaving home'
    trigger:
      - platform: state
        entity_id: device_tracker.amelchio
        from: ‘home’

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code does not interact with devices:

  • Local tests with tox run successfully.
  • Tests have been added to verify that the new code works.

Copy link
Copy Markdown
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

I like it 👍

amelchio added 2 commits May 19, 2017 22:29
This makes it somewhat easier to read if the suggestion happens to be
named "to".
@amelchio amelchio changed the title [WIP] Ignore attribute changes in automation trigger from/to Ignore attribute changes in automation trigger from/to May 19, 2017
@amelchio
Copy link
Copy Markdown
Contributor Author

I have added a test and updated the documentation. I am happy with this now but would appreciate a review from @armills.

(Note: it turned out that for without to is already forbidden.)

@amelchio amelchio requested a review from emlove May 19, 2017 21:10
Copy link
Copy Markdown
Contributor

@emlove emlove left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for putting it together! I think this behavior will be a lot more intuitive.

@emlove emlove merged commit 81f0826 into home-assistant:dev May 20, 2017
@balloob balloob mentioned this pull request Jun 2, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Sep 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

State changed triggered when state is not changed

5 participants