Triggering a flow at 2 minutes to every hour

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
Philip
Posts: 82
Joined: 08 Jun 2015 19:20
Location: Hampshire, UK

Triggering a flow at 2 minutes to every hour

Post by Philip » 19 Oct 2016 12:24

I have a flow that I want to trigger at 2 minutes before each hour (i.e. at 00:58, 01:58, 02:58, etc).

I originally tried triggering it daily at 00:58, and then getting it to “sleep” for 60 minutes (or 3600 seconds), but I found that the clock drifted slightly and that it didn’t seem to survive a reboot or a period when the phone was switched off (by which I mean that if the phone was switched off from, say, 01:15 to 01:30, then the flow would not trigger at exactly 01:58:00).

So instead I have set up 24 separate triggers for the flow (at 00:58, 01:58, 02:58…) and this works fine, but seems rather inelegant.

Is there a better/more elegant way to do this, that will survive the phone being switched off for a period or rebooted, and which won’t drift with time?

(For those wondering why I want to do this – my last BMW had an option in the on-board computer to “beep” just before each hour. I found this really useful when I was listening to music, as it would remind me to switch over to the radio, where the News is usually broadcast on the hour. My current cars don’t do this, so I’ve written an AutoMagic flow to check whether I’m in my car, and if so to tell me that “the news will be on in 2 minutes”).
--
Philip

User avatar
Scotty
Posts: 78
Joined: 26 Aug 2016 20:29
Location: Southern California

Re: Triggering a flow at 2 minutes to every hour

Post by Scotty » 19 Oct 2016 17:17

Try this:

Trigger: Periodic Timer
Interval 1h
Wake device.... yes
Limit time range....yes
Weekdays - probably check every day
Set "From" value so the minutes is set at 58 (e.g., 5:58AM -- the value for hour depends how early in the morning might you be driving)
Set To time to whatever seems reasonable to you (I don't know how late you might be in your car)
Options - fixed time - yes.

Then link that trigger to the desired action (in your case, a beep sound).

So when you're in the car, and activate the flow, it'll wait until 58 mins past the hour to first sound a beep (and then it'll do it every hour thereafter). Because you've chosen "fixed time", this works regardless of the time when you activate the flow (e.g., if you activated the flow at 7:22AM, it'll still beep at 7:58AM - if you hadn't set "fixed time", then it'd beep 1 hour after you'd activated it, i.e. at 8:22AM)

User avatar
Philip
Posts: 82
Joined: 08 Jun 2015 19:20
Location: Hampshire, UK

Re: Triggering a flow at 2 minutes to every hour

Post by Philip » 26 Oct 2016 11:03

Thank you very much - that works perfectly, and is much more elegant than having 24 different triggers for the flow!

(Apologies for the delay in responding - I wanted to check my logs over a few days to ensure that it was doing what I wanted).
--
Philip

Post Reply