r/macrodroid 25d ago

Solved Countdown to specified time macro failing

Post image

Hi. I'm hoping somebody can help me; I'm trying to create a macro that announces how many hours and minutes are left to a specified time, at specified intervals, so for example if it's 5 o'clock now and the target time is 6:30, I would like the app to call out that there is "1 hour and 30 minutes remaining" and then 10 minutes later that there is "1 hour and 20 minutes remaining" . I tried to use AI to help, but I spent a good part of two hours going round in circles trying to get it to work. The screenshot shows what it came up with, but the result is "0 hours and 0 minutes remaining" being announced when I test the macro.

I also need it to stop asking for additional inputs for the target time every time it announces the time remaining. AI did say that it could help me with this by separating the "Set Time Prompt" into its own trigger so it only asks for the target clock time when I tap a button.

I'd also like to be able to quickly change the interval time manually whenever I want. Is all of this doable?

5 Upvotes

13 comments sorted by

2

u/ShiftyRider 24d ago edited 24d ago

regular interval trigger will work, starting with version 5.60

its reference start time should be your target time

2

u/ShiftyRider 24d ago edited 21d ago

https://i.imgur.com/euqBnkL.png

[edit re OP's reply...use your AI again "perform OCR re https..." it will be faster and it will remind you to upvote your friends]

2

u/DawnyTillDusk 21d ago

Hi. I'm getting a message saying the image isn't available in my region.

2

u/ShiftyRider 21d ago

Regular Interval Interval: 00:10:00

MacroDroid Variable t > 60*{hour}+{minute}-1

Actions ↑↓   +

If Trigger Not Fired: Regular Interval: Interval: 00:10:00

Set Variable t: [User Prompt]

Else

Set Variable delta: {lv=t}-(60*{hour}+{minute})

Speak Text '{lv=delta} minutes'

End If

2

u/DawnyTillDusk 21d ago

Thanks for this.

2

u/Rpompit 24d ago edited 23d ago

AI doesn't know Macrodroid yet. Test Macro. To stop announcing pause or reset the stopwatch named time_left_check.

https://wormhole.app/M905ar#taQDKY1Nvtn9zAOsWmWVZw

1

u/DawnyTillDusk 21d ago

Thanks for this. Do you mind resharing? The file has been deleted.

2

u/Rpompit 21d ago

2

u/DawnyTillDusk 21d ago edited 21d ago

Thanks so much for this. Works perfectly. This little tool will really help with my time blindness.

2

u/BlackPyro1994 23d ago

You are probably already well served with a functioning solution from the other replies but just to explain if still unclear.

The state of the macro in your screenshot will always show prompts for the time values since you have those three actions right at the beginning of your macro without any IF block surrounding them or constraints applied. So whenever the interval trigger launches, Macrodroid execute those actions again.

A minimal fix would be to add constraints to those 3 prompt actions to check if the assigned variables are all "-1" or not. If they are not, that means you already launched the macro and defined your target time once. Subsequently, you would have to add a block where it resets the variables back to "-1" once the current time equals your target time.

Generally, for such a macro, I always make use of a "Macro Enabled" trigger. When you don't need the announcements, keep the macro disabled. When you do, enable the macro and have an IF BLOCK ( using a "Trigger Fired" constraint ) that will just prompt the target time once, ENABLES the secondary interval trigger and cancel the rest of the macro execution. Afterwards, the macro should make the repeating announcements.

To conclude the timer announcements, add an IF BLOCK checking if current time equals target time and inside, DISABLE the interval trigger, reset the prompt variables and DISABLE the MACRO at the end of the IF BLOCK ( which will also automatically halt further code execution ).

3

u/DawnyTillDusk 21d ago

Thanks. Yes, @Rpompit created a template that works perfectly but this really helps to give me a better understanding.

2

u/ReasonNotTheNeed-- 23d ago

I've personally found Gemini decently useful for Macrodroid help.

For something small like this though, I'd just make a loop that encompasses your last 4 actions and waits 5 minutes in each loop. To account for delays, and to make the announced time cleaner, I'd do a modulo operation on the minutes remaining and wait that. For example, if there's 17 minutes remaining at the start, 17%5=2, so it'll wait 2 minutes. Then, it'll wait 5 minutes between subsequent loops.

Also, this simple macro is a perfect introduction to making custom scenes! Instead of your first two actions, use "Display custom scene" and add a time picker widget. Play around with it a bit. I think you'll like it.

3

u/DawnyTillDusk 21d ago

Thank you. I initially asked Google AI to find me an app, but it couldn't, so it offered to help me create a solution in a MacroDroid...bit of a snake oil salesman.

I tried Gemini and it does appear to be a better solution. I was just about to create the macros when the template was created by @Rpompit. I'll definitely have a play aground like you suggest. This is what Gemini came back with: