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

Add scene.create service #27023

Open
balloob opened this issue Sep 27, 2019 · 4 comments

Comments

@balloob
Copy link
Member

commented Sep 27, 2019

Home Assistant release with the issue: 0.99
Component/platform: Scene
Description of problem:

We should be able to create scenes using a service. This will allow people to store state of entities as part of a script, do something, and then restore it using the normal service.

By creating it as primitives, people can use it in a wide variety of use cases.

Service should be added to homeassistant/scene.py

For first version, we should not focus on persisting it to disk. It will be lost after a restart or config reload. (persisting can be step 2).

Example service data (just like the scene config):

scene_id: temp_entered_house
entities:
  light.kitchen: on
  light.ceiling:
    state: on

This would create the scene scene.temp_entered_house which can be activated using the standard scene.turn_on service. If the scene already exists, it should error out if scene is defined in configuration.yaml, override if it was defined using the scene.create service.

@dkagedal

This comment has been minimized.

Copy link

commented Oct 7, 2019

The scene config uses name: for the scene entity id. Shouldn't this use the same?

Apart from being subjectively better (IMHO), it would also allow for a very straighforward (dumb) mapping from the config to the service call, so that we can have just one implementation in the end.

@dkagedal

This comment has been minimized.

Copy link

commented Oct 7, 2019

I'm new to HA development, but this leads me to ask whether there are any general principles around this, or if we could have such principles? Something like how an entity declaration in the configuration file maps to a create service call.

@balloob

This comment has been minimized.

Copy link
Member Author

commented Oct 7, 2019

This is the first service to create entity IDs via service.

We need name anyway, so why don't we make sure that either name or entity_id is passed in. If either is not passed in, generate one from the other. We should make sure that entity_id is unique.

@dkagedal

This comment has been minimized.

Copy link

commented Oct 7, 2019

Sounds good. But it means that it shouldn't use scene_id in the service API, right?

Is this name the same thing as what is sometimes called the "friendly name"? It would be helpful to make sure things are consistent in terminology and attribute names etc.

By the way, the entity ID is missing from the yaml coniguration for scenes, since there is no way to provide the entity id (at least not documented).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.