Automations and Scenes and Scripts, oh my

So as I’m delving further into HA, I’m noticing there’s often more than one way to skin the proverbial cat.

To that end, I’m interested to see what the favorite (or correct, or preferred) method of controlling lights and scenes is among users.

I can write an automation, ‘if x switch, turn on y light’, but that limits me to having to write an automation for any device that affects those lights and seems the least efficient way to handle it.

So, it seems to be a tossup between writing a scene and calling it, or writing a script and calling it. Scenes are nice, as they adjust in real time, but that can also lead to a negative WAF if she happens to be in the room. :stuck_out_tongue:

What say you? What’s your preferred method of handling scenes?
Is there an advantage or disadvantage to one method or the other that I’m missing?
Am I completely off base?

My goal is to figure out the most efficient technique and use it from the ground up for consistency.

1 Like

A scene is a series of actions, where each action is limited to setting an entity’s state. You can activate a scene from the UI, a script, or automation.

Example: Set bedroom light brightness to 50%.


A script is a series of actions optionally controlled by logic, able to execute any service call. You can activate a script from the UI or an automation.

Example: Set bedroom light brightness to 50% but only if the light is currently off and the current time is after 20:00:00.


An automation listens for a desired event to occur and then executes a series of actions optionally controlled by logic, able to execute any service call.

Example: When motion is detected in the bedroom, set bedroom light brightness to 50% but only if the light is currently off and the current time is after 20:00:00.


Which one is the right one for a given application, depends on the application’s requirements. For my purposes, I use automations and scripts exclusively.


EDIT

Added examples and links to documentation.

3 Likes

@123 explanation is excellent.

Essentially, if you want something to happen when something else happens, that is an automation.

But of course, Automations can call scripts as many do. So repetitive things can be put in scripts and variables used to detemine which thing caused this to be run, and take action.

Just like @123, I never use scenes in HA.

BUT … I have an Insteon installation and I use their “scenes”. That is because triggering a scene in Insteon will turn all lights (on/off/whatever) instantly, HA scenes in that use case have a popcorn effect, one a time. Some of my insteon scenes have 15 lights/switches … turning the scene on through HA “insteon.scene_on” and it happens in a fraction of a second. Recreating that exact same scene in Home Assistant and then activation the scene will take 20 seconds,

Could you give an example?

Interesting.

Most of my house is Insteon/ISY as well, I’m slowly moving everything over to HA and different hardware.
I wasn’t aware of the HA scene delay, as I haven’t built any large scenes in there yet.
For the most part, I’m just recycling ISY scenes under HA control until the Insteon hardware for that area gets replaced.

Have you explored groups?

I also use scripts exclusively since they offer more control (and also don’t enable when you go to edit them if that’s still a thing).

However, one use for scenes that I have found is that you can use them to easily save the state of any number of entities:

You can use snapshot_entities to save the state of those entities. Alternatively you can just manually create a scene to recall later.

2 Likes

I have. I use them to gather common room lighting.