⚙ Turn Light, Switch, Entity or Scene On & Off with Trigger Conditions

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

GitHub Link Click Here

Like this blueprint? Consider hitting the :heart: button below :+1:

Version: 1.7 :fire:

Need help? :eyes: See our FAQ: Click Here

:newspaper: The Automation Process:

  • Turn ON a Light, Switch, Entity or a Scene with a entity ON & OFF state, the sun’s elevation, an ambient light value or time.
  • Turn OFF a Light, Switch, Entity or a Scene with a entity ON & OFF state, the sun’s elevation, an ambient light value or time.
  • You have the option to set weekdays. This is a global option for all trigger conditions.
  • You have the option to enter in any global conditions you like.

:rocket: CHANGELOG

  • Version: 1.7 - 14 Oct-23 - Update ambient option to have ON and OFF value.
  • Version: 1.6 - 6 Oct-23 - Update binary sensor to entity state. Added option to add any global condition.
  • Version: 1.5 - 21 Sep-23 - Update deprecated code.
  • Version: 1.4 - 28 March-28 - Select any entity you like.
  • Version: 1.3 - 13 March-23 - Update typo in variables.
  • Version: 1.2 - 31 Jan-23 - Made weekdays a global option.
  • Version: 1.1 - 30 Jan-23 - Fixed time trigger.
  • Version: 1.0 - 30 Jan-23 - Initial release.

:shield: MY OTHER BLUEPRINTS

:bulb: Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time
:infinity: Sensor Light Add On - Media & Movie Lights - House Alarm Lights - Smoke Alarm Lights & Exhaust Fans + More
:shower: Bathroom Humidity Exhaust Fan
:low_battery: Low Battery Notifications & Actions
:vibration_mode: Appliance Notifications & Actions - Washing Machine - Clothes Dryer - Dish Washer - ETC
:calendar: Calendar Notifications & Actions
:round_pushpin: State Notifications & Actions
:toilet: Toilet Exhaust Fan with time delay
:hourglass_flowing_sand: Entity - Run ON Timer
:stopwatch: Trigger - Run ON Timer
:magic_wand: Manual light control with auto OFF
:door: Closet, Pantry, and Cupboard Lighting
:timer_clock: Timer
:thermometer: Temperature Control Exhaust Fan
:snowflake: Temperature Control Exhaust Fan - Inverted
:eight_spoked_asterisk: Toggle Switch - Turn ON & OFF Entities
:nazar_amulet: Press Button - Turn ON & OFF Entities
:on: Switch - Turn ON & OFF Entities

Like this blueprint? Consider hitting the :heart: button below :+1:

21 Likes

Q: How to use the “The By-pass” without having a physical switch?

A: Go to Settings / Devices & Services / click on the “Helpers” tab / click “+ CREATE HELPER” and select “Toggle”. In the name put “Light By-pass” and click save. Then go back into the automation and in the “The By-pass” search for the name you created in this case “Light By-pass” and click save. Now in a “Dashboard” click “Edit dashboard” then click “+ ADD CARD” click on “Button” or “Entities” in the entity field again search for the name you created in this case “Light By-pass” and click save. Then click “DONE”. You now have a “By-pass” switch to disable the Light, Switches or Scenes.

Q: I would like to set a different value but the slider is not letting me?

A Just simply type the number value you would like in the field and click save. A red line will appear under the number you have entered but once you click save, exit the automation and go back into it the red line will not be there.

New update 1.2

  • Fixed time trigger
  • Made weekdays a global option for all trigger conditions.

Enjoy

Blacky :grinning:

1 Like

This is looking great after a first quick glance, thanks for sharing!
I will test this tonight in combination with an existing automation that turns a night light on permanently between sunset and midnight.
Cheers,
Uwe

Thanks for your kind words.

Please make sure you update to V1.2 if you haven’t already. As I just fixed the time triggers just for what you are trying to do.

Edit: Tip, your settings for this would be the sun condition and the time would be, “On Time” could be any time between sunset and just before midnight (say 11:30 PM) and “Off Time” would be midnight.

That was fast. Even with time travel! Or are you in a time zone where it’s already Jan. 31st? :wink:

Just discovered your earlier “Sensor Light” blueprint and might switch over to this one, though. Still the same use case, but involving a motion sensor, so that looks more suitable to me.

