Skip to content
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

Creating a scene by snapshotting entities #28939

Merged
merged 13 commits into from Nov 22, 2019
Merged

Conversation

@Santobert
Copy link
Member

Santobert commented Nov 22, 2019

Breaking Change:

Nothing breaks

Description:

It's now possible to create a scene by snapshooting entities. This would be helpful to create a scene on the fly without knowing the current state. Please let me know if this feature is not needed/wanted.

Example use case:

  • Turn off the climate while a window is open, restore the previous state as soon as the window closes again.
  • Change the light to inform about something, then restore the previous state.

Since we don't know the current state before changing things, we can't create a scene from it at the moment. This PR makes it possible.

Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#11255

Example service data:

scene_id: all_lights
entities:
  light.bed_light: on
snapshot_entities:
  - light.ceiling
  - light.kitchen

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.
  • I have followed the development checklist

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

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.
Santobert added 3 commits Nov 21, 2019
@Santobert Santobert requested a review from home-assistant/core as a code owner Nov 22, 2019
@project-bot project-bot bot added this to Needs review in Dev Nov 22, 2019
@probot-home-assistant

This comment has been minimized.

Copy link

probot-home-assistant bot commented Nov 22, 2019

Hey there @home-assistant/core, mind taking a look at this pull request as its been labeled with a integration (homeassistant) you are listed as a codeowner for? Thanks!

@Santobert Santobert changed the title Scene snapshot Create a scene by snapshotting entities Nov 22, 2019
@Santobert Santobert changed the title Create a scene by snapshotting entities Creating a scene by snapshooting entities Nov 22, 2019
@Santobert Santobert mentioned this pull request Nov 22, 2019
2 of 2 tasks complete
@balloob

This comment has been minimized.

Copy link
Member

balloob commented Nov 22, 2019

I like the idea and I like the structure of the service data. I see how you came up with "snapshot", but I don't know if that is the right configuration term since it doesn't rely to entities at all. Maybe snapshot_entities or import_entities ?

Santobert added 2 commits Nov 22, 2019
@Santobert Santobert force-pushed the Santobert:scene_snapshot branch from 3f143ac to e6de278 Nov 22, 2019
Santobert added 2 commits Nov 22, 2019
Dev automation moved this from Needs review to Review in progress Nov 22, 2019
@balloob

This comment has been minimized.

Copy link
Member

balloob commented Nov 22, 2019

image

We need to tone this guy down…

@Santobert

This comment has been minimized.

Copy link
Member Author

Santobert commented Nov 22, 2019

Yes, I expected this. I need to learn how to assert exceptions 😅

Copy link
Member

balloob left a comment

Looks great. Ok to merge when the test has been updated.

@Santobert Santobert force-pushed the Santobert:scene_snapshot branch from 985ea51 to 903d344 Nov 22, 2019
@Santobert Santobert changed the title Creating a scene by snapshooting entities Creating a scene by snapshotting entities Nov 22, 2019
Copy link
Member

MartinHjelmare left a comment

Great!

Dev automation moved this from Review in progress to Reviewer approved Nov 22, 2019
@MartinHjelmare

This comment has been minimized.

Copy link
Member

MartinHjelmare commented Nov 22, 2019

Can be merged when build passes.

@balloob balloob merged commit c35f9ee into home-assistant:dev Nov 22, 2019
11 checks passed
11 checks passed
CI #20191122.36 succeeded
Details
CI (FullCheck Mypy) FullCheck Mypy succeeded
Details
CI (FullCheck Pylint) FullCheck Pylint succeeded
Details
CI (Overview CheckFormat) Overview CheckFormat succeeded
Details
CI (Overview Lint) Overview Lint succeeded
Details
CI (Overview Validate) Overview Validate succeeded
Details
CI (Tests PyTest Python36) Tests PyTest Python36 succeeded
Details
CI (Tests PyTest Python37) Tests PyTest Python37 succeeded
Details
cla-bot Everyone involved has signed the CLA
codecov/patch 100% of diff hit (target 94.47%)
Details
codecov/project 94.47% (target 90%)
Details
Dev automation moved this from Reviewer approved to Done Nov 22, 2019
@Santobert Santobert deleted the Santobert:scene_snapshot branch Nov 23, 2019
AndreBremer added a commit to AndreBremer/home-assistant that referenced this pull request Nov 24, 2019
* Initial commit

* Add tests

* service.yaml

* typo

* snapshooted -> snapshot

* snapshot_entities instead of snapshot

* Edit validator

* Fix tests

* Remove keys()

* Improve coverage

* Activate scenes

* Use pytest.raise

* snapshot -> snapshotted
@lock lock bot locked and limited conversation to collaborators Nov 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
4 participants
You can’t perform that action at this time.