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

@clowgg

I started developing an add on blueprint about 4 months ago… maybe I should revisit it as it has been put on the back burner. I think it may help you but it is very raw and not finished. Maybe I will PM you and we can work through this together if your keen to do some testing.

Blacky :smiley:

@voydz

Hi Felix

Option 2 & 4 are turn On actions but are doing 2 different things :thinking:

This is very complicated as there are so many scenarios. Right now I can’t see it working. I will look into it but…

Your general question is one I have on my list…I don’t like to promises anything… I have it in my thoughts… thanks for all your suggestions and input.

Blacky :smiley:

Yes of course, happy to do some testing!

@Wilko

Nice one…

Can you please reboot your HA not restart but a reboot. Then try again.

Go to settings / system / click top right power button and you will see this.

86

Just to give you some understanding. I know what the logs are and what it relates to. I simple terms HA added a new way for us to write code and gave us some time to do so. I waited 3 months after the added the code to give everyone time to update. HA did this about + 6 months ago so it is not new. If we didn’t do this the blueprint would probably be broken now. Because you have updated I am trying to get your HA to see this code by rebooting it. Hopefully it will work :crossed_fingers: on your system. Just thought I would give you some info so you can be assured that it is within your system and not the blueprint.

I am more than happy to help in any way. Please let us know if this resolved your problem.

Blacky :smiley:

Awesome, thank you.

May I follow up with a recent question I had in mind after testing a bit more. What is the behavior of this blueprint if a light included in the lights to trigger is already on. Does the automation stop there or does it just overwrite everything with the “turn on” setting.

Thank you very much.
best regards

@Justdigit

Hi Justin,

That is not good lets try and resolve this.

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

Blacky :smiley:

@harryfine

Hi Harry, Everything you said is perfect and I looks like you are doing everything correct :+1:

Would you be so kind to 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.

Blacky :smiley:

Perfect.

Add your lights in as entities and select your dynamic lighting options. Then in “Scenes - Scripts To Turn OFF” add a scene with your lights at 10%, now they will turn off at 10%. Then set your sun conditions the same as the other automation and you should be good to go.

Blacky :smiley:

Nice one I will PM you soon and explain it all.

Blacky :smiley:

@voydz

If the blueprint triggers the light ON and if it keeps getting triggered and the light is ON it will stay ON. You can adjust the light brightness etc once it is ON and it will stay that way until the light goes OFF. If the automation is triggered ON again then it start all over again. This is how it is designed to work or you will never be able to change your lights brightness, etc once it is ON.

Blacky :smiley:

This is just brilliant. This means my “overwrite” use-case (4th option) is implicitly handled by your automation. That makes thing a lot easier for now.

To achieve use-case “turn-on by switch” (2nd option) I use your automation with delayed bypass OFF after i.e. 60min. So its only up to me, to handle the “turn-off by switch with cooldown” (3rd option). I do this with the help of a script I wrote. I will test the next days and give feedback.

Also, to mitigate issues with scrambled “input_booleans” for turn on/off bypasses, I temporarily created an automation that resets everything every night.

@voydz

Nice one Felix, your getting the hang of the blueprint… thanks for your feedback. It is quite powerful, once you know how to make it work. Fully understand it is a lot to take in on first glance.

Blacky :smiley:

Thanks for taking a look blacky,

alias: Front Hall Light on with Motion & Lumens
description: Front Hall Light on with Motion & Lumens
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.front_hall_motion_and_occupancy_sensor_for_light
    light_switch:
      entity_id: light.front_door_dimmer_switch_z_wave
    time_delay: 1.5
    include_light_control:
      - use_brightness
      - use_transition
    light_brightness: 80
    light_transition_on: 1
    light_transition_off: 1
    include_night_lights: night_lights_disabled
    include_night_light_control:
      - use_brightness
      - use_transition
    night_light_transition_on: 1.5
    night_light_transition_off: 1.5
    night_lights_conditions: []
    night_time_delay: 3
    include_sun: sun_disabled
    night_lights_sun_elevation: -3
    include_ambient: ambient_enabled
    ambient_light_sensor: sensor.front_hall_motion_and_presence_sensor_illuminance
    ambient_light_options: ambient_light_option_enabled
    ambient_light_value: 15
    include_bypass:
      - bypass_enabled
      - bypass_enabled_turn_off
    include_time: time_disabled
    night_light_brightness: 30
    sun_elevation: -1.5
    motion_bypass:
      - input_boolean.day_night_mode
    motion_bypass_lights_stop:
      - input_boolean.day_night_mode
    after_time: "08:00:00"
    before_time: "20:30:00"
    sun_elevation_rising: -4
    ambient_light_high_value: 30

@harryfine

Thanks Harry, I can see some old YAML in there relating to the by-pass that will probably be the cause.

I could walk you through it but it is probably easer to just delete this automation and create a new automation as it will also clean up all your disable options and make your YAML nice and clean to read.

