⏳ Entity - Run ON Timer

@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.

New update 1.5

New Feature :new:

Timer Helper - Added a timer helper option. By adding a timer helper it will survive a Home Assistant restart and resume its time. It also allows you to display the time in a dashboard.

Note - When creating your timer helper, make sure you tick the box to restore so it will survive a HA restart and don’t set any time in the timer helper duration, use the time settings in the automation.

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:

Hi, just trying to understand how this works, if I want multiple separate devices to turn off on a timer, do I need to create an automation from this blueprint for each?

Like, if I have a bunch of light around the house that I want to turn off automatically after x min of being turned on, is it not possible with a single automation?

I am on the next version 1.6 and I forgot to push it out. It has been tweaked a bit but If you would like each light to be able to turn OFF after X amount of time once it has been turned ON then yes. The new version will allow you to have multiple entities and you can just turn one ON or any of them ON but the time delay will be from the last one that was turned ON. 1.5 will turn them all ON and OFF together but 1.6 will give you an option to turn them ON and OFF together or turn them ON individually but they will all go OFF together. That may work for you

I will have to look at my version again to make sure it is ready to be released and then I will push it out. I try and get this done tomorrow.

Blacky :smiley:

1 Like

New update 1.6

New Feature :new:

Trigger Entity State - Added a trigger entity state option. You can now choose ON or OFF as the trigger state.

Trigger Entity Sync - Added a trigger entity sync option. This is now an option.

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

I would like to be able to set the time for the timer using some control in the UI. Right now I have the timer hard coded to leave the device on for a fixed number of hours. I am using it to charge an e-bike battery and would like to be able to change the number of hours from a UI control instead of having to edit the instance of the blueprint.

I created an input_number in the UI and have a slider that spans the range of values that I’d like to use to set the number of hours that the timer is on. Is there a way to use this with this blueprint? I’m a bit of a HA newbie. I’ve done some reading and it seems I may need to use a helper and a variable plus a template, but I’m not quite sure how to do that. Can I do it without editing this blueprint and just make modifications to the automation that uses the blueprint? Any help would be much appreciated.

Not sure this blueprint is right for me, or if you can point to something else?

I am after a backup for lights that are manually turned on (dash or alexa or physical button), to have an auto time out.

So I use the sensor light for some rooms, but would like a backup for all rooms to monitor a light being turned on and left on.

Lamp on or Home Assistant starts.
15 min timer to turn off
But will reset if there is motion
and cancel if the light is manually turned off
Light turns off

I have created something myself but it isn’t great. Does this solve it for me or some other blueprint like this one?

@richsimpson

Not sure if this is what your are after but just brain storming.

I would have a notification that would send a message to my phone if the light is ON for X amount of time and motion is OFF. Then I would have an action button in the message were I can decide if I would like to turn the light OFF.

Have a look at this :round_pushpin: State Notifications & Actions

  1. Use state and your light = on
  2. Start Trigger - Time Delay = X amount of time the light must be ON for.
  3. Global Conditions = motion must be OFF.
  4. Action buttons = set it up to turn your light/s OFF.

Set one up for each automation.

  • One light used in a automation - easy set up.
  • Two or more lights used in a automation - Use one light as the state trigger and in action turn OFF add all lights.

Maybe that will work for you.

If not

You will have to set up a template sensor for when the light is ON for X and motion is OFF = turn ON else = OFF. Then use that as a trigger in a automation to turn lights OFF. But you may have them going OFF when you would like them ON hence the notification method above, you get to decide and it is only if someone leaves the light ON and the automation gets tricked (sequence of events leads to the light/s being ON) and the light stays ON.

Totally up to you… hope this helps… let us know how you go.

Blacky :smiley: