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

Hi @Blacky, No this isn’t the ‘fault’ of the automation its due to the CCTV seeing the sudden change between the light being on and then turning off, and classifying that as motion. To work around that (given I kept on getting errors trying to add in a delay so it didn’t loop) I ended up just setting it to use a 15sec transition on the light, so it fades out and the CCTV doesn’t see this as motion.

1 Like

We are thinking along the same lines:

I created the following template sensor and added it as the ambient light sensor:

    #### Laundry Lux Sensor
  - name: Laundry Lux
    state_class: measurement
    unit_of_measurement: lx
    device_class: illuminance
    unique_id: 7d92b7b3-34e3-4be9-8673-3a26934a51ff 
    state: >
      {% set elevation = state_attr('sun.sun', 'elevation') %}
      {% set lux = states('sensor.laundry_room_motion_illuminance_lux') %}
      {% if lux == 'unavailable' %}
      0
      {% elif elevation < 5 %}
      1
      {% else %}
      {{ lux }}
      {% endif %}

Hopefully this will keep us from ever being completely in the dark, no matter what the sensor is doing!!

2 Likes

Hi @jbhobson

Nice one thanks for sharing this with the community… that is really nice to know. Thank you :+1:

Blacky :smiley:

Hi again,

Thank you for the quick response!

I tried what you said and while it did not turn off, I noticed in the trace it turns off and back on in the same second:

Triggered by the state of binary_sensor.dining_hall_motion_occupancy at May 18, 2024 at 3:48:23 PM
Test Test if any of 22 conditions matches
Test Test if any of 9 conditions matches
Test Test if any of 5 conditions matches
Test Test if any of 12 conditions matches
Test Test if any of 3 conditions matches
Test Test if any of 4 conditions matches
Choose: Default action executed
2 seconds later
(light.dining_hall_1) turned on
(light.dining_hall) turned on
(light.dining_hall_2) turned on
1 second later
(light.dining_hall_3) turned on
3 minutes later
(light.dining_hall_5) turned off
(light.dining_hall_1) turned off
(light.dining_hall_2) turned off
(light.dining_hall_3) turned off
(light.dining_hall_4) turned off
(light.dining_hall) turned off
(light.dining_hall_5) turned on
(light.dining_hall) turned on
(light.dining_hall_2) turned on
(light.dining_hall_3) turned on
(light.dining_hall_4) turned on
(light.dining_hall_1) turned on
Finished at May 18, 2024 at 4:02:23 PM (runtime: 840.17 seconds)

The runtime is very long, considering I set it for 0 timeout, so something weird is happening.

Then I tried to turn off dynamic lighting on same automation and test again, which made it turn off correctly as seen in the trace:

Triggered by the state of binary_sensor.dining_hall_motion_occupancy at May 18, 2024 at 4:03:29 PM
Test Test if any of 22 conditions matches
Test Test if any of 9 conditions matches
Test Test if any of 5 conditions matches
Test Test if any of 12 conditions matches
Test Test if any of 3 conditions matches
Test Test if any of 4 conditions matches
Choose: Default action executed
(light.dining_hall_5) turned on
(light.dining_hall) turned on
(light.dining_hall_1) turned on
(light.dining_hall_2) turned on
(light.dining_hall_3) turned on
3 minutes later
(light.dining_hall_3) turned off
(light.dining_hall_1) turned off
(light.dining_hall_2) turned off
(light.dining_hall_4) turned off
Finished at May 18, 2024 at 4:06:29 PM (runtime: 180.03 seconds)

I realize the lamps turning on and off don’t match perfectly, but I think that’s just zigbee acting up. It should be 5 lamps in a group.

It did take about 3 minutes to complete as you said it would so I think this is perfectly good.

Lamps being turned back on is very strange and the traces are probably not too helpful…
Are there ways of getting more debugging info than this?

@xink64

Rather than entering in a group could you try entering them individually as entities.

Blacky :smiley:

