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

Hi All,

First of all, thanks in advance for looking at my query,

Having real problems getting this to work, I stripped my configuration to just the basics.

I have Tested and both scripts work, ie turn on and off the light respectively.

Can anyone spot what I’m doing wrong here?

alias: Test bedroom sensor
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.motion_sensor_motion
    light_switch:
      entity_id: script.bedroom_light_on
    boolean_scenes_scripts: input_boolean.bedroom_light_toggle
    end_scenes:
      - script.bedroom_light_off

Thanks again for your help

@thegoodsuk

Welcome to the community.

All looks good. I have no idea of your scripts though.

Maybe just try and use the light or switch.

Blacky :grinning:

Hi @Blacky
Thank you for this blueprint, it’s made it pretty streamlined to define / tweak motion-sensor lights.

I’ve setup Bypass entities to represent physical light switches in my house, so that when someone flips the switch it turns the Bypass entity ON for a few sec. I use the Bypass entity under ā€œKeep the light’s current stateā€ and set the Bypass auto-OFF to 15min.

Unfortunately, somewhere between versions 7.1 and 8.0 of the blueprint , this mechanism is now broken. :frowning:
The problem: When the Bypass entity turns off – the lights turn off.
:warning: This is despite using the third Bypass option, ā€œKeep the light’s current stateā€.
I don’t have any other time/sun/device/nightlight parameter setup, only the Bypass.

Some investigations:

  • The light’s history graph shows it was indeed the automation that turned it off
  • The automation’s trace shows it was triggered by the Bypass entity switching back to the OFF state
  • I can even cause this behavior by manually toggling the Bypass entity. Interestingly, turning the entity ON does nothing (does not turn the light on), but turning if OFF definitely turns the light off.

Why is it turning the light off, if it’s under the ā€œKeep current stateā€ option?
Any help is appreciated :slight_smile:

@anonforumposter

When you turn the bypass ON, the 3 options only perform the action then, not when you turn it OFF.

When you turn it OFF, if the trigger isn’t active, it will turn the light OFF as expected. You can use the Bypass - Time Delay so when you turn OFF the bypass and the trigger is clear, the automation will wait for the delay before turning the light OFF. If the automation is triggered during this delay, it will override and keep the light ON.

This prevents you from standing in the dark when turning the bypass OFF.

Blacky :grinning:

Thanks for the super-quick reply :slight_smile:

That’s not the expected behavior.

  • The Bypass entity is just a helper toggle input_boolean.bypass_entity. It is not connected to the actual light.
  • I have an automation that listens to the physical light switch’s event.button_pressed event, and turns the Bypass toggle on. There’s nothing listening in the other direction.
  • So the expected behavior when manually toggling the Bypass helper entity, would be to not affect anything.

I believe the automation is also triggered when the Bypass turns OFF.
See the following Trace:


I hope this helps to try to figure out where the problem is.
Thank you

Hello @Blacky

I confirm that it is an awesome script, good job!

I’m trying to set up a configuration that puts me in the same situation as @anonforumposter.
However, there might be a better way to do it, so I explain what I’ve done.
I have three lights that turn on white via a motion trigger when the outside brightness is low.
But, if I decide to change the color of my three lights to red, for example, they turn white again at the next motion.
So, I tried to create a bypass using a switch template based on whether the lights were already on or not.
The problem is that as soon as the lights turn off, my switch also turns off, but it also triggers the automation, which then turns my lights back on as if the automation no longer checks the conditions for turning on, such as motion and outside brightness.

Any ideas ?

Hello everyone,
I now use the automation in various rooms, entrance area and stairwell. A really useful and good solution that has thought of pretty much everything. At this point, a big thank you for that!

Unfortunately, I noticed a few inconsistencies in the last few days (actually since the start of the setup for the affected rooms/zones). The light is sometimes (maybe 2-3 times a day/evening) not switched off properly according to the set timer.