Best way to do this is first disable this automation (3 dots to the right of the automation and select disable). Then create a new automation and if needed you can always refer back to your disabled automation if you need to check any settings. Once you have your new one up and running you then can delete the old disabled automation.

Hope this make sense. Let us know how you go.

Blacky :smiley:

Thx Blacky

1 Like

@Blacky I want to have a 2 different off states for for time, could you explain how I can achieve this

atm I have just 1 set as follows

alias: Back Garden Sensor Light
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.back_garden_motion_sensor_occupancy
    light_switch:
      entity_id: scene.back_garden_sesnor_light
    include_sun: sun_enabled
    sun_elevation: 0
    ambient_light_sensor: sensor.back_garden_motion_sensor_illuminance_lux
    end_scenes:
      - scene.back_garden_sesnor_light_off
    time_delay: 2

I would like to change this so instead of the light turning off, it would just drop to 5%, I was planning of doing this by just adjusting the scene to 5% instead of off, But I would like to add a 2nd time off scene for between 23:00 to sun up, so that would turn off the light after no motion.

so

the light will turn on to 5% by a evening automation

for this automation
0 elevation to 23:00, on motion go to 100%, done by scene Back Garden Sensor Light, then on no motion go back to 5% done by scene Back Garden Sensor Light (Off)

the light will turn off by a good Night automation

23:00 to 0 elevation, on motion go to 100%, done by scene Back Garden Sensor Light, then on no motion go back to off

how can I achieve this last part ?

My post earlier today asks almost the same.

I am testing with a script for the off action, the script handles the wanted “off” state.

Hi @Blacky

you support and the response times are incredible. Thanks for that. :slight_smile:

Regarding your post I am replying to. Is this behavior true for Scenes and Scripts in “Lights - Switches - Scenes - Scripts”?

I did a little testing today and it seemed like the scenes and scripts are triggered over and over even if the light did not turn off before motion was detected.

best regards

Hi @Blacky, thank you so much for this fantastic blueprint.
We really like the dynamic light control :smile: .

However, for us the control with time is preffered over the control of sun elevation (at least for now in winter :wink: ).

So I’ve adapted the brightness calculation in your script. I’ve no clue of programming, but for us this works (after adding the time to the blueprint and adapting you brightness calculation). Just in case someone can make use of it, here the adapted code snippet

{# Convert current time to total minutes since midnight #}
{% set current_time = now().time() %}
{% set current_minutes = current_time.hour * 60 + current_time.minute %}

{# Convert start and end times to total minutes since midnight #}
{% set morning_start = strptime(dynamic_lighting_morning_start_time, '%H:%M:%S') %}
{% set morning_start_minutes = morning_start.hour * 60 + morning_start.minute %}
{% set morning_end = strptime(dynamic_lighting_morning_end_time, '%H:%M:%S') %}
{% set morning_end_minutes = morning_end.hour * 60 + morning_end.minute %}

{% set evening_start = strptime(dynamic_lighting_evening_start_time, '%H:%M:%S') %}
{% set evening_start_minutes = evening_start.hour * 60 + evening_start.minute %}
{% set evening_end = strptime(dynamic_lighting_evening_end_time, '%H:%M:%S') %}
{% set evening_end_minutes = evening_end.hour * 60 + evening_end.minute %}

{# Determine brightness based on current time #}
{% if current_minutes < morning_start_minutes or current_minutes > evening_end_minutes %}
  {% set brightness_value = dynamic_lighting_min_brightness %}
{% elif morning_start_minutes <= current_minutes <= morning_end_minutes %}
  {% set brightness_progress = (current_minutes - morning_start_minutes) / (morning_end_minutes - morning_start_minutes) %}
  {% set brightness_value = (dynamic_lighting_min_brightness + brightness_progress * (dynamic_lighting_max_brightness - dynamic_lighting_min_brightness)) | round(0) %}
{% elif evening_start_minutes <= current_minutes <= evening_end_minutes %}
  {% set brightness_progress = (current_minutes - evening_start_minutes) / (evening_end_minutes - evening_start_minutes) %}
  {% set brightness_value = (dynamic_lighting_max_brightness - brightness_progress * (dynamic_lighting_max_brightness - dynamic_lighting_min_brightness)) | round(0) %}
{% else %}
  {% set brightness_value = dynamic_lighting_max_brightness %}
{% endif %}
{{ brightness_value | round(0) }}
1 Like

@andyblac this is the script I am now using as end_scenes action :

alias: Garden lights
sequence:
  - if:
      - condition: or
        conditions:
          - condition: time
            before: "21:30:00"
          - condition: sun
            after: sunset
            after_offset: "-00:30:00"
      - condition: or
        conditions:
          - condition: time
            before: "00:00:00"
            after: "06:30:00"
          - condition: sun
            before: sunrise
            before_offset: "00:30:00"
    then:
      - service: scene.turn_on
        metadata: {}
        target:
          entity_id: scene.garden
    else:
      - service: light.turn_off
        metadata: {}
        data:
          transition: 30
        target:
          entity_id: light.garden
mode: single

1 Like