[RELEASE] A slightly better sunset timer

smartapp_alerts

(Mcilroyc) #1

Hi -

I built a simple smartapp that sends me a reminder every day at or near sunset based on a simple offset (in minutes, plus or minus). https://gist.github.com/mcilroyc/ee568d5a373bb199379b

I found all the example apps to be insufficient and/or buggy.

I started with this example app:

My version includes improvements to the above:

  1. Proper handlng of post-sunset reminders by using two alternating event handlers, avoiding the collision on the runOnce scheduler
  2. If installing/updating app after today’s sunset, schedule tomorrow’s in addition to today’s
  3. Use event’s dateValue() to avoid parsing a date string

Thoughts appreciated.


(Brian Diehl) #2

I updated the thread title to include [RELEASE] so everyone knows it’s a SmartApp release thread and not a question/complaint.


(Amit Bahree) #3

Question - could I use this to trigger our Evening routine , which is currently based on the sunset time and can offset some minutes, but it is almost always either too early or too late. Is there an option where I could match it up with the lux level and based on either of those trigger the routine? Appreciate any thoughts. Thanks.