Turns on at a specific time and turns off after a given time

Hi there,
I can’t find what I’m looking for in the various exchanges.
I am a beginner and I am learning little by little, I turn to you for your help.
I apologize in advance for my English, I am French and I use a translator.

I have home assistant GUI:
Home Assistant 2022.7.3
Supervisor 2022.07.0
Operating System 8.2
UI: 20220707.0 - latest

I’m looking for a blueprint that would allow me to program the switching on and off of an entity at a specific time and during a period of time.

So that you understand, I want to use it to program my daily automatic watering.
I have several “Wooz R7054”: Woox R7060 control via MQTT | Zigbee2MQTT.

And here are examples of what I would like to do:

  • At 6:30 p.m., turn on “switch.irrigation_1” for 30 minutes, then turn off “switch.irrigation_1” at the end of the 30 minutes.
  • At 7:00 p.m., turn on “switch.irrigation_2” for 30 minutes, then turn off “switch.irrigation_2” at the end of 30 minutes.
  • etc…

I can’t manage to do this in a simple automation.
Currently, I need to create two automations:
one to turn on “switch.irrigation_1” at 6:00 p.m. and another to turn off “switch.irrigation_1” at 6:30 p.m. for example.
The problem is that I have 15 devices to program and it will be necessary to create 30 automations to do what I want.

I found this: [WIP] - Day / Time selector
It’s great, but I don’t see how to integrate my entity corresponding to my “switch.irrigation_1” for example
I asked for more info on this post without getting an answer, that’s why I’m creating a new one here.

Ideally, we should be able to use this blueprint for any entity (light, power plug, …)

Thank you in advance for your answers

have a good day

Use the “wait for a time to pass” action after turn on then turn off.

I would not use “wait for time to pass”. If you do, and you reload an automation or restart HA, they won’t shut off.

1 Like

Thinking out loud here… But if I were to write an automation for this, I believe i’d create a input_datetime helper for each irrigation which would have the start time of that irrigation. and then another timer helper for that irrigation which would be the duration for that irrigation to run (or you can use a end time helper too if its fixed).

Then i’d have one automation with a trigger like this:

  - trigger:
      - platform: time
        at: input_datetime.irrigation_1_starttime
        variables:
          zonename: irrigation_1
      - platform: time
        at: input_datetime.irrigation_2_starttime
        variables:
          zonename: irrigation_2

Then within the automation action, you’d use the triggering entity to determine what to run at that time. Like this:

  - service: timer.start                                                                                      
    target:                                                                                                     
      entity_id: timer.{{zonename}}
  - service: some_service_to_start_your_sprinkler
    entity_id: something.{{zonename}}

I’d have another automation for turning them off using a trigger like this for each:

  - platform: event                                                                                                                                                                                                                                 
    event_type: timer.finished                                                                                                                                                                                                                      
    event_data:                                                                                                                                                                                                                                     
      entity_id: timer.irrigation_1
    variables:
      zonename: irrigation_1
  - platform: event                                                                                                                                                                                                                                 
    event_type: timer.finished                                                                                                                                                                                                                      
    event_data:                                                                                                                                                                                                                                     
      entity_id: timer.irrigation_2
    variables:
      zonename: irrigation_2

And use the zone name to turn off the right irrigation. You can do this more dynamically as well by using {{trigger.entity_id}} and replacing the names with what you need.

  - service: some_service_to_stop_your_sprinkler
    entity_id: something.{{zonename}}

Also as an alternative to all of the above, you could use this to run a scheduler:

Maybe using the scheduler component would simplify things? Also I think there are specific irrigation integrations that could be of use, but I don’t know links to them off hand.

Ah… @calisro beat me to the punch :smile:

Great minds think a like. :open_mouth:

This would actually be clean on how you can do your irrigation.

You could use simple scheduler.

regress: That’s a nifty scheduler as well. I wish they had a lovelace piece to it. I see the author did say they are working on it…

Good evening,
Thank you for your feedback, I did not expect so many answers :slight_smile:
I’ll check it all out and let you know if it works for me.

Good evening,
Thank you so much for sharing, this is exactly what I needed.
I will do some tests.
I will still consider other people’s suggestions.
Thanks for your help.