[HOW TO] Gentle Wake Up Triggered by Android Alarm (with Automagic & SharpTools)


(Scott H) #1

I created a routine that fires my Gentle Wake Up routine 5 minutes before my phone’s audible alarm goes off. I dug around the forum a bit to see how others have used the gentle wake, but it looks like they were all using the builtin features of either a fixed time schedule or some manual activity. I typically get up around the same time on weekdays, but can vary sometimes by 20-30 minutes, and I don’t want to have to remember to go into SmartThings and turn the process off if I’m not going to work in the morning. I have multiple alarms saved that I label like, “Work”, “Work Late”, etc. I always turn my alarm on before I go to bed, choosing the one that is appropriate. After setting up this, I simply edited them to go off 5 minutes earlier, and be silent.

Step 1 of course, is setting up the Gentle Wake routine in SmartThings. I called mine “Wake With Bedroom Corner Lights”. I recommend an incandescent light for this, I can’t get LEDs to start anywhere near as dim as an incandescent.

Step 2: Authorize your new thing in SharpTools (if you need help with SharpTools, the developer, @joshua_lyon, is active here and is extremely helpful)

Step 3: Build your flow in Automagic ($3.90 currently - if you want to try it out, you can get a trial version from the Automagic website here)

  1. Set Flow Name: “Start Morning Lights With Alarm”
  2. Trigger: Next Alarm
  3. Condition: Time Range (only continue if within the defined range - I set this to weekdays from 5am-7am)
  4. Condition: Expression: global_me_home (this is tied to my presence routine, if I’m not home, I don’t want my bedroom lights turning on. You can skip this or base it on SmartThings default “Home” mode if that works for you)
  5. Action: Plugin: "A Thing"
    a. Device Type: Gentle Wake Up Controller
    b. Device: Wake With Bedroom Corner Lights
    c. Command: on
  6. Action: Script: (I have my phone alarm ring 5 minutes after my lights start, change the parameter here if you want a different duration)
    time5=addMinutes(triggertime, 5);
    h="{time5,dateformat,HH}";
    m="{time5,dateformat,mm}";
  7. Action: Set Alarm
    a. Hour: {h}
    b. Minute {m}
  8. Action: Set Flow State (disable this flow for the day so it doesn’t restart when the audible alarm starts - I enable the flow in my bedtime routine, but you could just enable it based on a time trigger)
    a. Flow pattern list: "Start Morning Lights With Alarm"
    b. Enable or disable flows: Disable

Step 4: Set up your Android alarm - this is just an easy way to set your trigger for the Automagic flow (I use the Google Clock app - I’m sure there are others that would work, but the Samsung one defaults new alarms to giving you a Bixby report, rather than having a default alarm tone)

  1. Set the alarm for 5 minutes BEFORE you want to wake (this is when the lights will start coming on)
  2. Set the alarm to Silent and turn off vibrate

I’ll probably fiddle with the ramp-time a bit, maybe start it a bit earlier and spread out the dim up time, but I really like having the light start to wake me up before my alarm sounds.

.
EDIT: Updated the image to a 16:9 ratio so it displays right in the post, thanks @joshua_lyon for the tip


(Joshua Lyon (SharpTools.io Dashboard)) #2

Very cool use of SharpTools and Automagic - thanks for sharing!

It’s great to see a use-case using an alternative to Tasker. The programming-like nature of Tasker can scare some people away whereas the decision-flow design of Automagic is at least a little bit more inviting.

Edit: I’m not certain, but it seems like Discourse crops images which are taller than 16:9 (git commit | post)


(Scott H) #3

New & Improved Version 2!!

I didn’t like the fact that I had to set my wake up alarms for earlier than I actually wanted to wake up, and even more, I didn’t like the fact that I had to set them as silent for v1. If the flow failed for any reason, I would get no audible alarm, which is bad™.

So here’s version 2.