I don’t think that’s related as I have other singular lamps with the same problem, as seen here:

Triggered by the state of binary_sensor.vikt_motion_occupancy at May 20, 2024 at 9:23:44 AM
Test Test if any of 22 conditions matches
Test Test if any of 9 conditions matches
Test Test if any of 5 conditions matches
Test Test if any of 12 conditions matches
Test Test if any of 3 conditions matches
Test Test if any of 4 conditions matches
Choose: Default action executed
(light.vikt_light) turned on
4 minutes later
(light.vikt_light) turned off
(light.vikt_light) turned on
Finished at May 20, 2024 at 1:28:27 PM (runtime: 14683.20 seconds)

This room has 4 min timeout and lux based dynamic lighting.
Automation kept going until I went into the room again which explains the 4 hours to finish the task.

I have done a lot of work on dynamic lighting. I thought I was going to release it today but I wasn’t 100% happy with it and made some changes. If I get some time to test it again tomorrow and it checks out then I will release it. If you can wait until this next release is out, then update it and see if it fixes it. Once I release it would you be so kind to let me know it it has been resolved.

Thanks for your patience.

Blacky :smiley:

1 Like

Absolutely, no problem!
I will leave dynamic lighting off for now and when ready I can report back.
Thank you so far, and looking forward :slight_smile:

This blueprint it a bit more technical then a simple ON /OFF…

Yeah, been through the code, and I see that :wink:
It seems as if you filter on the State of the bulb:

selectattr(''state'', ''eq'', ''off'')

And not just once, but it seems to be done in every condition where you check what lights to control… (?):

