šŸ”† Smart Light - Entity - Sun Elevation - Ambient & Time Triggers

@Blacky arghhh, in the UI it flashes red when you insert numbers manually so I thought it was not allowed. thanks a lot.

I Love your blueprints, thanks for sharing.

1 Like

Hey Blacky! Iā€™ve tried the Smart Light blueprint but itā€™s not turning on my light. Iā€™ve tried to keep the blueprint config really simple and can confirm the entity ID is correct for both the light and illuminance. Can also confirm the illuminance right now is 14 which is way under the ambient light value. Can you see what I did wrong? The traces are quite complex so Iā€™m not sure what info I should provide. Iā€™m using ZHA with a Conbee II stick and a Philips Hue lamp + movement sensor which has an illuminance sensor in it. Thanks!

id: '1727692116475'
alias: Light - Living Room
description: ''
use_blueprint:
  path: Blackshome/smart-light.yaml
  input:
    light_switch:
      entity_id: light.living_room
    include_ambient:
      - ambient_low
    ambient_light_value: 90
    ambient_light_value_off: 280
    ambient_light_sensor: sensor.living_room_illuminance

Hi, I have tried to use your blueprint. I just need to set time on/off. I have selected the Trigger time on and off, then In Lights I chose the device I want to be triggered on and off, then in Weekdays the days I want the lights to be switched on and off. I do not have motion sensors or other devices. However, after many attempts the system cannot run the automation and trigger the lights. I am new with HA and still mastering it so, any help is very much appreciated

Here is the YAML:

alias: Strip light
description: ""
use_blueprint:
  path: Blackshome/smart-light.yaml
  input:
    include_light_control:
      - use_transition
      - use_brightness
    include_light_colour_control: use_rgb_colour
    weekday_options:
      - sun
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
    include_entity_state: []
    include_time:
      - time_off
    after_time: 00:25:00
    before_time: 21:30:00
    include_weekdays: weekday_enabled
    night_lights_conditions: []
    night_lights_after_time: 23:51:00
    night_lights_before_time: 23:52:00
    include_night_light_control: []
    include_night_lights: night_lights_enabled
    light_brightness: 30
    light_switch:
      device_id: 06f2dd5abc9285578c370cf62bae65aa
    include_sun: []

@TheAutomator

Iā€™ve tested your YAML, and it worked perfectly. Youā€™ve set a Low Lux Value of 90, so for the automation to trigger, the LUX value must go from above 90 to below 90. When that happens, the light will turn ON.

If youā€™re adjusting the settings in the blueprint and your current LUX value is, say, 80, the automation wonā€™t trigger because it needs to cross from above 90 to below 90.

Also, note that youā€™ve only set it to turn the light ON, so the automation wonā€™t turn it OFF. Iā€™m not sure if thatā€™s what you intended.

Make sure your sensor.living_room_illuminance reports the lux value. It looks like it is correct but I am just checking.

Blacky :smiley:

Ah now I get it! It needs to cross from above 90 to below 90 sounds like the key point to me. I would like it to always respond/trigger on the motion sensor, not only when it crosses. I found this blueprint that does that: Home Assistant Blueprint: Smart Lux Dimmer (github.com)

I have all my lights under your blueprints now so it would be awesome to get this one on it too! I donā€™t know how to fix it thoughā€¦ Is it because of the trigger that has the above/below values defined while the blueprint I shared has them as a condition?

Correct on your other points - I wanted to keep the blueprint as simple as possible to get it to work first which makes troubleshooting easier. Hence the turn off functionality hasnā€™t been implemented yet :slight_smile:

@dsim

Welcome to the community.

Thanks for you YAML.

There are a few things that are not correct.

  1. Trigger Time, you have only enable to use the OFF timeā€¦ you need to enable the ON time. Once yo enable the ON time then your time is ON at 12:25 am and OFF at 9:30 pm. I could be wrong but you may be after ON at 9:30 pm and OFF at 12:25 am if so adjust the times to your liking.

  2. Lights you can use devices only entities can be used. The link I am about to provide will link you to my sensor light blueprint FAQ but is the same as this blueprint and shows you how to expand down your device to entities. Click Here

  3. Weekdays Option because you have selected it to run every day then you donā€™t need to enable this option. Use this option when you want to limit the days it should run. Disable this option.

  4. Night Lights Settings you have enabled night lights but you have no lights selected or a condition to activate night lights. I think you would like this disabled.