I noticed the following behavior:
In the log of the entities, I can see how the light is switched on and off again by the automation. In the dashboard or when viewing the entity, it is also shown as switched off - but in fact it is still on. If I now operate the virtual switch, nothing physically changes in the light, but in HA it is then shown as switched on again and can then be switched off manually again. So far so good.
If the light is still switched on, even though the automation should have switched it off, and I enter the area again and thus trigger the motion detectors again, the automation says the light is switched on, but it remains ā€œoffā€ in the entity view. Pretty confusing.
On top of that, I also set up ambience, with the option that the lights to be switched on affect my lighting intensity. In the case that the light stays on again, HA thinks it is off, the motion detectors are triggered and the automation does its thing, the motion detectors report a high luminosity and the automation should not switch the light on - but it does it anyway. I hope you have been able to follow me up to this point :smiley:

Could it perhaps be related to the fact that I have grouped the light (several sources) in the relevant areas as a group in the helpers and selected these groups as an entity in the respective automation? I come to this because in the other rooms, where I actually added the individual lamps as an entity, these problems have not occurred so far.

A quick word about my system:
I almost exclusively use Zigbee devices (for the devices in question, that’s 100%). Integrated into HA via Z2M. The Zigbee network seems very stable and reliable to me, at least when I think about the other daily operations of lights, sensors and heating, etc.

If I can give you any other important information, please let me know.

Best regards
Luppes

Update - I do have night light glow enabled with the newly added PIR sensor, so that must be how the recessed lights are turning on. What’s unclear is why there are no time constraints on night glow. It seems to be running in parallel to the primary light in Sensor Light which I have enabled from 10am to 7pm.
TLDR - what conditions inhibit night glow operations?

(original)I’ve taken a different approach for my kitchen recessed lighting (no dynamic lighting) that works for me from 10am to 7pm.

Now trying to use night light option from 7pm to 10am to turn on a different light (pendants) using a different PIR sensor and seeing something odd.

At 11am (when night lights should be off) the PIR sensor is still turning on the recessed lighting.

Pasting the configuration below, seems odd to me that this should be happening. Still not effective at following the traces yet, but maybe this is an easier way to debug.

TLDR - adding night lights with a different light and different PIR sensor seems to be affecting the primary light in Sensor Light outside of the time it’s configured to operate.

id: '1740070715912'
alias: Kitchen Recessed Lights - Sensor Light
description: ''
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.everything_presence_lite_f03ea0_occupancy
    light_switch:
      entity_id: light.kitchen_main_lights
    include_dynamic_lighting: disable_dynamic_lighting
    dynamic_lighting_lux_sensor: sensor.home_pws_solar_rad_lx
    dynamic_lighting_max_lux: 40000
    dynamic_lighting_min_lux: 10
    dynamic_lighting_max_brightness: 60
    dynamic_lighting_min_brightness: 1
    include_light_control:
      - use_brightness
      - use_transition
    light_brightness: 50
    light_transition_off: 6
    include_time: time_enabled
    after_time: '10:00:00'
    before_time: '19:00:00'
    light_transition_on: 3
    night_lights_conditions:
      - entity_state_enabled
      - time_enabled
      - sun_enabled
    night_lights_after_time: '19:00:00'
    night_lights_before_time: '10:00:00'
    night_lights:
      entity_id: light.kitchen_island_pendants
    include_night_light_control:
      - use_brightness
      - use_transition
    night_light_transition_on: 2
    night_light_transition_off: 10
    night_lights_sun_elevation: -4
    night_time_delay: 0
    night_glow_light_brightness: 3
    include_night_glow: night_glow_enabled
    night_glow_lights:
      entity_id: light.kitchen_main_lights
    include_night_lights: night_lights_enabled
    night_lights_entity_state:
      - binary_sensor.everything_presence_one_9f80a4_pir

@anonforumposter

When you turn the bypass ON, the automation will execute the selected option and then be disabled.

