Automation based on a timer - timer cancelled vs timer finished

Hi!

I would like to set up some simple automation for my drip watering system in the garden. I have many automations based on the precipitation, time of the day etc but sometimes, I turn the watering on manually and couple of times I forgot to turn it off later on.
I set up an automation with a 45 min timer. The idea was that when the 45 min timer is done, the watering is turned off and I get a notification. Then I added another automation to cancel the timer when the watering is turned off before the 45 min elapses.
The only parameter that I found for the timer related to it finishing the counting is “Idle”. So no matter if the timer finished the count down or if it was cancelled, it will become idle. Is there any option that I missed to distinguish between the two of those? I would like to trigger different actions depending on whether the timer was cancelled or if the countdown is done. I think I can find a work around for this but still interesting to know what options are out there.

Could I use the Attribute “Duration” and then specify “from” as: 0:45:00 and “to” as: 0:00:00 instead of “Idle” state?

Use the event trigger to differentiate finishing vs canceling.

platform: event
event_type: timer.finished
event_data:
  entity_id: timer.[your timer]

And, you can put both event types in the same automation if you want.

platform: event
event_type:
  - timer.finished
  - timer.cancelled
event_data:
  entity_id: timer.[your timer]

Then, check trigger.description to see which one happened with

trigger.description | contains('finished')
1 Like

@holger14 thank you so much! I tested it and it woks :slight_smile:

@jeffcrum could you please explain the “check trigger.description” part? Where and how can I check the trigger description? Under the conditions? Can I then trigger specific actions in one automation? If the trigger descriptions contains ‘finished’ I do one thing and if it contains ‘cancelled’ I do another?

Not in conditions. Because, you know it will already be one of those.

But, in actions. You can use an if/then/else or a choose action and a template condition to see which one it was. Then, yes, do different things based on that.

1 Like