💡 Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time - Light Control - Device Tracker - Night Lights

@kman42

First you need HA to know your TV is ON or not. Some TVs have a integration or something that works for HA. If not a smart plug can do this. If you use a smart plug then create a template binary sensor using this code. go to settings / devices & services / helpers tab / create helper / template / binary sensor / add your name (lets call it “TV ON”) and in “state template” use this code adding your smart plug entity in and adjusting the 85 to your requirements (when TV is ON/OFF check power and adjust).

{% if states('sensor.your_power_sensor_here')|float > 85 %}
  on
{% else %}
  off
{% endif %}

If you are not using night lights then use the “TV ON” or you TV may have a state when it is ON already and you didn’t need to create the template sensor using a smart plug… what ever it is use it in “Enable entity state option” option for night lights. Then set up your lights as required under night lights and you are done.

If you are using night lights see above post for a rough guide as it is the same way… create another automation …

Let us know how you go.

@fvhemert

Welcome to the community :wave:

If this is the case then you will need to use your binary sensor in the by-pass option 2. Your binary sensor has to be OFF when you would like the lights ON. Not sure if you can edit your binary sensor to do this. If not create another one using your binary sensor you have making it work the opposite way like this.

Go to settings / devices & services / helpers tab / create helper / template / binary sensor / add your name (lets call it “LUX Dark”) and in “state template” use this code

{{ is_state('input_boolean.your_binary_sensor_here', 'off') }}

Then add “LUX Dark” to the by-pass option 2

Let us know how you go.

Blacky :smiley:

@Blacky thanks for the quick reply. I’ll give it a try this weekend and post the results.

Thank you again for the quick response.

The nightlight option is working :slight_smile: , but the problem is that I do want to use the nightlight option later on.

The other option is (for me) to much a work around, and I am afraid I cant recall the automation later on. I know that this is not your problem, but I am not a everyday poweruser of HA. So I do want to make things as understandable as possible for myself.

May I brutally ask if there is a plan to add the Kelvin (and maybe the transition) option to the bypass option? That would solve all the problems. And I really do think there are more people who want to override the settings (bypass) with other settings then the original, and not only change the delay.

There are a ton of options you can use the bypass option for, if you can change the brightness and Kelvin.

@Hassio

Nice one

This is a problem for me to as it keeps growing and has so many scenario / options to keep track of.

This will grow the automation. Then there so many more different options. The best way is to provide the by-pass trigger then the user can go in any direction they like.

Blacky :smiley:

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! :bulb::sparkles:

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 :sparkles:

  • 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.

28

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 :tada: :partying_face:

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 :partying_face: :tada:

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 :smiley:

Back to FAQ: Click Here

Back to “The Settings & Best Practice Guidelines” Click Here

4 Likes

Great! Thank you. I will try it today

Is there any way to have the blueprint ignore lights that have become unavailable? Sometimes my lifx bulbs drop off the net temporarily and the automation fails because of this

Kitchen Lights: Choose at step 1: default: Parallel Actions for dynamic lighting: parallel 1: Choose at step 7: Set the Sun Elevation Lighting - Colour Temp + LUX Controled Brightness for the normal lights switch: Dynamic Lighting Control: Choose at step 1: Set the dynamic lighting lux brightness and dynamic sun elevation colour temperature for the normal lights switch: Error executing script. Error for call_service at pos 1: Error rendering data template: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'brightness'
Kitchen Lights: Choose at step 1: default: Parallel Actions for dynamic lighting: parallel 1: Choose at step 7: Set the Sun Elevation Lighting - Colour Temp + LUX Controled Brightness for the normal lights switch: Dynamic Lighting Control: Error executing script. Error for choose at pos 1: Error rendering data template: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'brightness'
Kitchen Lights: Choose at step 1: default: Parallel Actions for dynamic lighting: parallel 1: Choose at step 7: Set the Sun Elevation Lighting - Colour Temp + LUX Controled Brightness for the normal lights switch: Error executing script. Error for repeat at pos 1: Error rendering data template: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'brightness'
Kitchen Lights: Choose at step 1: default: Parallel Actions for dynamic lighting: parallel 1: Error executing script. Error for choose at pos 7: Error rendering data template: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'brightness'
Kitchen Lights: Choose at step 1: default: Error executing script. Error for parallel at pos 4: Error rendering data template: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'brightness'

@johnwang16

Hi John, welcome to the community.

Can you confirm that your lights have a attribute brightness. Go to developer tools / states tab and search all your light you are using in the automation for the attribute brightness as shown below.

Blacky :smiley:

Thanks, @Blacky, I’m going to try this approach this weekend. Which post are you referring to when you say “see above post”? Here’s a summary of what I think you are suggesting. Note: I am currently using the night light feature.

  1. Create a toggle helper called “TV ON”
  2. Use by-pass option 3 in my existing Sensor Light automation and enter the “TV ON” helper
  3. Create a new template binary sensor. Go to helpers / create helper / template / binary sensor / in states add this. Let’s name this “TV Lights”.
{{ is_state('input_boolean.TV_ON_helper', 'off') }}
  1. Create 2nd automation with lights as required. Do I use the new Turn Light, Switch or Scene On & Off automation or another instance of the Sensor Light automation?

  2. Add the new template binary sensor (TV Lights) into the 2nd automation by-pass option 3.