When you turn the bypass OFF, the automation enters auto mode, where it checks both the light and the trigger:

  • If the light is ON and the trigger is OFF, the automation will turn the light OFF.
  • If the light is ON and the trigger is ON, the automation will wait until the trigger turns OFF before turning the light OFF.
  • If the light is OFF and the trigger is ON, the automation will turn the lighs ON.

Yes that is correct… it will look to see what is happening and then react as above.

Blacky :grinning:

@Rysome

When the automation turns your lights ON, you can adjust their brightness or colour, and they will remain that way until they turn OFF. The next time the automation turns them ON, it will apply the selected light control settings from the blueprint.

If you prefer to keep the current brightness and colour unchanged, simply don’t use the light control options… the automation will then only turn the lights ON and OFF.

Blacky :grinning:

@Luppes

Sounds like communication problems with your lights and the Zigbee network.

Blacky :grinning:

@SoccerTX

  1. You have enabled the Time global condition to only run the automation between 10am to 7pm. The automation will only work between these times. Disable this option because your using night lights.
  2. In night lights your using all 3 night light conditions. So every condition must be true for night lights to work. Normally you will just pick one night light condition. Try just using the time condition only so night lights will be active between 7pm till 10am.
  3. Nigh glow only is active in night lights.
  4. In night light control I have also selected If lights are ON, adjust the lights when crossing over.

Try this YAML below to see how it works.

id: '1740070715912'
alias: Kitchen Recessed Lights - Sensor Light
description: ''
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.everything_presence_lite_f03ea0_occupancy
    light_switch:
      entity_id: light.kitchen_main_lights
    include_dynamic_lighting: disable_dynamic_lighting
    dynamic_lighting_lux_sensor: sensor.home_pws_solar_rad_lx
    dynamic_lighting_max_lux: 40000
    dynamic_lighting_min_lux: 10
    dynamic_lighting_max_brightness: 60
    dynamic_lighting_min_brightness: 1
    include_light_control:
      - use_brightness
      - use_transition
    light_brightness: 50
    light_transition_off: 6
    include_time: time_disabled
    after_time: "10:00:00"
    before_time: "19:00:00"
    light_transition_on: 3
    night_lights_conditions:
      - time_enabled
    night_lights_after_time: "19:00:00"
    night_lights_before_time: "10:00:00"
    night_lights:
      entity_id: light.kitchen_island_pendants
    include_night_light_control:
      - use_brightness
      - use_transition
      - if_lights_are_on_adjust_when_crossing_over
    night_light_transition_on: 2
    night_light_transition_off: 10
    night_lights_sun_elevation: -4
    night_time_delay: 0
    night_glow_light_brightness: 3
    include_night_glow: night_glow_enabled
    night_glow_lights:
      entity_id: light.kitchen_main_lights
    include_night_lights: night_lights_enabled
    night_lights_entity_state:
      - binary_sensor.everything_presence_one_9f80a4_pir
    include_night_glow_light_control:
      - use_brightness
      - use_transition
    night_glow_light_transition_off: 3

Blacky :grinning:

1 Like

@Blacky thanks for this comprehensive blueprint. Highly appreciated.
May I ask you, or anyone else, hot to add ā€œtimeā€ to the trigger? I tried this in yaml under trigger but no consequence.
What I’d like to achieve is, that the triggers just fires if the trigger is activated for 1 minute, just as an example. The challenge is, I’d like to get the dinner light just activated if we sit by the table and not if we just passing by.
If anyone could help me, I’d really appreciate.

Thanks

Hi,

I want to automate my office light goes on based on lx value only between (for example) 17.00 PM - 23.30 PM.
However its is not working what am i doing wrong

alias: Sensor Light
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.everything_presence_one_0436d4_pir
    light_switch:
      entity_id: light.hue_ambiance_lamp_1_2
    light_brightness: 50
    dynamic_lighting_max_lux: 10
    dynamic_lighting_min_lux: 30
    dynamic_lighting_max_brightness: 50
    dynamic_lighting_min_brightness: 20
    include_light_control:
      - use_brightness
    include_time: time_enabled
    before_time: "23:30:00"
    after_time: "16:00:00"
    include_dynamic_lighting: enable_lux_controled_brightness

