Scenes vs Automations

Hi,

I’m a little confused about what scenes are vs automations vs scripts. Let’s say I want to do this:

  • if I detect the bathroom exceeds some humidity threshold (someone in the shower),
  • open the heating valve to make it cozy until some nice temp is reached in the bathroom
  • keep it there until the humidity goes down to a new threshold (shower over, towels are dry)
  • return heating to initial configuration

Things I don’t understand:

  • Should I think of the scene as a function that I can place in the action part of the automation? Or is that what a script is? Or do they have a different purpose?
  • How do I go back to the configuration that the radiator had before the shower, given that people play around with it? I should save it into some variable in the action?
  • How do I make an automation last only for the period of high humidity? Or do I need two automations, one when humidity goes up, one when it goes down?

Thanks for the insight!

A scene is a saved state of one or more entities that can be instigated with a single service call.

A script is one or more service calls run in sequence.

An automation is basically a script that is executed when a given event or combination of circumstances occurs.

So basically the answer to your question is that you can use any of the three to achieve what you want, but only the automation will do so ‘automatically’. However the action of the automation could be to run a script, and one of the services in a script could be to activate a scene. So you could potentially use all 3 if you wanted to.

11 Likes

Thanks!

So am I right in thinking that to I can save the initial room state by creating a scene in the automation action, so that I can refer to it at the end when the action is finished?

Can I share these ad-hoc scenes between scripts? I guess I would like to save the state of the room when the script is triggered by a rising sensor, but then I would like to trigger another action when the sensor falls back and at that point restore the save scene. But I think this would require two separate automations?

Yes, use the scene create service.

No, but it’s less of a problem than you think, because if homeassistant is controlling these things then it should already know what state things should be in at any given time, so a normal scene will do the job rather than an ad-hoc one. Ad-hoc scenes are more designed for a temporary deviation like an announcement over tts or a flash of the lights to indicate an alert of some kind.

In your case of the rising and falling sensor, its one automation, and you can use the ad-hoc scenes to achieve it no problem.

Are scene configurations persistent across reboots and such, e.g. I can create a scene and re-activate when I want even after a reboot?

I hope that’s not a dumb question.

Normal scenes yes, ad-hoc no.

Neat! Guess I need to do some learnin’

1 Like

May I ask, what is the difference between Normal and Ad-hoc scenes?

Normal scenes are configured through the UI/yaml and saved permanently.

Ad-hoc scenes are created inside your automation and saved temporarily in memory – e.g the state of the room before you decided to turn the lights down and play Barry White for 30 seconds – so that you can go back to that state when Barry is resting.

2 Likes

Thanks for the clarification

What you could do is to keep it as one automation (“activate” and “deactivate”) with a possible timeout in between.

So your automation activates on the rising sensor, store the states in the ad-hoc scene and set the desires states. Then you add another action which is a “wait for trigger” (can also add time-out with “continue” to not stay on forever) which detects the falling sensor and after that restore states by saved ad-hoc scene