There are probably ways to improve this, so please help! And I searched, but didn’t see any similar posts.
This is just a simple how-to, with best practices for creating a simple “Something Mode”, with automations and various triggers and a timeout to end the mode. This will help you eliminate unnecessary redundancies and complexities and edge cases that might occur with other approaches to this problem.
A couple of use cases: changing lights and air purifier when you put on a movie, bumping some tunes and disabling automatic lights for a party, etc etc.
First, create a toggle helper: Settings → Devices & Services → Helpers → Create Helper → Toggle. I name toggles so it’s clear that they’re true or false (boolean) variables, like “Movie Mode” or “Roommate is on a Call”.
Next, create two scripts: Settings → Automations & Scenes → Scripts → Add Script. I use a name that has a prefix of the mode, e.g. “Movie Mode: Activate” and “Movie Mode: Deactivate”. In these scripts, add the necessary actions for starting or stopping things. For example, in my “Movie Mode: Activate” script, I have actions to turn our air purifier to silent mode, turn off the living room lights and their motion sensor activation, and turn the kitchen lights to sleep mode in case someone walks in there (they shine into the living room). (Oh, it also plays this clip on a speaker for fun ) ✂️ Baby lock the doors and turn the lights down low - YouTube
Finally, create at least two automations: Settings → Automations & Scenes (should already be selected) → Create Automation.
The first two should have, for triggers, state triggers for the toggle helper (“Movie Mode”), one automation for transitioning to “On” and another for transitioning to “Off”. The actions for these automations should be the respective scripts from above. I call them “Movie Mode: Activate on Toggle Turn On” and “Movie Mode: De-Activate on Toggle Turn Off”.
The next automations should be the methods you want to use to toggle/turn on/turn off the mode. For example, you might want a script where the trigger is double-clicking a physical smart button and the action is to toggle the “Movie Mode” helper. You can include all the toggle triggers you want in this one place. Similarly, you can (optionally) create one to just turn on the mode (I haven’t had a use case for this yet). Finally, optionally create one to turn off the mode: I have this happen automatically at 05:00 AM for most modes in case people forget to turn it off manually. I use names like “Movie Mode: Turn Off Toggle Automatically” or “Movie Mode: Toggle”.
Now, you can add a button entity to dashboards of your toggle helper, and it will accurately represent whether the mode is on or off, and toggling it will allow you to toggle the mode!
This is pretty simple, but there are other ways to do it that don’t result in as clean/clear of a set of entities.
I hope this helps some of you!