Trigger time/date/sunrise action if missed.

Nonhocapito

New member
I noticed one issue with the sunrise/sunset trigger.

It seems that, if your phone was off during the trigger (for example at sunrise), then when you turn on the phone later, the action won't be triggered.

Is there a workaround to this? A setting to trigger actions when the scheduled event was missed?
 

Snurre

Well-known member
Can you elaborate? Once macrodroid knows the device was just booted, how does it know whether it just missed sunset or sunrise?
If you set a var (feks boolean) to true when sunset/sunrise trigger is fired , then you could check this var when boot trigger is fired
 

Endercraft

Moderator (& bug finder :D)
If you set a var (feks boolean) to true when sunset/sunrise trigger is fired , then you could check this var when boot trigger is fired
How would it fire if the device was off ? It would not be needed if it was on.
 

Nonhocapito

New member
How would it fire if the device was off ? It would not be needed if it was on.
Yeah I am not sure how this would work.

True, at boot, via variable, it would see that one of the two actions was not performed, but: there would be no way to tell if this is normal (sunrise or sunset haven't happed yet), or if something is amiss.

Notice that, if one action sets the variable fired-at-sunrise to true, it should logically at the same time set the variable fired-at-sunset to false.

So, at any time there would always be one variable set to false, the other to true, and no way to tell if the situation is normal or something went wrong.

Unless, perhaps, there was a script to check in what portion of the day the phone has been turned on, compared to when sunset and sunrise are, and therefore check what variable it should expect to find to be true.

But, if I had such a script... I wouldn't even need to have an action triggered by macrodroid's sunset/sunrise in the first place.
 
Last edited:

Endercraft

Moderator (& bug finder :D)
What you could do (but may not work in all cases) is have a macro trigger when this intent is received :
android.intent.action.ACTION_SHUTDOWN
then set a variable with a constraint like if before sunrise. Then with a device boot trigger, check if you are after sunrise and check the variable, and if the constraints meet then do the actions (Note : it will not work if you force-shutdown because it is instantaneous).
 

Nonhocapito

New member
Actually my phone is usually shut off by macrodroid itself, as I have a macro for this purpose (as I often fall asleep with the phone on). It only works with the "alternate" shut down, not sure if it's the forced kind, but I think so.

I am now working on a more complex macro... I am modifying an existing one I found which takes the sunrise/sunset times from an api on the internet and puts them in a variable (sorry don't have the link at hand right now)

Once I have the seconds until sunset or sunrise in variables, I can then do:

If seconds after sunrise > seconds after sunset
(It means sunset is the next in line, but it's not sunset yet)
I run my action related to sunrise, regardless of when I booted my device.

The whole thing looks good but I haven't tested it yet.
 
Last edited:

Endercraft

Moderator (& bug finder :D)
It only works with the "alternate" shut down, not sure if it's the forced kind, but I think so.
It is the forced kind, but then it doesn't matter because you can use that macro instead to set the variable instead.

Personally I use a feature that automatically shuts down and boots my phone (shut down at 3 AM and boot 3:30 AM, to simulate a reboot and to let it cool down a bit, but other than that it should always be on). MD keeps track of this, and I have a variable set so my SIM is unlocked automatically if it was before the long false reboot.
 
Top