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

@mdb17

The Ambient condition addresses this scenario. If the room is already bright enough, the light won’t turn on. Could you clarify if you’re looking for something different or additional?

Maybe the bypass is what your after?

Blacky :smiley:

Hi @Blacky,

Great work keeping this blueprint alive!

Is it possible to have the automation make constant adjustments to light temperature throughout the day - when a toggle button is on and the lights are on?

Typical use case:
15x lights with temperature control are grouped together as 1 light entity. When any of the lights are on (brightness>0%) the automation is triggered and adjusts light temperature according to dynamic lighting setting - but only if a toggle button is active (I.e: “Auto Light Temperature” on or off). The lights are not triggered by motion sensors - only manual activation and timed automations.

Thanks :slight_smile:

@Cregeland

Yes, you can achieve this setup. However, to provide the best advice, I’ll need to understand your specific requirements. Could you please describe what should happen for each action you have in mind?

Once I have this information, I can guide you on how to set it up.

Blacky :smiley:

Thank you @Blacky,

The idea is to have the temperature of living room lights change according to sun angle - the same way already implemented in dynamic light control. Warm light in the morning/evening and cold during the day. The only difference is that the lights are not triggered by a PIR - they are typically turned on manually or by a scene and left on for hours.

It would be nice if an automation could adjust the light temperature (and maybe brightness) every x minutes while the lights are on - and while «auto light temp» toggle button/suitable entity is enabled.

@Cregeland

okay,

The «auto light temp» toggle button;

We have normal lights and night lights. Night Lights, despite the name, are just a different set of lights we can use. You could add a toggle labeled Dynamic Lighting OFF as the state condition for night lights. When the toggle is ON, it will use Night Lights; when OFF, it will use normal lights (dynamic lighting).

This can be tricky because automations generally don’t work well when the trigger (light ON) is also the action (light ON). However, there are several trigger options you can consider:

  1. Toggle Helper: Use a toggle helper to trigger the automation.
  2. Template Sensor: Create a template sensor for the light group. When the group is ON, the template sensor is ON, and it can serve as the trigger.
  3. Scene with Toggle: Although scenes don’t have a state, you can configure the scene to activate a toggle helper, which can then be used as the trigger.

Is this what you are looking for?

Blacky :smiley:

Thanks for the quick reply :slight_smile:

That could work. I have created a binary sensor template that turns on when the lights are turned on. The sensor updates correctly.

I use this binary sensor as the trigger and have selected the light group as target under “lights”. Under light control I have not selected anything except “Use colour temperature” since I do not want it to adjust brightness - only temperature.

Dynamic lighting nr 3 selected. minimum/maximum temperature set.

