🔆 Smart Light - Entity - Sun Elevation - Ambient & Time Triggers

Hi Blacky, thanks so much for all your great work. Highly appreciate your powerful blueprints.
Although reading a lot already I wasn’t able to go through all of it for both blueprints. Hence apologies if this question was answered already. Maybe you could hint me to the answer otherwise here is what I’m trying to achieve/my use case (actually quite similar to the reptile question in Dec. 23): We have guinea pigs downstairs and I would like to switch the lights in a more dynamic and natural way: in the morning, when brightness outside is exceeding 1400 lux but not too early in summer times until they get fed in the morning and switch off lights in the evening when lux is below 1400 again but not too early in winter times. (I prefer lux from my local sensor rather than sun elevation due to reasons already mentioned, e.g. on cloudy days it’s quite dark although sun has not set yet, more accurate for local situation and circumstances (basement) than general sun position). Usually the blueprints work the other way around: lights on when it’s getting dark, Hence I’ve set up a binary threshold sensor, stating “On” when lux > 1400 but the blueprint is not working with it although it’s working with another binary sensor I’ve set up just fine (grouping valves for watering the garden and controlling the water pump - maybe a good use case/inspiration for other users as well what your powerful blueprint is capable of).
The binary lux sensor is working just fine stand-alone and stating what it is supposed to state as well as the entity for the light switch is accessible for the blueprint (both tested).
I’d prefer this blueprint although I’ve tested it with Sensor Light as well but don’t want to have a delay switching the light off in a static way (is it possible to disable/bypass the delay function?).
While this would work for summer times, another challenge would be winter times. I assume I would need to realize this via a scheduler in addition to my lux binary sensor but not sure which is a global trigger and how they are connected. I understood that they are rather connected via OR than AND.
What I’d actually try to realize is: between 6am-8am test lux > 1400? If lux > 1400 → switch on lights, otherwise manually at 8am the latest. In the evening the other way around: start testing lux at 7pm, if it Drops below 1400 switch off otherwise manually switch off at 8:30pm.
Grateful if you could hint towards a working solution. Thank you very much in advance.

@manu24

Welcome to the community.

This statement is the key here.

If I am reading it correctly and making some assumptions, your guinea pigs are downstairs (maybe in a basement) where sunlight is not. So you trying to replicate the sun so you guinea pigs are taken care of in the best possible way (nice).

Would this work?

Try using the time trigger from 8am till 7pm (or whatever works for dynamic lighting). Then to make it look like the sun, In Dynamic lighting use option 11 (just for brightness control) or option13 (for brightness and colour temp). Then set up the morning time so the light will gradually come up to brightness and the evening time to slowly dim to darkness. This way they wont get a shock when the light turns ON or OFF and they will love you for it.

You could use your lux sensor for dynamic lighting and that will work to, but time based for this case would use less resources in your HA.

Is this what your after? If not reach out again or let us know how you go.

Blacky :grinning:

Hey Blacky,

After a bit of troubleshooting I think I’ve got it working. It doesn’t feel like to most elegant way of doing thing, but at the same time I don’t know how I would do it differently. This is how I’ve solved my configuration:

Helpers

input_boolean.living_room_light_control_helper

Used for the Scenes & Scripts - Toggle Helper

input_boolean.woonkamer_light_toggle_helper

Used to toggle the lights from a dashboard card

binary_sensor.woonkamer_light_presence_sensor

{{ not is_state('group.family', 'home') }}

Used to set Bypass Switch - Turn lights OFF with the goal to always make sure the lights are turned off when there isn’t anyone home.

binary_sensor.woonkamer_manual_light_control

- trigger:
    # 1) Hue wall‐switch event
    - platform: state
      entity_id: event.woonkamer_hue_wall_swtich_button_1

    # 2) Living room light control helper toggled
    - platform: state
      entity_id: input_boolean.living_room_light_control_helper
      
    - platform: state
      entity_id: input_boolean.woonkamer_light_toggle_helper

  binary_sensor:
    - name: "Woonkamer Manual Light Control"
      unique_id: woonkamer_manual_light_control
      state: >-
        {% if trigger is defined %}
          {%- if trigger.entity_id == 'event.woonkamer_hue_wall_swtich_button_1'
                and state_attr('event.woonkamer_hue_wall_swtich_button_1','event_type') == 'short_release' -%}
            {{ 'on' if is_state('binary_sensor.woonkamer_manual_light_control','off') else 'off' }}

          {%- elif trigger.entity_id == 'input_boolean.living_room_light_control_helper' -%}
            {{ states('input_boolean.living_room_light_control_helper') }}
            
          {%- elif trigger.entity_id == 'input_boolean.woonkamer_light_toggle_helper' -%}
            {{ states('input_boolean.woonkamer_light_toggle_helper') }}

          {%- else -%}
            {{ states('binary_sensor.woonkamer_manual_light_control') }}
          {%- endif %}

        {% else %}
          {{ states('binary_sensor.woonkamer_manual_light_control') }}
        {% endif %}

This helper has multiple functions, but in the end it all come down to triggering the lights based on manual input. It listsens to an statues update from the Hue Wall Switch, the dashboard toggle helper and the automation controler helper.
When I manually toggle the lights though the dashboard or the wall switch, the output of this entity will be updated resulting in the automation triggering. When to automation triggers from another source, for example the sun elevation, the control_helper switches states and the binary sensor is mirrored into the correct state.
The result of this logic is that no matter from which source the automation has toggled the lights, this entity always reflects the current state.

The Automation

As for the automation implementation, it currently looks like this. Since a lot of logic is happening in binary_sensor.woonkamer_manual_light_control there is very little additional going on in the automation.

