Skip a Timed Automation if a Physical Button is pressed...Please Help!

Looking for some help. I am new to HA and have 2 Aqara Pet Feeders on a schedule to feed the dogs in the AM and in the PM. I also have an Aqara Mini Switch that I can use to manually feed the dogs.

I am looking to find a way to skip the timed automation in the event the mini switch has been pressed manually.

Here is an example scenario

Dog A is scheduled to be fed at 6am and at 6pm. However, Dog A can be a little a**hole when he is hangry and it is before his feeding time. Therefore, I push the manual Aqara mini switch to feed him early but don’t want the feeder to dispense more food at the scheduled time.

Thank you in advance for any help!
p.s. YAML is intimidating and I am HA illiterate unless it is creating simple stuff.

You can add a condition to your feeder automation that checks when the mini switch was last pressed and only pass on to the actions if it was greater than a few hours ago. e.g.

conditions:
  - condition: template
    value_template: "{{ now() - states('event.aqara_mini_switch')|as_datetime|as_local > timedelta(hours=3) }}"

Note the actual entity will depend on if you are using ZHA or Z2M. And if Z2M, if you are using experimental or legacy entities.

Look in Developer Tools → States. Do you see an event entity for your mini switch that has a state value of the last time it was pressed, or is it an action entity?

Thanks Tom for the quick response!

I have taken snapshot of the states of the mini switch.
I am not sure what to do from here.

In your automation that automatically feeds the dog add this condition:

conditions:
  - condition: template
    value_template: "{{ now() - states('event.button')|as_datetime|as_local > timedelta(hours=3) }}"

It will not feed the dog within three hours of the button being pushed. So if you push the button between 3am and 6am, or 3pm and 6pm then the automated feed will not happen. You can adjust this time to suit your needs in the timedelta(hours=3) bit.

Thank you so much! I will give it a try.

Just so I am understanding correctly, I went into the automations.yaml and pasted what you had provided. Here is a how it looks.

Tom,
Thanks again. My automation appears to be working flawlessly. Thanks Again!

1 Like