Do I have this right?

Thanks!

thanks! Yes, the light does have a brightness attribute. Here’s the list when it’s online. I can reproduce the exception if I unplug any light such that it’s unavailable

min_color_temp_kelvin: 2500
max_color_temp_kelvin: 9000
min_mireds: 111
max_mireds: 400
effect_list: effect_colorloop, effect_pulse, effect_stop
supported_color_modes: color_temp, hs
color_mode: color_temp
brightness: 176
color_temp_kelvin: 4999
color_temp: 200
hs_color: 27, 19.257
rgb_color: 255, 227, 205
xy_color: 0.373, 0.349
effect: null
friendly_name: Kitchen Sink
supported_features: 36

Hi Blacky, can you see why this isn’t working again? For a post HASS restart?

different to yesterday. this is a light that has a scene enabled for the on and off commands.

Tested by also using the same automation in another room. The one that did work before. That still works and looks to be identical.

Another one for a light on a simple on/off also failed:

Cant figure out why some worked not others. All ad motion triggered shortly before the HASS restart. Only the Kitchen LED did work.

1 Like

Hey, just another thank you for the blueprint. I just loaded it yesterday and am only working with one bulb so far. Many options! Great work! Works great, once I fixed my mistake of entity vs sensor. :laughing: I also just loaded your sensor light add-on. Both appear to meet and exceed my needs.

Just responding to my own post to help anyone that may be trying to do the same thing.

1-2. No need for a helper if HA recognizes your TV. Just set it as the entity in the bypass.
3. No need for a new template binary sensor.
4. Create 2nd automation with lights as required. Use the new Turn Light, Switch or Scene On or Off automation.
5. Add the TV as the entity into the 2nd automation by-pass option 3.

Works perfectly. It’s like magic!

@johnwang16

Okay, thanks John :+1:… I will have to add this to my list so I can test it. Currently I have completed the next release and working through final checks so I am not sure if I will get to this before then but I will look into it.

Stay turned.

Blacky :smiley:

1 Like

@richsimpson

Yep I know what that is. Because you are using scenes only and the way scenes are handled in HA the automation can’t tell if it is ON or OFF. The good news is I have been working on this and it has been resolved. Stay turned for the next release that will be out soon. If you can’t wait for it then what you can do is just add one light entity used in the scene into “Lights - Switches - Scenes - Scripts” and “Night Lights”.

Blacky :smiley:

@G2740

Hi Dave, it is realy nice to get this type of feedback every now and then without any questions. Glad you like it and thanks for yore kind words :smiling_face_with_three_hearts:

Stay tuned for the next release to be out soon.

Blacky :smiley:

@kman42

Love it :+1:… looks like your are getting the hang of the blueprint… nice work and thanks for the update.

Blacky :smiley:

FAQ: How to use the Ambient Options

What are Ambient Options?

The Ambient Options set conditions that restrict automation to run only when it is dark or below specific ambient light levels. These levels are typically measured in LUX, and such sensors may also be referred to as LUX sensors. These are global conditions and can work alongside other selected conditions if configured.

Ambient Light Sensor

Using a primary outdoor sensor to detect the actual outdoor LUX value can be beneficial, as it allows you to apply a consistent measurement across all lighting automation setups. Indoor sensors may be used when the outdoor LUX value is not relevant, such as when lights are used in enclosed spaces like a garage or when blinds are closed.

Ambient Light Sensor - Site Conditions

Sometimes, when lights turn on, they can affect the ambient light sensor, increasing its LUX value and causing the lights to turn off prematurely. To address this, select an option that best suits your installation.

NOTE: If you are using a buffer zone between the high and low lux values, select “NO” for this option.

Ambient Light - Low & High Lux Values

These settings allow you to create a buffer zone between two lux values to manage light activation and deactivation more effectively.

  • Ambient Light - Low Lux Value: Set this value to determine when the lights should turn ON. The light will activate when the lux level falls below this set value. This value should be equal to or lower than the “High Lux Value” below. A typical guide value is 20 lux (dusk).

  • Ambient Light - High Lux Value: Set this value to determine when the lights should turn OFF. The light will deactivate when the lux level rises above this set value. This value should be equal to or higher than the “Low Lux Value” above. Setting a higher value creates a buffer zone to prevent immediate light deactivation. A typical guide value is 80 lux (dawn).

Enjoy

Blacky :smiley:

Back to FAQ: Click Here

Back to “The Settings & Best Practice Guidelines” Click Here

I will look out for it. though the last one is screenshot for Utility room failed and is also a simple light and motion sensor. no Night mode, just on and off.