Night lights enabled with entity state only. Entity is toggle button (dynamic lighting off". No lights set as target under “night light” since it should not control anything when the “dynamic lighting off” is active.

The automation triggers but does not do anything. Did I miss anything?

The only downside I see to this is that the lights will not continue to be adjusted as time goes - only once when the automation is triggered?

Thanks again for excellent help.

I need to know what you are trying to do.

  1. What triggers the automation? Is it turning the light on manual?
  2. Why do you have «auto light temp» toggle.?

You don’t need to select “User colour temperature” when using dynamic lighting option 3. Dynamic lighting will do that and only Brightness and transition will be considered. It wont stop it from running but “User colour temperature” will not be considered when using DL option 3.

Dynamic lighting off was to take place of your «auto light temp» toggle. I thought you would like to be able to turn the lights ON with some light control but when this toggle is used then DL will be activated. I not sure why you have «auto light temp» toggle. If you want to prevent the automation from running (as you are not selecting any night lights) then you can just use this toggle in bypass option 2 and not in night lights. When this helper is ON you can still turn the lights ON and OFF manually but the automation will not run. When it is OFF the automation is active and DL will work.

Use this in your trigger.

I think we are getting our wires crossed.

Sorry for being unclear about my intention :smiley:

  1. When a light is turned on manually (physical switch, HA light card etc) the user will set the desired brightness.
  2. The automation is triggered by a binary sensor that is set to “ON” as a result of actions in step 1. I have that working and the automation is confirmed to trigger by this binary sensor.
  3. I would like the automation to set a suitable light temperature between 2700K and 5000K based on sun angle. Dynamic Lighting option 3. Typically warm light in the morning/evening and cold light in the middle of the day.
  4. The lights remain on for a few hours. During this time the automation will recalculate the light temperature as the sun angle changes. Intervals of 15 min or so is sufficient.
  5. If the user desires a different light temperature the bypass switch can be turned on (enable “Dynamic Light OFF”). I have that toggle button set under “Bypass” - “3 - Enable the Bypass - Keep the lights current state” to avoid any readjustments as long as the “Dynamic Lights OFF” is enabled.
  6. When the lights are turned off manually (or by another automation/scene etc) the binary sensor used as automation trigger is turned off.
  7. The need for recalculating the temperature is no longer needed and the automation can stop.

I might be looking at this from wrong angle - maybe a different automation type is needed to keep recalculating as long as the trigger condition (light) is “ON”.

Thank you for your effort :slight_smile:

@Cregeland

All is good
 sometimes it is hard for me to get my head around what is happening. This layout really helps me understand
 thanks.

1 & 2. All good.
3 & 4. Select dynamic lighting option 3 and the setting you desire.
5. Nice, all is good.
6 & 7. Nice, all is good.

It looks like you got it all sorted. Is it working correctly?

Blacky :smiley:

I think this is what I am looking for I just misunderstood the options. I was thinking this option was for automatically turning the lights on based on the ambient conditions getting darker.

@mdb17

This condition must be met for the trigger to turn the light ON. However, if the light is OFF and the trigger is ON, once the condition is met, the light will turn ON.

There’s a lot of logic in the blueprint, so it can be tricky to understand everything.

Blacky :smiley:

1 Like

Thanks Blacky. I think I understand the concept. Once again thank you for your contribution​:+1::smiley:

1 Like

Hi Blacky, I saw the following error in the HA log today:

Error evaluating condition in 'Lichtsteuerung': In 'condition' (item 4 of 6): In 'or' (item 3 of 12): In 'template' condition: ValueError: Template error: int got invalid input 'unavailable' when rendering template '{{ (include_ambient == 'ambient_enabled') and (states[ambient_light_sensor].state | int < ambient_light_value | int) }}' but no default was specified In 'or' (item 4 of 12): In 'template' condition: ValueError: Template error: int got invalid input 'unavailable' when rendering template '{{ (include_ambient == 'ambient_enabled') and (states[ambient_light_sensor].state | int < ambient_light_high_value | int) and (expand(light_switch.entity_id) | selectattr('state', '==', 'on') | list | count > 0) }}' but no default was specified In 'or' (item 5 of 12): In 'template' condition: ValueError: Template error: int got invalid input 'unavailable' when rendering template '{{ (include_ambient == 'ambient_enabled') and (states[ambient_light_sensor].state | int < ambient_light_high_value | int) and ((include_night_lights == 'night_lights_enabled') and (expand(night_lights.entity_id) | selectattr('state', '==', 'on') | list | count > 0)) }}' but no default was specified

The whole thing was after a reboot and the entity logically not yet available.
But can you tell me where in the script I have to set default (0)?

The blueprint is going fantastic and I don’t have a problem with it :wink:

Big Thanks

@clipse

Hi Marco,

Can you please provide us your YAML of the automation? This YAML code are the settings you have selected in the automation so I can help. To do this go into your automation, top right 3 dots, Edit in YAML, copy all the code, come back to the forum and in your reply at the top tool bar click on “</>” and paste code in there.

This way I can try and find the bug and squash it for everyone.

Blacky :smiley:

I got an error. I still have to see if I can replicate it. I had the bathroom lights setup for day and night, and the night mode is selected by my phone sleep app. The result is that the LED lights got stuck at red (night color), the ceiling lights came on (which is only day mode) and they stuck on, never turning off.

Stopped because an error was encountered at 7 September 2024 at 08:55:46 (runtime: 184.93 seconds)

I downloaded the trace, but dont want to copy it here, what else I can help with?

@rbhun

It can be many things. I don’t get them here so probably not the blueprint and may be communications (e.g., for cloud services), network interruptions might have caused it to fail. It could have exceeded memory or CPU limits, or device not communicating. Try reboot your HA and keep an eye on it.

Blacky :smiley:

Apologies if this is covered elsewhere in the thread. I’m wondering what the best way to work with multiple scenes is?

What I want to do is have buttons on the wall to set the “mode” for the room and then depending on the mode have the lights behave differently. Some ways I had thought to achieve this were:

-Have a script that checks that variable and sets the scene appropriately and put that script in the “Lights - Switches - Scenes - Scripts *” setting in the automation.

-Have duplicate, very similar, automations and have the buttons on the wall enable and disable them when pressed

I think I have seen a problem with the script approach in that if the automation has already been triggered and the variable that the script checks is changed, then even triggering the automation doesn’t cause the script to re-run as the toggle helper I guess is checked before firing the script?

Hope that makes sense!

Thanks
Stephen

@sgrobertson

It all depends on how many options you would like. If it is just 2 options then you can use the night lights and the night light state condition.

Or

You can create multiple scenes and set up an automation for each one. To manage scene activation, use bypass option 3 and add a helper for each scene. For example, if you have 3 scenes, create 3 helpers. When one helper is turned OFF (to activate its corresponding scene), the other two helpers should automatically turn ON. You can achieve this behavior through custom automations that manage the state of the helpers. I hope this explanation is clear.

Blacky :smiley:

Thanks, yes that does make sense. I’ve started trying the second option and have it mostly working.

I’ve found that if I update the scene helper(s) while the lights are on then it does switch to the correct scene. But I need to manually turn off the “Scenes & Scripts - Toggle Helper” for the inactive automation otherwise I can’t go back to the previous scheme. That makes sense I guess as tha automation I presume uses that helper to tell that it has already set the scene so doesn’t need to do anything.

I just wasn’t sure if changing those helpers outside of the automation would be the wrong thing to do?

Thanks for your help and such a speedy reply!
Stephen

@sgrobertson

What you can try doing is having the scene turn OFF the other scene helpers for you so you don’t have to manually turn it OFF :wink:

Blacky :smiley: