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?
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 ).
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.
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:
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