Awesome blueprint, thank you.

Question: I have read through everything, and have set up a good working scenario. However, when my lights are triggered and turn on, and then I manually turn one of the bulbs off, I would expect the automation to periodically check the state of the lights and re-run the automation if one of the lights is not on, WHILE the sensor group state is ā€œtrueā€. That is not happening. Have not seen an optional setting to do that either.

It will basically sit there until the sensors are all ā€œfalseā€ and turn the lights off, and then again when one of the sensors is ā€œtrueā€ it will turn all the lights on again, including the one previously manually turned off.

Am I missing something? Any help is appreciated.

Thanks.

@Blacky

I had this blueprint working before and for some reason messed with it. Now I can’t get any Lux enabled dynamic things to work (lights just don’t change state with this enabled, straight motion activation works fine) and am seeing this error in my traces. How can I help you help me?

Error: TypeError: unhashable type: ā€˜list’

Hi Blacky,
thanks for your support!

I applied the BP to my kitchen light and the logic works so far.
But one more question: the kitchen light consists of 4 lights grouped to ā€œArbeitsplatteā€. In ā€œnight glowā€ the group shall be on, same when motion is detected (as ā€œnight lightā€) - but in the night only 1 light will be turned on (Arbeitsplatte4).
The logic works so far, but when the night glow gets activated at the evening or morning without motion detected, the group turn on excepting the one light used for night light. once motion is detected also the remaining light turns on, but the color is not always in synch with the group… could you give an idea how to fix it?

description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    include_device_tracker: device_tracker_disabled
    zone: zone.bei_marquardt
    include_night_lights: night_lights_enabled
    night_lights_conditions:
      - entity_state_enabled
    night_lights_entity_state:
      - input_boolean.hass_iobwach
    night_lights:
      entity_id: light.arbeitsplatte
    include_night_light_control:
      - use_brightness
      - use_transition
      - if_lights_are_on_adjust_when_crossing_over
    include_night_glow: night_glow_enabled
    night_glow_lights:
      entity_id: light.arbeitsplatte
    include_night_glow_light_control:
      - use_brightness
      - use_transition
    include_ambient: ambient_disabled
    include_light_control:
      - use_brightness
      - use_transition
    light_switch:
      entity_id:
        - light.arbeitsplatte4
    light_brightness: 10
    night_glow_light_brightness: 20
    night_light_brightness: 98
    motion_trigger:
      - binary_sensor.bm_kuche_occupancy
    time_delay: 2
    night_time_delay: 2
    include_bypass:
      - bypass_enabled_turn_off
    motion_bypass_lights_off:
      - binary_sensor.zuhausetemplate
      - binary_sensor.sensortemplate_daemmerung
    ambient_light_sensor: sensor.lichtsensor_beleuchtungsstarke
    include_sun: sun_disabled
    include_dynamic_lighting: enable_sun_elevation_colour_lux_brightness_inv
    dynamic_lighting_lux_sensor: sensor.lichtsensor_beleuchtungsstarke
    ambient_light_value: 120
    ambient_light_high_value: 180
    dynamic_lighting_min_brightness: 10
    dynamic_lighting_min_colour_temp: 2300
    dynamic_lighting_max_colour_temp: 5000
    bypass_time_delay: 1
    dynamic_lighting_max_brightness: 60

type or paste code here

Hi Becky,

As always. This makes life so much easier. Thank you for your work!
I have a question. My living room has quite a weird layout which results in me wanting to average lux value for the ambient part of the BP.
I have it via the helpers in HA (median. So sort off) but I can’t select that helper as it doesn’t have a lux entity. How can I still select that helper?

I think you have to use the ambient feature. Dynamic lighting is for the light itself being dynamic

This blueprint is fantastic! I’m replacing a lot of Node-Red stuff with this.

Question: why is the minimum transition time 0.5 seconds? I’d like to use a shorter time (0.2s) because that feels more instant than 0.5s and more pleasant than 0s