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

@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

@dsim

Sorry, please donā€™t post your questions about your automation here. This post is for this blueprint only. Please create a separate topic and ask the questionā€¦ there are many community members willing to hep you.

Blacky :smiley:

1st of all: awesome work :beers:

Quick question as Iā€™m willing to debug myself: how to trace this automation? I even cant scroll to the end, trace is cutted of.

I have here an Hue Light 9290012573A

I wonder if it works with that color_mode xy
refering to zigbee2mqtt it should also accept RGB: Philips 9290012573A control via MQTT | Zigbee2MQTT

{
    "brightness": 87,
    "color_mode": "xy",
    "last_seen": "2024-10-23T23:49:08+02:00",
    "linkquality": 48,
    "power_on_behavior": "off",
    "state": "ON",
    "update": {
        "installed_version": 16787456,
        "latest_version": 16787456,
        "state": "idle"
    },
    "color": {
        "h": 5,
        "hue": 5,
        "s": 91,
        "saturation": 91,
        "x": 0.589,
        "y": 0.329
    },
    "color_temp": 439,
    "update_available": null
}

But even with minimum trigger and simply condition, this or other light wont turn on.

With a on/off switch it gets triggered. So now I just wanna trigger it by the Sun Elevation. No luck so far.

@TylonHH

That is the end you just need to move to the right to see the trace. It is a big one with a lot going on.

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:

No needed anymore. The automation works like charme, since it was triggered by the ā€œsunā€. I thought while setting up or testing it, it would run because the sun was down.

Awesome work. Saved me alot of headacheā€¦ ā†’ donation
grafik