Yep, already 31st. :+1:

Can you add Numeric state aswell of an entity?

IE - condition: numeric_Stare
entity_id:
above:
below:

@cbothma Hi Christoff

Could you give me your use case?

Help.
I’m new to HA and for the life of me i can’t get the on and off times to work.

I have the trigger as a light sensor but only want it to trigger between 9-5 if it gets too dark in the house for the plants. But it seems to trigger randomly outside of these times.

Hi @Stevie , firstly welcome to the community :+1:.

This automation works when it passes through or over the trigger condition. So if you have a light sensor every time it passes over the set point it will turn the light ON and or OFF. If you have also set the time trigger then every time it passes over the set time it will turn ON and or OFF. The only global condition is weekdays.

The automation was developed as a lot of people just wanted a simple ON / OFF for a light with time. I added extra options to choose from when developing it if time was not your thing, like LUX, sun & binary sensor. You can choose weekday as a global setting so it could be used in a office environment were Monday to Friday you need the lights ON and OFF. Example: If using time option set the time to turn the lights ON at 8 am and OFF at 6 pm Monday to Friday.

Normally you would choose just one option.

So for what your trying to do, this automation will not work.

This works fantastic, really appreciate the blueprint!! I might tweak it to add the ability to control entities (door locks, garage etc) so I can have schedules like lock the door, shut the garage and turn off all the lights at a set time and unlock the doors and turn on lights in the morning. That would basically make this an all in one starter for any automation, really.

@jclendineng

Hi Joel, I will do an update to include any entity you like. Just update to Version: 1.4 and you will be good to go.

New update 1.4

  • You can now select any entity you like to turn ON and OFF not just lights, switches or scenes.

Enjoy

Blacky :grinning:

2 Likes

Hello, thanks for the script and the continued support!

I have played around with both the time for it to be active and the sun position, but it appears the light will turn on regardless of the time of day, instead of only when i am trying to define it. unless i am drastically misinterpreting it

which from an earlier post: The automation was developed as a lot of people just wanted a simple ON / OFF for a light with time. I added extra options to choose from when developing it if time was not your thing, like LUX, sun & binary sensor. You can choose weekday as a global setting so it could be used in a office environment were Monday to Friday you need the lights ON and OFF. Example: If using time option set the time to turn the lights ON at 8 am and OFF at 6 pm Monday to Friday.

It looks like it might not do what i was hoping (basically when a event in frigate is logged to turn on a light) I only want to turn on a light if a person is seen, not the millions of bugs in florida :slight_smile:

@mykpoz

Hi Michael, firstly welcome to the community.

This blueprint works with the actual trigger points (crosses over your setting). Example

You mentioned time and sun.

When the sun drops below the sun elevation or the “ON time” it will turn the light ON. If you enabled the option.

When the sun rises above the sun elevation or the “Off Time” it will turn the light OFF at that point. It is not a condition to only work when the sun is below the sun elevation.

It is the same for “Binary Sensor” and “Ambient Light Sensor”.

So the sun could turn the light ON when it goes below the sun elevation and then the time can turn it off. Example if you let the sun turn it ON and then you would like it off at 11:30pm you would set the sun elevation at say -1.5 and the light would come ON when it passes over this setting. Then if you would like it OFF at 11:30pm you would use the time and set the ON time to 11:29pm (the light is already ON so nothing changes) and the off time to 11:30pm. Light turns OFF. When the sun goes above the sun elevation it will turn it OFF but it is already OFF so nothing happens.

What I think your after is for the light to only come ON when it is dark or below the sun elevation. For this you would need to use my other blueprint called :bulb: Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time.

This is tricky… but if you have a CCTV camera that can detect humans and then send triggers for this and not the millions of bugs you have in florida it should work with my other blueprint.

Hope the helps you.

Blacky :smiley:

1 Like

It is actually working pretty much as I want now. :+1:

I would like to see a timer option for switching off lights. Now it needs two?? automations that might interfere as I see it but please correct me if I am wrong.
I want to use it with a ‘presence sensor group’ switch light groups on but when no occupancy it should switch of after X time.

Hi Stevie, that is good news :+1:

@zebrahosting

I think you may be after my other blueprint. Have a look at this one.

:bulb: Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time