I have fixed up you YAML below but you will still need to do expand down you device to entities as shown in item 2 above and make sure your ON and OFF times are correct as shown in item 1 above.

alias: Strip light
description: ""
use_blueprint:
  path: Blackshome/smart-light.yaml
  input:
    include_light_control:
      - use_transition
      - use_brightness
    include_light_colour_control: use_rgb_colour
    include_time:
      - time_off
      - time_on
    after_time: "00:25:00"
    before_time: "21:30:00"
    light_brightness: 30
    light_switch:
      device_id: 06f2dd5abc9285578c370cf62bae65aa

Blacky :smiley:

This is the blueprint you need then. :bulb: Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time . It work with a motion sensor and has the LUX as a condition.

Blacky :smiley:

Thank you so much! It is working now.
I am now testing the transitions.
Thank you for the very nice script and your generosity for sharing.

Thanks, will do! What would be the trigger sensor? Since I donā€™t want it to work based on motion but just based on lux + condition on when Iā€™m home. Time is also not a great trigger because it can rain during the day or I can watch a movie at 1 AM. I use this Sensor Light blueprint for my bathroom/toilet/bedroom/hall and it works really well there! But not sure how this would work.

I am digging more into your script and wanted to know if you can help with the light transition. I see that if I chose RGB I can only set one color and I am not sure what the transition refers to. I thought that I could chose more than one color and the LED would have transitioned the different colors.

The following is the for the Light Control that shows the Red only. Is it possible to add more colors instead of being static in one only?
Thank you so much!

light_transition_on: 2
    light_transition_off: 3
    light_colour_temperature: 3600
    light_rgb_colour:
      - 255
      - 38
      - 0

I am confused.

Blacky :smiley:

Transition is the time it takes to go from OFF to ON and from NO to OFF.

You can only choose one colourā€¦ one for normal lights and another one for night lights.

Blacky :smiley:

Sorry for the confusion! :slight_smile: Let me rephrase. The light should turn on and get its brightness changed based on the illuminance sensor (which is part of my Hue motion sensor). Also when Iā€™m home and when a sensor Awake=on. (Which gets set automatically every day when I get into the living room and gets turned off when I go to sleep at night) Motion is not relevant as Iā€™m often sitting still in the living room.

If I use the Sensor Light blueprint, I need to specify a binary sensor as the trigger sensor which I donā€™t think is relevant because it just needs to use the illumination sensor. And when I use the Smart Light blueprint, itā€™s not turning on my light when illuminance is below the threshold.

Does that make sense? Thanks!

@TheAutomator

So the Smart Light blueprint will do it for you but you will need to create a template binary sensor to use in the bypass. This template binary sensor should be configured as follow

  1. Awake = ON and you are home = Binary sensor OFF

    else binary sensor ON

Then you use this in the bypass option 2 and set up you ambient.

Blacky :smiley:

1 Like

Thanks! Have made the binary sensor and will test with this soon! :slight_smile:

1 Like

Aaah I think I see it. I used the dev tools to play with the inputs. Letā€™s say I set low lux value to 20. When my motion sensor reports 0 or 5, the automation doesnā€™t trigger while I was expecting it to. It needs to cross from 21 to 19 to be effective. Is there a reason the blueprint works like that instead of just always triggering and checking if the value < 20? There is probably a good reason you implemented it like that. Thanks! :slight_smile:

Also another interesting scenario I noticed is when I switch back from night light to normal light mode that the brightness goes from 50 % (the night light value I set - good) to 54 % instead of 100 % which is what the dynamic lightning should control. If I then go and force the lux value of the illuminance sensor to e.g. 0, it goes back to 100 % (which is in line with my dynamic lightning setting). If I disable dynamic lighting and enable the option ā€œUse Brightnessā€ under Light Control, it goes to 100 %, so this looks like an issue with dynamic lighting.

switch.light_living_room_night_light_scene is a simple switch that turns on when my Apple TV is playing and off when it pauses. Any idea what that could be? Here is my current config:

alias: Light - Living Room
description: ""
use_blueprint:
  path: Blackshome/smart-light.yaml
  input:
    light_switch:
      entity_id: light.living_room
    include_ambient:
      - ambient_low
      - ambient_high
    ambient_light_sensor: sensor.living_room_window_illuminance
    dynamic_lighting_boolean: input_boolean.toggle_helper_automations_light_living_room
    include_dynamic_lighting: enable_lux_controled_brightness
    dynamic_lighting_lux_sensor: sensor.living_room_window_illuminance
    include_bypass:
      - bypass_enabled_turn_off
    bypass_lights_off:
      - binary_sensor.light_living_room_bypass_sensor
    night_lights_entity_state:
      - switch.light_living_room_night_light_scene
    include_night_lights: night_lights_enabled
    night_lights_conditions:
      - entity_state_enabled
    night_lights:
      entity_id: light.living_room
    include_night_light_control:
      - use_brightness
      - if_lights_are_on_adjust_when_crossing_over
    night_light_brightness: 50
    include_light_control: []

