⏳ Entity - Run ON Timer

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.6 :fire:

:newspaper: The Automation Process:

  • If selecting “Trigger entity state ON”, when the entity is turned ON, it will be automatically turned OFF after the pre-set time period.
  • If selecting “Trigger entity state OFF”, when the entity is turned OFF, it will be automatically turned ON after the pre-set time period.
  • You have a “Trigger Entity Sync” option. When using multiple entities and one entity changes state i.e. manually turned ON or OFF, then all the entities will be turned ON or OFF automatically in sync together.
  • You have the option to use a timer helper. This is useful if you would like to display the remaining time in a dashboard and the timer will survive a HA restart.
  • HA Restart - If you use a timer helper it will resume as nothing happened (recommended). If you don’t use a timer helper, then when HA restarts, the automation will try and reset back to the start.

:rocket: CHANGELOG

  • Version: 1.6 - 7 Nov-23 - Added trigger ON or OFF state option. Added trigger entity sync option.
  • Version: 1.5 - 22 Oct-23 - Added timer helper option.
  • Version: 1.4 - 21 Sep-23 - Update deprecated code.
  • Version: 1.3 - 9 July-23 - Bug fix in action
  • Version: 1.2 - 2 July-23 - Updated HA restart
  • Version: 1.1 - 7 Dec-22 - Initial release

:shield: MY OTHER BLUEPRINTS

:bulb: Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time
:high_brightness: Smart Light - Entity - Sun Elevation - Ambient & Time Triggers
: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
:loudspeaker: Notifications & Announcements
:calendar: Calendar Notifications & Actions
:round_pushpin: State Notifications & Actions
:robot: Android Notification Channel Manager
:toilet: Toilet Exhaust Fan with time delay
: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 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:

15 Likes

Great, thank you!
I will use it for my electric blanket :slight_smile:

2 Likes

This is a lovely blueprint. Many devices have an inbuilt timer, would be great if this gave us the ability to either count down within HA or set the inbuilt timer to count down. I do prefer the count down within a device itself as it ensures that if HA loses connection for any reason, the device will still turn off.

Hi @shrub100 glad you like it :+1:

To count down or count up it still time based.

Yea if you have a timer in the device then all you need to do is link HA to it or you will have to go into the device manually.

Yep that is one fall back using any home automation, if it can’t connect at the time to preform any task then it could be missed unless you have a 2 way conversation and the code that supports it.

Just curious. Can you share a usecase of when you have multiple entities?

Hi Anthony, firstly welcome to the community :+1:

It is really up to you but you could have a few lights or switches that you would like to operate at once. You may need a light and a fan on at the same time. It is why we love HA you get to choose. :wink:

Hi Blacky, is there a possibility to build something to have either different timers to choose from and one to control that entity completely manual?
Would be nice for my water-tab using it in different situations, fill my pond for xx mins. Or have it run till I stop it for continually watering.

@legi , Hi Peter, are you looking to do this through the front end?

Sorry for my first response I deleted that, this is the right…

Yes, could try doing a card with for example 4 switches. first 10 min, second 30 min, then 1 hour and on always on.

I will PM you.

New update 1.2

Updated Feature :white_check_mark:

HA Restart

Updated the HA restart to only trigger the automation if entities are ON. This prevents the automation running for no reason when HA is restarted. All the entities will still turn OFF automatically starting from the restart start point to the end of the pre-set time period.

Enjoy

Blacky :grinning:

New update 1.3

Bugs Fixes :bug:

  • Fixed some code in the action.

Enjoy

Blacky :grinning:

New update 1.4

:warning: BLUEPRINT CODE UPDATE :exclamation:

Just a heads up if your still on a old HA version before you update.

From time to time Home Assistant update their code structure and the old code will become “DEPRECATED” stopping / breaking automations from working. It effected this blueprint about 4 to 6 months ago. I wanted to wait some time so everyone had a chance to update their HA version before updating the code as older HA versions can not run the new code. This blueprint has now been updated so it will still operate once HA remove the “DEPRECATED” code from their system. :wink: :+1:

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:

Is it possible to make this blueprint universal so it could also turn off a device for a defined time and then turn back on after the time has elapsed? (Selectable action to temporarily turn on or off).

Also, it was not clear to me that this ran EVERY TIME an entity was turned on. I like the ability to turn turn on (or hopefully off) a device for a pre-defined time but can this also be made to only run 1 time (like a 1-shot) in addition to every time like it currently does? There are many times where I have a certain automation but want to temporarily override a state but allow the existing automation to take control again. With this setup, if my existing automation turns on a device that has this blueprint applied, it will turn off every time going forward based on the time defined in the blueprint.

@jlrosssc

Yes this is possible but maybe my :stopwatch: Timer Relay - Run ON Timer will suit you better. You can choose the state ON or OFF of an entity to then turn ON another entity.

Yes it is a run on timer, so when you turn it ON the timer will turn it OFF.

I am not realy sure what you are trying to achieve. When will it know when to do the “1-shot”. Have a look at my other blueprint and let me know if this works for you.

The other one is close but still makes this automatic. Here’s what I’m attempting to do. I can create individual automations but am hoping I won’t have to:

I have a number of things that come on upon home occupancy such as lamps, fans, etc. for the house and basement. There are times that I’m working from home and, with no one else home, I don’t need much of this on. I’m trying to find a way to turn off these selected items for a selectable time until the rest of the family comes home and they the come back on. I could active this from a push button or Apple Watch complication, for example but I don’t want these turning off every time I turn them on, only when I manually active the action. is this possible?

@jlrosssc

Have you considered using presence detection (person) so when those people are home then it will enable the items you would like. If you are home then only some items are enabled and the other items are not. My sensor light blueprint will do this but not sure if that works for you.

@Blacky thanks for the blueprint. I’ve changed it a bit and added climate entity, because wanted to control floor heating with it. Here is the updated code: run-on-timer.yaml · GitHub

Hi, my entity is not working properly, due to some issue in the Time Configuration
Would appreciate if anyone could help me

  1. In condition I want to add – time 2 to 4 am and 2 to 4 pm – switch.toggle
  2. In the If statement I want to add - time after 4 am to 2 pm & 5pm to 1 am — if the entity state “ON” – ACTION “switch.off”

The below code is not working correctly

trigger:
- platform: state
entity_id:
- binary_sensor.input_2
id: "on"
- platform: state
entity_id:
- binary_sensor.input_2
id: "off"
condition:
- condition: time
after: "18:40:00"
enabled: true
- condition: or
conditions:
- condition: time
after: "06:40:00"
action:
- service: switch.toggle
entity_id: switch.e16s_output2
- if:
- condition: state
state: "on"
entity_id: switch.e16s_output2
- condition: time
after: "08:35:00"
- condition: or
conditions:
- condition: time
after: "20:54:00"
then:
- service: switch.turn_off
entity_id: switch.e16s_output2
mode: single

I am using this to control two e-bike battery chargers. The chargers are plugged into Sonoff S31 plugs running Tasmota and connected to HA using MQTT using the Tasmota add on. I added the switch names as the entities to the automation created with this blueprint. I set the off time to 2 hours. I created an entity list dashboard that has switches for the two entities that control the plugs and one for this automation. If this automation is turned on and I turn on one of the plugs it will turn off the automation in 2 hours. That lets me charge the batteries for a fixed amount of time when they are low. If I want to fully charge them I simply turn off the automation and turn on the chargers. It works perfectly! Thanks.