šŸ’” Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time - Light Control - Device Tracker - Night Lights

@ZzetT

There are a few things.

AI is good but it can get things wrong. If you don’t know and it spits out an answer you think great… thanks… but if you know it is wrong and you say ā€œThat is not right it can do that because of ABCā€ then is says ā€œYes your absolutely right, sorry about thatā€¦ā€ and then spits out the same answer. Not good.

Your using scripts and HA has no idea if the light in ON through the script. This is why we use a toggle helper, it acts like a light so when we run the script to turn ON the light we also turn ON the toggle helper. Now the automation knows the light is ON (through the toggle helper ) … if you manual turn OFF the light and the toggle helper is ON the automation thinks the light is ON. It is not perfect but it is the only way to do this.

So if your light is ON and the toggle helper is OFF the automation thinks the light is OFF because your using scripts. Just think of the toggle helper as your light… if it is OFF the the light is OFF, it it is ON then the light is on. That is how the automation see it.

What you can do is add one of your lights used in the script as an entity as well as your script (the automation will run in the correct sequence ), don’t use any light control options and let the script do the work. Then the automation can see the light is ON.

Blacky :grinning:

Hi guys!
First of all, thanks for the excellent automation! I also hope you’ll move the file from Gist to a GitLab/GitHub repository, to simplify version tracker and changes. :wink:

I have a door open sensor and it fires events as Opened → Closed, and another mmWave sensors, which fires occupancy events as Cleared → Detected. Is it possible somehow to setup triggers events not for OFF → ON changes only?

@Murgot

Welcome to the community :wave:

You would use a different blueprint :high_brightness: Smart Light. I will make an automation so you can update the entities.

I will move this to the correct blueprint to stay on topic.

Blacky :grinning:

@AJKEnter

I going to move the conversation to the correct blueprint.

Blacky :grinning:

@Blacky Could you please help me? This automation doesn’t trigger my lights. I tried my best.

@jose1711

I know were it could be coming from in the code but I trying to get more information. I don’t just want to change things on the fly as it can effect other users.

I see your using a group for your lights :thinking:. What if you just enter in the light entities rather than the group? I can give you code to try but…

Let us know if removing the group and entering the entities works.

Blacky :grinning:

@hsm

Could you share the YAML code for your automation settings? This will allow me to better understand your settings and help troubleshoot the issue.

To do this:

  1. Open your automation.
  2. Click the three dots (ā‹®) in the top right corner.
  3. Select Edit in YAML.
  4. Copy the entire YAML code.
  5. Return to the forum and, in your reply, click the </> button in the toolbar.
  6. Paste your YAML inside the code block.

This ensures the formatting stays correct and makes it easier to analyze.

Blacky :grinning:

alias: Wiz automation with brightness adjustment
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.hue_motion_sensor_2_motion
    light_switch:
      entity_id:
        - light.wiz_linear
        - light.wiz_linear_2
    time_delay: 1
    include_light_control:
      - use_brightness
    light_transition_on: 3
    light_transition_off: 6
    include_light_colour_control: use_colour_temperature
    include_dynamic_lighting: disable_dynamic_lighting
    dynamic_lighting_lux_sensor: sensor.hue_motion_sensor_2_illuminance
    dynamic_lighting_min_brightness: 6
    dynamic_lighting_heartbeat: 4
    include_ambient: ambient_enabled
    ambient_light_sensor: sensor.hue_motion_sensor_2_illuminance
    include_night_lights: night_lights_enabled
    night_lights_conditions:
      - time_enabled
    night_lights_after_time: "00:22:00"
    night_lights_before_time: "00:06:50"
    night_lights:
      entity_id:
        - light.wiz_linear
        - light.wiz_linear_2
    night_time_delay: 1
    include_night_light_control:
      - use_brightness
      - use_transition
    include_night_light_colour_control: use_colour_temperature
    night_light_colour_temperature: 3600
    night_light_rgb_colour:
      - 242
      - 232
      - 196
    ambient_light_value: 120
    include_time: time_enabled
    after_time: "00:07:00"
    before_time: "00:22:00"
    ambient_light_high_value: 550

@YusDyr

I have thought about it but I just want to keep it simple.

You will need to do a template binary sensor and invert it. Then use this as your trigger.

To create a Template binary sensor, follow these steps:

  1. Navigate to Settings > Device & Services > Helpers tab at the top.
  2. Click the Create helper button.
  3. Select Template and then choose Template a binary sensor.

Next, provide a Name that you like and Device class. If applicable, you can link this template to an existing device so it appears under that device’s details but you probably wont do this.

In the State template field, add the code below, replacing binary_sensor.your_inverted_sensor_here with your entity ID you would like to invert.

{{ is_state('binary_sensor.your_inverted_sensor_here', 'off') }}

Blacky :grinning:

1 Like

@hsm

Thanks for your YAML.

It looks like your doing some testing.