{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'

Guess that makes it hard to put a ‘ignore off’ state in the BP… :wink:

I have rigged more into LIFX states, and they do indeed keep their State=On all the time while dimming/transitioning, witch I would expect (as they are technically still on… and could be set to transition over minuts…

Sadly, there is no attribute(exposed) telling they are in a transition:

min_color_temp_kelvin: 1500
max_color_temp_kelvin: 9000
min_mireds: 111
max_mireds: 666
effect_list: effect_colorloop, effect_pulse, effect_stop
supported_color_modes: color_temp, hs
effect: null
color_mode: color_temp
brightness: 255
color_temp_kelvin: 2600
color_temp: 384
hs_color: 28.623, 69.017
rgb_color: 255, 162, 79
xy_color: 0.537, 0.388
friendly_name: Gang 01
supported_features: 36

I guess LIFX users choice is:
Set a short dimming time (5 sec or less…) or deal with the frustration of not having the light come back on, when you walk into the area while the dimming is happening… (or grep out the State=On filter on each release… :wink: )

Would be so cool with a “ Force activate lights that are On” setting…

@marook

Thanks for the info Jakob, I thought it would be the light staying ON in HA when transitioning. Most lights show OFF instantly in HA while transitioning to OFF… WLED, Shelly, etc

Nice to know the attribute… I will keep them on file :+1:

I will put this on the list to look into but I think it may be you have to give up one thing to have the other… I could be wrong though.

Maybe if you contact LIFX and let them know… they may fix it so the light shows OFF in HA while transitioning to the OFF state.

Blacky :smiley:

1 Like

New update 6.6

Your lighting experience, your way – take control and customize it to perfection! :bulb::sparkles:

In this update, we focused exclusively on dynamic lighting. Below are the changes we have made. Hope you like it :smiley:

DYNAMIC LIGHTING UPDATE

  • New Feature :new:

    • You now have the option to select “Sun Elevation Lighting - Colour Temp + Brightness Inverted”. It works of the sun elevation but gets brighter at night while still transitioning from cooler lights during the day to warmer lights at night.
  • Performance Enhancements: :rocket:

    • The system now analyses the site conditions and sends data to your light only when required, reducing network traffic.
    • Sun elevation lighting no longer requires to set a heartbeat. It updates light data only when the sun’s elevation changes or under specific retrigger scenarios. This not only reduces network traffic but also smooths light control transitions, resulting in a more visually pleasant experience.
  • Maintenance :toolbox:

    • Code cleanup.
    • Updated descriptions.
    • Dynamic lighting now exclusively targets light entities.
  • Bugs Fixed :bug:

    • Fixed an undefined error in certain scenarios.

If you like this blueprint? Consider hitting the :heart: button in the top post :+1:

If you like my blueprints, and would like to show your support or just say thank you? Click Here :smiling_face_with_three_hearts:

Enjoy

Blacky :grinning:

4 Likes

Hi again,

Pulled 6.6 and it worked right away, thank you so much :slight_smile:
Will set up all the rest of my dynamic lighting automations and report back how it works!

Best,
Martin

1 Like

Hey @Blacky !

I had an idea when it comes to the time settings in this blueprint. Would it be possible to not only allow manual time input such as 00:00:00 but also using globally created time helpers such as input_datetime.namehere?

I suppose this could be useful when using a lot of the sensor light automations for different rooms and one would want to sync the start/end time in all of them at once :slight_smile:

1 Like

@Blacky Been using your BP for ages. But 6.6 seems to have broken my office lights. I have Hue lights, and in particular a Hue LED strip and Hue floor lamp are ‘acting up’. Specifically, brightness seems stuck at about 1%, no matter what I do with 6.6. In 6.5 it was working perfectly.

I created a simplified automation to demonstrate (below). 6.5 was using dynamic lighting, but I even disabled it here. When I run the below YAML the light brightness does not change to 100% when presence is detected.

alias: Office 2
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.presence_fp2_office_desk
    light_switch:
      entity_id: light.hue_office_floor_lamp
    include_dynamic_lighting: disable_dynamic_lighting
    dynamic_lighting_min_colour_temp: 2600
    dynamic_lighting_max_colour_temp: 6000
    light_brightness: 100
    include_light_control:
      - use_brightness
      - use_colour_temperature
      - use_transition

@SimTechLP

Welcome to the community :wave:

I am not 100% sure of your use case but if you would like to use time to turn ON and OFF multiple sensor light automatons you can use a time helper or a schedule helper as the trigger and the automation will run as per your automation settings. If you would like to disable the automation settings then you can use the time helper or schedule helper in the bypass option 1 and it will turn ON and OFF all your automatons regardless of the setting you have. You will just need to include the helpers in every automation you would like to control in either the trigger or bypass.

If this is not what you are looking for then can you explain your exact use case so I can better understand.

Blacky :smiley:

1 Like

@DuckDuck25

Thanks for reaching out as it really helps me make sure it works 100%.

On 6.6, I used your YAML (copy / paste) changed the trigger and the light. I also changed the delay from 5min to 0.1 for testing speed. Everything worked perfectly. I did a test with 100% and 25% brightness and all worked. I then selected option 3 for dynamic lighting and the colour changed and 100% / 25% testes worked perfectly.

From 6.5 to 6.6 the only changes are in dynamic lighting, nothing changed to the code if you don’t use it (Disable Dynamic Lighting) only the code in dynamic lighting was changed. Knowing this it was good that you did a normal test and found that your light is not behaving as that may point you to your light and not the BP.

Not using Dynamic lighting = There could be a few things. If you light is ON at 1% and you trigger the automation the light will stay at 1% even if your setting is at 100%. Try it with the light OFF and trigger it.

For Dynamic lighting I really need to know what option you are using as there is different code for the options.

DL = If you can try testing it with the light OFF and then trigger the automation and see if that works. Also note DL option 3 to 8 use elevation and not heartbeat anymore so nothing will change until the elevation changes. Option 8 uses both elevation and heartbeat. Elevation for light temperature and heartbeat for brightness.

I am keen to look into it if there is a problem.

If you are still finding it to fault can you provide your YAML of the automation that is not working so I can see every setting. Then take particular note of the sun elevation or LUX value at the time of the test as I can run a test just using that elevation and or LUX value. I need to know everything so I can recreate it here. Lights ON, lights OFF, from night light to normal light crossover light ON… anything that happened. Because there are so many scenarios… it has so many options… it is nice to know so I can try and recreate it.

Blacky :smiley:

As always, SUPER appreciate (and I’ve donated) your thorough and long responses. I admire your passion for perfection. You were right about the lights not being off, and thus when I ran the automation the levels did NOT change. I tried from the ‘off’ state, and my test automation worked as expected.

Possibly my troublesome lights were ‘stuck’ at 1%…I’m not sure. I’ll do more testing, but since manually using the Hue app to turn all lights off, my quick test seems like all is well. If you don’t hear further from me, assume it was lightbulb/user error. :slight_smile:

1 Like

Hey, maybe i missed it but is there a way to set a party mode? I’d like to disable all motion lights and keep the lights on during a party.
I think there’s a way to add generic/dynamic conditions to an automation template so that users can add their own bit of logic to disable the motion sensor, though i can’t seem to find it right now. Maybe template conditions? Or that’s not possible while keeping UI compatibility, then maybe just allowing to specify a boolean entity that disables the sensor if it’s true?
Would you consider adding this?

@serialoverflow

Yes you can :partying_face:… it is all there as per your suggestion. The way we do this is through the bypass. I will walk you through the steps. Looks like you know what your doing so it will not be a full detail step by step but if you need more information just ask.

  1. Create a toggle helper (boolean) call it “Party Mode” or anything you like.

  2. In the bypass options, you have 3 options to choose from. Each option is for what happens (action) when you turn ON your “Party Mode” boolean. What would you like the light to do?

  3. Then go through each sensor light automation and choose what bypass option you would like for your lights when you turn ON your “Party Mode” boolean. Select your option and add your “Party Mode” boolean into the correct input (option) you selected. Now all your automatons will disabled (locked) and all your lights will be as per your bypass selection (ON, OFF or Keep current state) when you turn ON your “Party Mode” boolean. You can still manually turn your lights ON or OFF, do anything you like as the automation is disabled (locked).

  4. When the party is over and you turn OFF your “Party Mode” boolean it checks the site conditions and reacts. The “Bypass - Time Delay” is like your “Time Delay” it works like a buffer. So when you turn your “Party Mode” boolean (bypass) OFF and no motion is detected it gives you a bit of time before the actual light will turn OFF so your not standing in the dark. If motion is detected the automation runs as per normal.

  5. If you like you can opt to use the “Bypass Auto OFF Option” so if you forget to turn your “Party Mode” boolean OFF it will do it for you. Since you’re using a single toggle helper for your ‘Party Mode’ boolean (bypass), you only need to select this option once, even if you’re using it in multiple automatons.

Not bad hay. Let me know if this works for you.

PS: This works the same if you have anything else you would like to do. Some example are.

  • Party Mode
  • Guest Mode
  • Sleep Mode
  • Movie Mode
  • Cleaning Mode - Lights ON
  • Upstairs Lights ON
  • Downstairs Lights ON
  • Bedroom Lights OFF
  • Smoke Alarm “Alarm” - Lights ON
  • Alarm System “Alarm” - Lights ON
  • Etc

Blacky :smiley:

2 Likes

Ok I’m struggling. I was using your Blueprint for a couple years. Decided to moved everything to a dedicated machine vs a docker container. Set everything up “fresh”. Don’t remember the version I was on but lots more stuff added. I’m close but missing something and its something stupid I’m sure I’m missing.

I’m a fairly simple use case. Want the motion to trigger a single light during the evening. Just using the time option 7pm-10pm, shutting the light back off after 5 mins of no motion (this portion works). Then starting a 10PM until 7am turn on a different light (actually two lights) and same shut off after 5 mins of no motion. Using just the time option again on night lights. Motion doesn’t seem to trigger the night lights only the evening one. All the entries are entities and did enable the night time time option and set the times. Any help would be appreciated.