FAQ: How to use scenes and scripts
Scenes or scripts offer an effective means of providing additional customization for your spaces within Home Assistant. They serve as versatile tools that allow you to define and automate specific states or sequences of actions for various devices and components within your smart home environment. By utilizing scenes or scripts, you can create tailored configurations and behaviours that align with your preferences and requirements. Whether itâs adjusting lighting, setting the ambiance, controlling devices, or orchestrating complex sequences, scenes and scripts offer a high degree of flexibility and control, empowering you to personalize your smart home experience to suit your unique needs.
Your lighting experience, your way - take control and customize it to perfection!
Scenes
Scenes can be particularly useful when you want to set a specific colour for your lights, especially because the lighting control options donât offer this feature. The controlling behaviour to adjusting your light colours can vary significantly across different manufacturers and platforms, leading to confusion. Using scenes eliminates this guesswork, as Home Assistant will handle everything for you. Additionally, scenes can help unify lighting settings, even if you have multiple lights with different formats, ensuring consistent colour representation when turning them on.
Scripts
Scripts offer a versatile approach if you want to customize which lights or switches turn ON or OFF based on your specific requirements. They can activate different lights or switches depending on the time of day or set a soothing glow light when turning OFF during night lights. The level of creativity is entirely up to you. Below is a basic automation examples to kick-start your creative inspiration.
Scenes - Scripts To Turn OFF
In Home Assistant, scenes and scripts are invaluable tools for automating tasks and streamlining operations by activating predefined configurations across various devices. Unlike individual entities like lights or switches, scenes and scripts are not inherently designed to be âturned OFFâ because they represent preset states or sequences rather than ongoing statuses.
To address this, supplementary scenes or scripts are created to restore the environment to its desired state once the automation sequence is complete. These additional commands serve as reset mechanisms, ensuring that the environment returns to its default or preferred settings, such as turning OFF lights or switches, once the automation ends. Once the desired scene or script has be created entering it into âScenes - Scripts To Turn OFFâ will facilitate this action.
Scenes & Scripts - Toggle Helper
Scenes and scripts lack a discernible state within Home Assistant, making it challenging for the automation to determine their activation status. To address this, itâs recommended to use a toggle helper alongside scenes or scripts. This enables the automation system to recognize when a scene or script has been activated, ensuring smooth operation. When entering scenes or scripts in âLights - Switches - Scenes - Scriptsâ or âNight Light,â itâs advisable to create a dedicated toggle helper for each input.
Toggle helpers also assists when crossing over from normal lights to night lights and vice versa, when using the ambient options and setting the ambient site conditions to âYesâ, or when Home Assistant restarts.
Scenes & Scripts - Crossing Over From Normal Lights To Night Lights
Having a toggle helper for scenes & scripts assists for the smooth operation when crossing over from normal lights to night lights and vice versa when a scene or script are ON. You will still need to enable âIf lights are ON, adjust the lights when crossing overâ in the night lights âLight Control Optionsâ for your scenes and scripts to transition to their new state.
We can create scripts for use in âScenes - Scripts To Turn OFFâ to apply different off settings based on whether normal lights or night lights are activated. To ensure smooth operation when crossing over between normal lights to night lights and vice versa, and if your lights, switches, scenes, or scripts are OFF, weâve included an input selection in âNight Lights - Use The Light Control Optionsâ labelled âYes - Manage OFF script when crossing over.â Enabling this option accommodates the different OFF settings you may have in your script when transitioning from normal lights to night lights and vice versa. When this happens the script gets activated applying your script settings.
Automation Example
1. Setup script and scenes to provide a night glow when night lights are activated.
This automation example is particularly useful for households with stairs, providing a gentle, low-level glow throughout the night (night glow). Families with young children often find this comforting, as it creates a soft, safe ambiance. It also work realy well with your outdoor lighting. It would be one of the most common how to request I get asked.
In this example, we have chosen a set of brightness % levels, but feel free to adjust them according to your preference. You can also customize the light colour and/or colour temperature. Additionally, you are not limited to controlling just lights; you can also toggle switches or control any other device you like.
What will happen when setting up the automation this way.
During normal lighting conditions, your lights will turn ON at 100% brightness and turn OFF when the time delay ends. When night lights are activated, your glow lights will be set to 10%. Then, when the automation is triggered, your lights will adjust to 50% brightness and then return to 10% when turning OFF. When the night lights are deactivated, your lights will turn OFF.
We will need to create 2 scenes, 1 script and 2 toggle helpers. It is very easy to do
- Scene 1 = 100% brightness for normal lights
- Scene 2 = 50% brightness for night lights
- Script 1 = Turn OFF during activation of normal lights and 10% brightness during activation of night lights.
- Toggle Helper 1 = Lights Scene & Script Helper
- Toggle Helper 2 = Night Lights Scene & Script Helper
Creating a Toggle Helper
Go to Settings / Devices & Services / click on the âHelpersâ tab at the top / create helper and select toggle.
Input the name you would like to call it and click create.
Then just repeat the proses for the second toggle helper.
Creating a scene
Go into Settings / Automation & Scenes / Click on the scene tab at the top / click âAdd Sceneâ and enter in a name you would like to call it.
Then add your entities in. We will add in a light entity and set the brightness to 100% , then click save.
We will do the same process creating another scene with the light at 50% brightness.
Creating a script
Go into Settings / Automation & Scenes / Click on the scrips tab at the top / click âAdd Scriptâ and click create new script, then enter in a name you would like to call it.
We will then click the âAdd Actionâ button.
In the search action start typing "ifâ and the âIf-thenâ action will appear. Select it.
First we will select the âAdd Conditionâ button.
For night lights in this automation we are using the âEntity Stateâ condition, so in the search action start typing "stateâ and the âStateâ action will appear. Select it.
If you are using a different condition other than state for night lights then choose from the below 2 steps as to the condition you are using:
- If you are using Time as a night light condition type " time" in and select it. Then enter in for âAfterâ = Start and âBeforeâ = End settings in the night light time conditions.
- If you are using Sun as a night light condition type " Numeric state" in and select it. Enter sun as the entity. Then using fixed number the âAboveâ = Rising and the âBelowâ = Falling settings in the night light sun conditions.
Then we will select the entity we used in the night lights condition and set the state to ON.
Then we will click the âAdd Actionâ button in the âThenâ.
In the search action start typing "lightâ and the âLight: Turn onâ action will appear. Select it.
Then we are going to enter in our light, set the transition to 4 (Very important for smooth operation) and our brightness to 10%. Once done we will select the âAdd Elseâ
Then we will select the âAdd Actionâ under âElseâ
In the search action start typing "lightâ and the âLight: Turn offâ action will appear. Select it.
Then we are going to enter in our light, set the transition to 4 (Very important for smooth operation) and click âSave Scriptâ
Now we have created our script
Setting up the automation
You will need to input your trigger and then input your scene 1 at 100% as shown below. We have also created a toggle helper because we are using scenes in âLights - Switches - Scenes - Scriptsâ and entered it into âScenes & Scripts - Toggle Helperâ. We then added our script into âScenes - Scripts To Turn OFFâ.
In the âLight Control Optionsâ we set the transition to 2 and 5 (Very important for smooth operation)
Down to night lights we have enabled it, entered in our scene 2 at 50%. We have also created another toggle helper because we are using scenes in âNight Lightsâ and entered it into âNight Lights - Scenes & Scripts - Toggle Helperâ.
In the âNight Lights - Light Control Optionsâ we set the transition to 2 and 5 (Very important for smooth operation). We have also selected âYes - Manage OFF script when crossing overâ. This will apply the 10% when night lights condition entity state turn ON even if the lights are OFF.
Click âSaveâ and you are done
Now during normal lighting conditions, your lights will turn ON at 100% brightness and turn OFF when the time delay ends. When night lights are activated, your glow lights will be set to 10%. Then, when the automation is triggered, your lights will adjust to 50% brightness and then return to 10% when turning OFF. When the night lights are deactivated, your lights will turn OFF.
I hope this explanation helps you understand how scenes and scripts are utilized in the blueprint automation process.
Enjoy
Blacky
Back to FAQ: Click Here
Back to âThe Settings & Best Practice Guidelinesâ Click Here