alias: Woonkamer Light Control
description: ""
use_blueprint:
  path: Blackshome/smart-light.yaml
  input:
    include_sun:
      - sun_falling
      - sun_rising
    sun_elevation: 8
    sun_elevation_rising: 5
    light_switch:
      entity_id: scene.woonkamer_kleuren_van_de_natuur
    boolean_scenes_scripts: input_boolean.living_room_light_control_helper
    end_scenes:
      - script.woonkamer_fade_and_turn_off_light
    include_bypass:
      - bypass_enabled_turn_off
      - bypass_enabled_turn_on
    bypass_lights_off:
      - binary_sensor.woonkamer_light_presence_sensor
    bypass_lights_on: []
    entity_input: binary_sensor.woonkamer_manual_light_control
    include_entity_state:
      - entity_on
      - entity_off

Conclusion

So far things have been working fine for just a day. I can’t say how stable it will be over time or in jet to be discovered edge cases, but for now I’m pretty happy.
If you have any feedback on this implmentation, I would be really happy to hear about it.

– Remco

@remcoenden

The main thing is if it works they way you would like it then it is perfect.

Blacky :grinning:

New update 3.0

Smart Lighting: Your Lights, Your Way - Take Control and Customize it to Perfection! :bulb: :sparkles:

:bug: Bug Fixes - Dynamic Lighting

  • Lux Controlled Options – When using option 1, 2, 8, or 9 (Lux Controlled Brightness or Lux Controlled Brightness Inverted), setting a minimum brightness below the Dead Zone caused the light not to turn ON at the set brightness until the lux value exceeded the dead zone threshold.

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:

1 Like

So I have been trying to use some lighting blueprints. Specifically been using the Smart Lighting Blueprint like shown in the image, but it never runs at all. I have tried with both device and entity. Anyone know what I may be missing?

In addition to this, the automation created with the blueprint does not even show up under the devices info as an automation.

@Blacky , do you have any ideas why I am having issues with this? Thanks much.

@devtech8

Your using a device and you can only use entities (green). If you click on the <> in your selected device it will expand it down to entities then make sure the entity your trying to control is selected… or just use Choose entity and remove your device.

Blacky :grinning:

hey @Blacky ,
thanks for your Blueprints, i use them in my automation.
How is this one different to 💡 Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time - Light Control - Device Tracker - Night Lights - #6 by Blacky

@jitesh_88

See this faq… click here

Blacky :grinning:

1 Like

I want to automate some outdoor lights with the following requirements:

  • during daytime (means binary_sensor.is_not_nighttime is false) the lights should be on 35% brightness if the ambient light is below 200lux and turn off on 300lux
  • during nighttime (means binary_sensor.is_not_nighttime is true) the lights should always be on 3% brightness.
  • transition between day and night setting should be smooth - if possible

My current config:

alias: Vorgarten Licht (33Z)
description: ""
use_blueprint:
  path: Blackshome/entities-on-off-trigger-conditions.yaml
  input:
    include_ambient:
      - ambient_low
      - ambient_high
    ambient_light_sensor: sensor.helligkeit_4z_illuminance
    ambient_light_value_off: 300
    ambient_light_value: 200
    light_switch:
      entity_id: light.licht_33z
    include_bypass: []
    bypass_lights_off: []
    include_light_control:
      - use_brightness
      - use_transition
    light_brightness: 35
    light_transition_on: 10
    light_transition_off: 10
    include_light_colour_control: use_colour_temperature
    light_colour_temperature: 3200
    night_lights_conditions:
      - entity_state_enabled
    night_lights_entity_state:
      - binary_sensor.is_nighttime
    night_lights:
      entity_id: light.licht_33z
    include_night_light_control:
      - use_brightness
      - use_transition
    night_light_brightness: 3
    night_light_transition_on: 5
    night_light_transition_off: 3
    include_night_light_colour_control: use_colour_temperature
    night_light_colour_temperature: 2702
    include_night_lights: night_lights_enabled
    cross_over_time_delay: 5

but it seems that the lights are on 35% brightness as well at night.
a quick advice what I need to change

That’s a lot of stacked negatives which hurts my brain but that sensor should be true when it is daytime.

yes,you’re right. my explanation contained too many negations. the yaml part states it correctly. :slight_smile:
Thanks for spotting the incorrect description, unfortunately my issue isn’t solved.

@nicknol

So close… you just needed to select If lights are ON, adjust the lights when crossing over in night light control. Because if the light is ON at 35% it will stay at 35% so this option will transition the light to 3%.

alias: Vorgarten Licht (33Z)
description: ""
use_blueprint:
  path: Blackshome/entities-on-off-trigger-conditions.yaml
  input:
    include_ambient:
      - ambient_low
      - ambient_high
    ambient_light_sensor: sensor.helligkeit_4z_illuminance
    ambient_light_value_off: 300
    ambient_light_value: 200
    light_switch:
      entity_id: light.licht_33z
    include_bypass: []
    bypass_lights_off: []
    include_light_control:
      - use_brightness
      - use_transition
    light_brightness: 35
    light_transition_on: 10
    light_transition_off: 10
    include_light_colour_control: use_colour_temperature
    light_colour_temperature: 3200
    night_lights_conditions:
      - entity_state_enabled
    night_lights_entity_state:
      - binary_sensor.is_nighttime
    night_lights:
      entity_id: light.licht_33z
    include_night_light_control:
      - use_brightness
      - use_transition
      - if_lights_are_on_adjust_when_crossing_over
    night_light_brightness: 3
    night_light_transition_on: 5
    night_light_transition_off: 3
    include_night_light_colour_control: use_colour_temperature
    night_light_colour_temperature: 2702
    include_night_lights: night_lights_enabled
    cross_over_time_delay: 5

Blacky :grinning:

1 Like