Turn on a relay for x number of minutes every 90 minutes

I have a relay that will activate a water valve. The water will fill my dogs water bowl outside. I want to have it activate from 7:30 am to 10pm every 90 minutes for 5 minutes. Is that an automation that HA can do?
Thanks

A time pattern trigger will fire every x minutes.

If you have a schedule helper as a condition, that will ensure the automation only runs between preset hours.

And a timer helper can be used to turn the tap off after x minutes.

1 Like

Thanks, I will try to wrap my head around all this :slight_smile:

if you must do it every 90 minutes, you might want to take a look at this thread:

if you can run every hour instead (3.5 minutes every hour?), or every half hour (~2 mins every half hour?) . or something like that, it’s easier … the time pattern trigger in the first link @Stiltjack posted has examples.

90 can be done, certainly… but i like simplifying when possible.

of course i have to ask… how big of a dog bowl (and how big of a dog?) do you have that it takes 5 minutes to fill it!!! and is the dog’s name clifford???

Yeah that was a fun discussion. My accepted solution from that thread:

trigger:
  - platform: time_pattern
    minutes: "/30"
condition:
  - "{{ (now().hour*60+now().minute)%90==0 }}"

I think I’d do the “for 5 minutes” thing with a second automation that turns off the valve when it’s been on for 5 minutes; and also at HA start as a safeguard.

Here’s a simple approach that gets the job done, survives a reboot, and includes a fail-safe in the event of a badly timed restart.

alias: example 
trigger:
  - id: 'on' 
    platform: time 
    at:
      - '7:30:00'
      - '9:00:00'
      - '10:30:00'
      - '12:00:00'
      - '13:30:00'
      - '15:00:00'
      - '16:30:00'
      - '18:00:00'
      - '19:30:00'
      - '21:00:00'
  - id: 'off' 
    platform: time 
    at:
      - '7:35:00'
      - '9:05:00'
      - '10:35:00'
      - '12:05:00'
      - '13:35:00'
      - '15:05:00'
      - '16:35:00'
      - '18:05:00'
      - '19:35:00'
      - '21:05:00'
  - id: 'off' 
    platform: homeassistant 
    event: start
condition: []
action:
  - service: 'switch.turn_{{ trigger.id }}'
    target:
      entity_id: switch.your_valve

Feel free to add/modify/remove time periods.

3 Likes

The timing isn’t determined yet per se, I used those numbers to get started. The bowl is about 3 quarts. It will also depend on the amount of water my valve will source. The dogs? One is 120# and the other will be 120# or more. No Cliffird lol Both Malamutes. The bowl will be outside and I want it full as much as possible. I tried a float valve in the bowl, and they ripped it out thinking it was a toy. So th evalve with a small tube going to a stainless steel tube in the bowl hopefully will last :))

Thanks that looks simple enough. I’ll give it a try this weekend

Another question comes up. What if I want to pause this? Say we leave for several days, or it is winter and not in use. Is it possible to have an entity that will stop the code from running. Let’s say the code Taras provided fits the bill, how do I pause it?

Thanks

Disable the automation

Add an input boolean helper (Toggle) and check it’s on in a condition.

Just create an input boolean helper (call it holiday mode or summer mode) and add it as a condition.

All you’d need to do is switch the input helper off and the automation won’t meet the condition.

You can even go all fancy and add the season integration. Add a condition that Season is not winter and you won’t need any manual intervention for that.

I agree with others; create an Input Boolean and add a State Condition that checks if it’s on. If you want to cease refilling the water bowl, simply turn off the Input Boolean.

In the following example, it uses a State Condition to check the state of input_boolean.refill_water_bowl.

alias: example 
trigger:
  - id: 'on' 
    platform: time 
    at:
      - '7:30:00'
      - '9:00:00'
      - '10:30:00'
      - '12:00:00'
      - '13:30:00'
      - '15:00:00'
      - '16:30:00'
      - '18:00:00'
      - '19:30:00'
      - '21:00:00'
  - id: 'off' 
    platform: time 
    at:
      - '7:35:00'
      - '9:05:00'
      - '10:35:00'
      - '12:05:00'
      - '13:35:00'
      - '15:05:00'
      - '16:35:00'
      - '18:05:00'
      - '19:35:00'
      - '21:05:00'
  - id: 'off' 
    platform: homeassistant 
    event: start
condition:
  - condition: state
    entity_id: input_boolean.refill_water_bowl
    state: 'on'
action:
  - service: 'switch.turn_{{ trigger.id }}'
    target:
      entity_id: switch.your_valve

If you want to get fancy, you can add conditions that constrain the automation’s behavior in other ways such as only during specific months of the year (i.e. specific time periods of the year).

Thanks guys! I will be playing with this over the weekend.

:joy::joy::joy::joy::joy::joy::joy::joy::joy:

As someone who had a Malamute for 13 years, I can attest to their creativity when it comes to destroying stuff.

Here’s a backup plan if you want to fine tune the filling of the water bowl instead of relying on a timer. Flood sensors usually have removable metal contacts at the bottom. By slipping in a pair of thin wires under the contacts to essentially extend the probe, you can easily hide the sensor out of harm’s way and only have a small bit of wire exposed near the top of the bowl.

That way, when your bowl is full, the sensor will detect water and you won’t run the risk of overfilling the bowl. You wouldn’t even need to trigger on time pattern - you’d just open the valve when sensor has not detected water for 90 minutes.
I’d still leave a failsafe to close off the valve after 5 minutes, in case they decide the wire makes a nice chew toy though!

image

I’ve had it working for almost a week and they seem to care less about the stainless tube sticking out of the side of the bowl. I might have gotten lucky there :)) I will bookmark this thread so if I need more inspiration I can reference the groups offerings. Thanks alot everyone! Have a great weekend!