Your Time is global so the automation will only work between 12:07 am till 12:22 am. Disable this option.

Your are stoped because your LUX sensor is higher than 120 lux. It will only turn ON when your lux sensor is below 120 lux. You could disable this option to and see if the lights turn ON and the enable it, then test it.

Note your night light time condition is from 12:22am till the next day at 12:06am. You will need to look at that to.

Hope this helps you.

Blacky :grinning:

Thank you Blacky,
You make a great job. :+1:

Thank you @Blacky. I have couple of questions,

  1. If I want to control 4 lights in same zone in a group for example, 2 lights will turn on between lx 200 and 700 and all 4 between lx 30 to 200, can we do that using your blueprint? Also preferably, 2 with different color temperatures.
  2. Clock takes time from selected zone for home assistant or from anywhere else?

Impressive work. I feel like what I want it quite simple, but I’m just confused on how to set it up.

I have a seperate automation handling the various lights (canned ceiling lights, various LEDs signs/strips, smart plugs, etc) in a specific room via one of those 4 button switches. So I have like 12 different scenes being triggered based on the button they press. What I was wanting to setup with this is basically If no motion or presence is detected then trigger the scene to turn off all the lights.

Currently on the blueprint I can only figure out how to achieve the opposite, to trigger a scene when motion/presence IS detected. But I want to do the opposite, I don’t care how the different lights were turned on, IF it doesn’t sense anyone in the room for X amount of time, then turn the lights off.

I would like to create the same graphs that you show in the ā€œSun Elevation Settingsā€ section of the FAQ. In the second image you say this is how it looks in a sensor card, but I cannot for the life of me figure out how to recreate the graph on my own dashboard using the Sensor card. Would you mind providing a bit more detail on how that graph is created? I am on the most recent version of HA (15.2 I believe).

@Blacky Thank you, I’ve replaced the group helper with a list of entities.

Now I get two kinds of errors: Zigbee delivery failed (when the lights are turned off manually using a switch) and this one:

2025-04-03 07:46:00.466 ERROR (MainThread) [homeassistant.components.automation.automaticke_svetla_spalna_den_2] AutomatickƩ  
svetlÔ spÔlňa deň (2): Choose at step 1: default: Parallel actions for dynamic lighting and normal lights: parallel 1: CC
hoose at step 7: 5 - Dynamic Lighting - Sun Elevation Lighting - Brightness Inverted: Error executing script. Error rendering template for repeat at pos 1: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'brightness'

There’s a chance that there’s a relationship between the two (unable to read brightness if the light does not communicate). Would it be possible to not raise an error for specific automations?

Hello everyone! :grinning:
My yaml code that I paste into the schema in automation looks like below, but unfortunately it doesn’t work. When I enter the user interface, the ā€œtriggerā€ field is empty. Could I ask for advice? What am I doing wrong?

alias: Outdoor lighting - front door
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    include_sun:
      - sun_falling
      - sun_rising
    light_switch:
      entity_id: light.a60_clear_11
    include_light_control:
      - use_brightness
      - use_transition
    light_transition_off: 5
    light_brightness: 20
    include_night_lights: night_lights_enabled
    night_lights_conditions:
      - entity_state_enabled
    night_lights_entity_state:
      - binary_sensor.dzwonek_do_drzwi_osoba
    night_lights:
      entity_id: light.a60_clear_11
    include_night_light_control:
      - if_lights_are_on_adjust_when_crossing_over
      - use_delay
      - use_brightness
      - use_transition
    night_light_brightness: 100
    cross_over_time_delay: 2
    night_light_transition_off: 5
    motion_trigger:
      - binary_sensor.dzwonek_do_drzwi_osoba

@hsm

  1. You will need to have 2 automations. It can be done with the blueprint but because your asking for the lights to turn ON or be able to turn ON at different lux levels then you will need to create 2 automations using the blueprint. You then can select the different colour temps.
  2. This question I don’t understand.

Blacky :grinning:

@yourfavoriteweapon

Maybe try this blueprint :magic_wand: Manual light. This way you manually turn on your lights and then it will be turned OFF with a motion sensor.

You can turn ON the scenes but in the automation use the light entities.

Blacky :grinning:

1 Like

@stuckupfool

Welcome to the community.

This is a bit tricky as you need to create template sensors. If you like PM me with your YAML of your automation and I can walk you through it.

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.

Blacky :grinning:

@jose1711

This error is saying you have no brightness attribute in your lights.

Zigbee recently had an update that caused issues for many users. I don’t use Zigbee myself, but I recommend checking the forums for details on the update and its impact on entities.

In Home Assistant, go to Developer Tools and inspect your lights. Check the entity attributes to see if brightness is still present. Some users have resolved issues by removing and re-adding their devices, but before doing that, search the forums to see if there’s a better solution. The goal is to ensure the brightness attribute is available in your light entity.

Blacky :grinning: