System sleep trigger only during a specific Time of day?


#1

I am trying to create a macro that triggers when I put computer to sleep but want it to trigger only at the end of the day at say after 2 am in the night.

Can't seem to figure out a way.

Plus I think it will be more useful to create a 2am - 4am window for the macro so that it doesn't occur any other time.


#2

One way is to add an Assert action to the top of the macro that makes sure the HOUR() function returns a value greater than or equal to 2, and less than or equal to 4, i.e. the 2am–4am window, before the macro proceeds:

image

Another way would be to not use the sleep trigger, but instead to make your Mac sleep by adding a Sleep action to the end of the macro you have now and using a Cron trigger to run the macro at 2am every night:

11%20PM


#3

Generally you would just trigger on the sleep, and then check the time. I would use a If Then Else action, rather than an Assert action, but the idea is the same. You can also use the calculation

HOUR() ≥ 2 AND HOUR() ≤ 4