I have a light entity which supports RGB, e.g. light.ok_to_wake_light. I see the ability to set one RGB value along with a schedule, but in my case I want the following different colors:

7pm - blue (0, 0, 255)
8:30pm - red (255, 0, 0)
6:30am - green ( 0, 255, 0)
9am - off (0, 0, 0)

How can I have a schedule like this? My apologies Iā€™d love to not have to ask, but I couldnā€™t figure it out on my own.

Thank you! I super love this blueprint.

@TheAutomator

This is how automations work, they have a trigger point.

You will notice your dynamic lighting step value is 4% so that is why it is 54% to slowly go to the brightness. Then at ever heartbeat your light will change 4% untill it gets to its value.

Have you got another automation?

Blacky :smiley:

@bmbouter

You will need to create a script with a choose. Below is your YAML for a script. Just create a new script, edit in YAML and paste this in. Then edit in visual editor and expand out the 4 actions and replace / change your light entity. Save and then add this into lights. Make sur you create another scene or script with the light OFF and add it into Scenes - Scripts To Turn OFF then also add a toggle helper into Scenes & Scripts - Toggle Helper.

alias: OK To Wake Light
sequence:
  - choose:
      - conditions:
          - condition: time
            after: "19:00:00"
            before: "20:30:00"
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              rgb_color:
                - 0
                - 0
                - 255
            target:
              entity_id: light.your_light_here
      - conditions:
          - condition: time
            after: "20:30:00"
            before: "06:30:00"
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              rgb_color:
                - 255
                - 0
                - 0
            target:
              entity_id: light.your_light_here
      - conditions:
          - condition: time
            after: "06:30:00"
            before: "09:00:00"
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              rgb_color:
                - 0
                - 255
                - 0
            target:
              entity_id: light.your_light_here
    default:
      - target:
          entity_id: light.your_light_here
        action: light.turn_off
        data: {}

The YAML below is if you schedule is ON it will check every 30 min and change the light colour

alias: OK To Wake Light
sequence:
  - repeat:
      while:
        - condition: state
          entity_id: schedule.your_schedule_here
          state: "on"
      sequence:
        - choose:
            - conditions:
                - condition: time
                  after: "19:00:00"
                  before: "20:30:00"
              sequence:
                - metadata: {}
                  data:
                    rgb_color:
                      - 0
                      - 0
                      - 255
                  target:
                    entity_id: light.your_light_here
                  action: light.turn_on
            - conditions:
                - condition: time
                  after: "20:30:00"
                  before: "06:30:00"
              sequence:
                - metadata: {}
                  data:
                    rgb_color:
                      - 255
                      - 0
                      - 0
                  target:
                    entity_id: light.your_light_here
                  action: light.turn_on
            - conditions:
                - condition: time
                  after: "06:30:00"
                  before: "09:00:00"
              sequence:
                - metadata: {}
                  data:
                    rgb_color:
                      - 0
                      - 255
                      - 0
                  target:
                    entity_id: light.your_light_here
                  action: light.turn_on
        - delay:
            hours: 0
            minutes: 30
            seconds: 0
            milliseconds: 0

Blacky :smiley:

I am trying to trigger a device (a wall wifi switch connected to a dehumidifier) using your automation when the humidity goes above a certain percentage (humidity sensor). I have created an automation that links to your automation. However it is not working. I would also like to have the switch to go off when the humidity sensor goes below a certain percentage and then shut off the dehumidifier. Here is the YAML. Or can I do all of this just using your automation? Can you help me with this? Thanks1

alias: Crawl space wall plugin ON when humidity >56%
description: Crawl space plugin ON when humidity >56%
triggers:
  - type: humidity
    device_id: 3977a68e58081ca5f6101781f3712f4c
    entity_id: bb0e6d16f7bb87a7c99eea670a3386a3
    domain: sensor
    trigger: device
    above: 56
conditions: []
actions:
  - action: automation.turn_on
    data: {}
    target:
      entity_id:
        - automation.crawl_space_dehumidifier_1_front_on_off
mode: single