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

@networkcrasher

Sorry I am not following along.

I do know there’s an issue that I just can’t seem to fix. One day I’ll revisit it. Because there are so many scenarios, the problem shows up when you restart HA during a small window of time, it comes from the sun falling and time. That window is usually around 1 am to 3 am when restarting Home Assistant. I thought I was the only one working at that hour, most people are sleeping! :rofl:

Blacky :grinning:

@smartlightenthusiast

THAT WAS A GOOOOD FIND! Thanks for letting us all know… I will have to put that in the memory bank.

I glad you finally got it up and running! :+1:

Enjoy

Blacky :grinning:

1 Like

Hi @Blacky
Sorry, I know it’s confusing but if we just look at it like this, maybe it’ll be easier to understand.

I have the following automation that turns on/off based on a entity state. If I reboot HA after it’s turned on, when HA finished restarting, all the lights controlled by this automation turn off. It could be 1 minute after they turn on or hours, it’s not between 1 and 3 AM or anything too late.

alias: Night Lights off at 3AM
description: ""
use_blueprint:
  path: Blackshome/smart-light.yaml
  input:
    light_switch:
      entity_id:
        - scene.dimmed_night_lights
        - switch.couch_small_lamp
        - switch.foyer_lamp_outlet
        - switch.great_room_lamps_outlet
    boolean_scenes_scripts: input_boolean.dimmed_night_lights
    end_scenes:
      - scene.dimmed_night_lights_off_at_3am_off
    include_ambient: []
    ambient_light_value: 1000
    include_sun: []
    sun_elevation: -5.5
    sun_elevation_rising: -5
    include_time:
      - time_off
    before_time: "03:00:00"
    include_entity_state:
      - entity_on
      - entity_off
    entity_input: input_boolean.standard_night_lights

Do I need to do something special to keep the lights on during an HA restart? Every time I check the entity after a restart, it’s on.

@networkcrasher

Yes, that helps me understand. Because this blueprint covers so many scenarios, it’s really hard to get all the conditions right. You’re dealing with entity ON/OFF plus Time OFF, which makes it nearly impossible to cover every situation perfectly.

What I’ll do is update the blueprint to include an option to enable or disable the HA restart feature. This way, if you prefer, you can turn it off. The chances of something going wrong after a restart are very low, so disabling it would likely be the best option.

Keep an eye out for the next update, then simply disable HA restart.

PS: Thanks for your support / donation!

Blacky :grinning:

New update 3.1

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

:new: New Feature

  • HA Restart: Added an option to enable or disable the HA restart safeguard option. Because this automation supports many scenarios, the HA Restart safeguard option may not always behave as expected. In most cases it works fine, so it’s enabled by default. However, if you find it causes issues in your setup, you can disable this option. In most cases, when HA restarts, the automation will not land on an ON or OFF state, so disabling this option gives you a higher chance that nothing goes wrong.

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

New update 3.2

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

:new: New Feature

  • Trigger - Push Button: You can now use a button as the trigger.

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:

Hello,

Do you have any plans to port ā€œNight Glowā€ from the sensor blueprint to this blueprint as well?

Thanks!

@iphoting

Welcome to the community.

I didn’t but I will put it on the list to do.

Blacky :grinning:

1 Like

Hi there! I’m new here and I’m having a bit of trouble with the blueprint. I tried using it, but it didn’t seem to trigger anything.

I’ve attached my config for reference. Any help you can provide would be greatly appreciated!

alias: Smart Light First Floor
description: ""
use_blueprint:
  path: Blackshome/smart-light.yaml
  input:
    light_switch:
      device_id: e875d0a8b0f34023e8ddc6693ba810d8
    include_ambient:
      - ambient_low
      - ambient_high
    ambient_light_value: 60
    ambient_light_sensor: sensor.hub_2_living_room_illuminance
    ambient_light_value_off: 120

@drselump14

Welcome to the community.

You are using a device as a light. Only entities are allowed. See this FAQ (my other blueprint FAQ but is the same) on how to expand it down to an entity, click here..

Blacky :grinning:

Ah, thank you. Now everything works

1 Like

Hi @Blacky, thanks for this wonderful blueprint. You mention here that different values will be fine – however, for dynamic lighting, there’s a hardcoded check that only runs interpolation when elevation is > -10. I’d like to set up my dimming to run from sun elevation falling from -10 to -30 (where -30 is 10pm). I could use night lights but I’d prefer an even dim down to my minimum. Any particular reason why -10 is set as an arbitrary cut off?

Edit: would something like the following not work as a simpler alternative (unless it interferes with night lights?

{% if elevation >= dynamic_lighting_sun_elevation_end_falling %} #maybe add a upper bound?
    ...  # interpolate
{% else %}
    ...  # clamp to min (or max)
{% endif %}

Thanks!

@gsdatta

Welcome to the community.

This setting is to force the min / max value depending on your DL selection. The sun elevation was design to mimic the sun and at -10 it should be completely dark.

If you would like it to go to 10pm then consider using the DL Time options 10, 11, 12 or 13.

Blacky :grinning:

Thanks for the note! Basically what I’m trying to do is start the lights when it’s dark out based on solar elevation and then continually dim until we sleep (so not like true adaptive lighting based on solar cycle but more like ā€œbright when it’s dark and dim slowly till some solar timeā€). I guess I could use ambient light or solar trigger and then time based dynamic lighting :thinking:

Hi, I’m wondering is it possible to enable the light activation by sensor only in the noon. I want to turn the light on automatically when there is bad weather

1 Like

Hi, would it be possible to implement additional conditions?
Thx and regards
Mike

@gsdatta

Yeah, you cold set the time up for DL then use sun as the ON trigger and time as the OFF trigger.

Blacky :grinning:

@drselump14

Yes… you just need a sensor that detects what you consider ā€œbad weather,ā€ and defines what you call ā€œnoon.ā€ Once you’ve created that sensor, you can use it in Trigger – Entity State.

Blacky :grinning:

@Mike.Hellracer

I have been considering this but it can break the blueprint.

The blueprint may turn the light ON but then will never turn if OFF due to the conditions you set :thinking:

Blacky :grinning:

Hi @Blacky

thank you for all the blueprints and the time and effort!

I have a question though, much like networkcrasher mentions, I have something weird: when HA restarts all my lights switch on (when they shouldnt and they were off before the restart).This also happens with other lights than the example below that use the same blueprint.

I just noticed the ā€œHA restartā€ option, I will try that but do you think this will be able to help in this case?

alias: Garden Lights
description: ""
use_blueprint:
  path: Blackshome/smart-light.yaml
  input:
    light_switch:
      entity_id:
        - light.shellyplug_s_c8c9a3894282
        - light.lichtslinger_overkapping
    sun_elevation: 4
    include_sun:
      - sun_falling
    include_ha_restart: disable_ha_restart

Thanks again!

PS: I am using 3.2.