So the background in case you didn’t read the 1st post: I have multiple alarms saved that I label like, “Work”, “Work Late”, etc. I always turn my alarm on before I go to bed, choosing the one that is appropriate. This process starts a Gentle Wakeup Controller a few minutes before any of my alarms go off between 5am & 7am on a weekday.

Step 1 of course, is setting up the Gentle Wake routine in SmartThings. I called mine “Wake With Bedroom Corner Lights”. I recommend an incandescent light for this, I can’t get LEDs to start anywhere near as dim as an incandescent.

Step 2: Authorize your new thing in SharpTools (if you need help with SharpTools, the developer, @joshua_lyon, is active here and is extremely helpful)

Step 3: Build your flow in Automagic ($3.90 currently - if you want to try it out, you can get a trial version from the Automagic website here)

  1. Set Flow Name: “Start Morning Lights Before Alarm”

  2. Trigger: Time
    a. Weekdays: set as appropriate, I have M-F checked
    b. Time: set as appropriate, I set it to 5am
    c. Option: Allow in device idle/doze - CHECKED
    d. Option: Like alarm clock - UNCHECKED (I’m not completely clear what this would do, but maybe it should be checked too…)

  3. Condition: Expression: global_me_home (this is tied to my presence routine, if I’m not home, I don’t want my bedroom lights turning on. You can skip this or base it on SmartThings default “Home” mode if that works for you)

  4. Action: Init Variable Next Alarm
    a. Variable: next_alarm

  5. Action: Script (check if there’s an alarm set, then set some variables for later use - I have my lights start 7 minutes before the alarm, change the 7 in the last line of code to whatever you want as your lead-in)

    if (next_alarm == null)
    { delayMins = 999; }
    else
    {
    nextMins = ("{next_alarm,dateformat,HH}" * 60) + “{next_alarm,dateformat,mm}”;
    curMins = ("{getDate(),dateformat,HH}" * 60) + “{getDate(),dateformat,mm}”;
    delayMins = nextMins - curMins - 7;
    }

  6. Condition (I use a 2 hour window starting with the 5am trigger time)

    Expression: delayMins > 0 AND delayMins < 120;

  7. Action: Sleep
    a. Duration: {delayMins}m

  8. Action: Plugin: "A Thing"
    a. Device Type: Gentle Wake Up Controller
    b. Device: Wake With Bedroom Corner Lights
    c. Command: on

Step 4: Set up your Android alarm. Any alarm app should work, I’ve used the Google Clock app and Sleep for Android.

I’ll probably fiddle with the ramp-time a bit, maybe start it a bit earlier and spread out the dim up time, but I really like having the light start to wake me up before my alarm sounds.


(Adam Skoreyko) #4

Thank you so much for posting/creating this!

I just recently purchased a Philips Wake-Light from Amazon for a decent chunk of money and after using it a few times find it very un-intuitive and clumsy. I also don’t like the idea of going away from a ‘smart’ device and using something that feels like I would of had it in the 90’s.

So I decided to do some digging thinking Smartthings should be able to do this for me and after looking at a few options that seemed clunky (as you mention in your own write-up) this seems idea. The fact that I can use the native alarm functionality on my android phone seals the deal for me.

Thanks again for posting this!


(Scott H) #5

I’m glad you like it!

I will say that it’s not 100% effective - sometimes the light fails to start. I usually snooze my alarm for 5min the 1st time it fires, so if the light isn’t on, I hit a SharpTools shortcut to start the Gentle Wake process at the 1st alarm. I haven’t taken much time to DX the issue, but the Automagic process is completing successfully, so I assume it’s a communication failure between Automagic & SharpTools, or between SharpTools & SmartThings.


(Joshua Lyon (SharpTools.io Dashboard)) #6

If you have any logs from AutoMagic and SharpTools from the time of a failure (or the next failure), I’d love to see them. A handful of users are seeing inconsistency with Tasker and I’m trying to track down what’s similar between the devices.

I have the same device, patch level, software versions, etc as some users and I can’t seem to reproduce it, so any additional data would be helpful!


(Scott H) #7

I’ll try to remember to grab logs next time it fails…