Sunset and Sunrise triggers don't work - resolved

Volmark

Member
Sunset and Sunrise triggers don't work on Motorola g30. But they do work on Samsung devices (Tab A Andr 11 and J600 Andr 10)
 

Attachments

  • Day-Night.png
    Day-Night.png
    159.1 KB · Views: 13
Last edited:

Abalsam

Active member
Sunset and Sunrise triggers don't work on Motorola g30. But they do work on Samsung devices (Tab A Andr 11 and J600 Andr 10)
I know this is probably a waste of time to ask the question but in order for macrodroid to properly calculate sunrise and sunset, you have to preset the location to use in trigger settings. Since that must be done on each device and is not something that can be copied down with the macro, I just wanted to confirm you did set that info on the non working device?

If you have and it's still not working, I have a working routine (adapted from an example macro provided by tanutanu which sends a web query (including the device's location) to get the day's sunrise and sunset (which I can then use to set stopwatch triggers). Please let me know and I can extract that portion of the larger macro.

Thanks
 

Volmark

Member
I know this is probably a waste of time to ask the question but in order for macrodroid to properly calculate sunrise and sunset, you have to preset the location to use in trigger settings. Since that must be done on each device and is not something that can be copied down with the macro, I just wanted to confirm you did set that info on the non working device?

If you have and it's still not working, I have a working routine (adapted from an example macro provided by tanutanu which sends a web query (including the device's location) to get the day's sunrise and sunset (which I can then use to set stopwatch triggers). Please let me know and I can extract that portion of the larger macro.

Thanks
Thanks for the answer. Your suggestion is very interesting. I didn't think about the location.
I don't know how to preset the location in trigger settings.
In general, I would really like to look at the solution that you mentioned. Can you post it please?
 

Abalsam

Active member
Thanks for the answer. Your suggestion is very interesting. I didn't think about the location.
I don't know how to preset the location in trigger settings.
In general, I would really like to look at the solution that you mentioned. Can you post it please?
From the home screen select the settings icon (right most icon on bottom of screen).
That will bring up this screen:
Screenshot_20220210-222432~2.png

From the settings screen select Trigger Options which will take you to this screen:
Screenshot_20220210-222441~2.png

From the trigger options screen select Sunset/Sunrise which will take you to this screen:
Screenshot_20220210-222504~2.png

From this screen select the one option which will open a map for you to define the location to use.

Hope that helps.
 

stsu

New member
Is there a possibility to adjust this setting with current location? Maybe with a macro to adjust every 24 hours?
 

Dimlos

Well-known member
@stsu I have created a macro that displays the sunrise and sunset for the current location, although it cannot be used as a trigger.
Please try it if you like.
 

Attachments

  • Sunrise_and_Sunset_Time.macro
    11.5 KB · Views: 6

stsu

New member
@stsu I have created a macro that displays the sunrise and sunset for the current location, although it cannot be used as a trigger.
Please try it if you like.
Thanks a lot for your macro.
But as you mentioned, I can't use it as trigger. The trigger is part of MacroDroid (trigger sunrise/ sunset). But first you have to define your location....and if you change your location, you have to set your location again.
What I am looking for, is a macro which set every 24 hours the current location of my mobil as the trigger sunrise/sunset location of MacroDroid.
 

Dimlos

Well-known member
Maybe that would have to be implemented as a feature of MacroDroid to make it happen.
Why don't you post it to Feature Request?
 

RSF

Well-known member
@stsu - You can use @Dimlos ' idea about using stopwatches to create a trigger when each day's sunset time is reached. The attached macro gets the current location's sunset time each day at 4pm, and sets a stopwatch-related variable which triggers when sunset occurs.
 

Dimlos

Well-known member
@RSF Are you sure you're not missing the timezone calculation, because the time returned by the API is UTC+0000, so the time is probably off.
My macro is UNIX Time once and reconverted to UNIX Time so that the time zone of the system setting is applied.
However, I think it is still incomplete because the time should be shifted when moving to a location in a different time zone.
 

RSF

Well-known member
@Dimlos - Great catch.Thank you. Indeed I missed the timezone/UTC aspect of the API. I threw the macro together on my Chromebook (since it has a keyboard and nice big screen) and weirdly (since Chromebooks don't really emulate Android 100% especially around location and system settings) it looked like it worked OK. Lesson learned to always test on an actual Android phone...

@stsu - Please try the attached macro instead, if you're still looking for a sunset trigger scheme.
 

Attachments

  • Sunset_pseudo-trigger2.macro
    11.1 KB · Views: 8

stsu

New member
Thanks a lot to both for your work and inputs!
Now I assume (I haven't changed my location yet) the second marco works fine.
Nevertheless I will post it in Feature Request.
 

RSF

Well-known member
Yes, I tested version #2 (on my phone this time) and it worked.

Note that
  1. Of course you'll want to change the Log Event action to whatever you want to run at sunset and
  2. The macro checks the sunset time (and sets the associated Stopwatch and trigger) at 4pm each day. I guessed that'd make sense for someone traveling on business as one is normally in a new time zone/location by 4pm (at least in my experience). You may want to change that, however, to an earlier time, or additional times, or maybe change it to check anytime Airplane Mode is disabled (if you take planes), or anytime you connect to a wifi network (if you stay in hotels on travel) -- depending on how you travel between locations.
 

Nonhocapito

New member
Yes, I tested version #2 (on my phone this time) and it worked.

Note that
  1. Of course you'll want to change the Log Event action to whatever you want to run at sunset and
  2. The macro checks the sunset time (and sets the associated Stopwatch and trigger) at 4pm each day. I guessed that'd make sense for someone traveling on business as one is normally in a new time zone/location by 4pm (at least in my experience). You may want to change that, however, to an earlier time, or additional times, or maybe change it to check anytime Airplane Mode is disabled (if you take planes), or anytime you connect to a wifi network (if you stay in hotels on travel) -- depending on how you travel between locations.
Could this be used to trigger something at sunrise as well? Should I duplicate the entire macro or just part of it?
 

RSF

Well-known member
It would work for sunrise as well -- that web-service call returns both sunrise and sunset times for the location that's passed to it.

You'd need the whole macro, just as for the sunset scheme. You'll need to edit "sunset" to "sunrise" for variable and stopwatch names, and change the Day/Time Trigger to be 4am (a time guaranteed to be before sunrise).

(Note that if you don't travel between time zones, the built-in Sunrise trigger would work fine and be more straightforward)
 
Top