Use your alarm to simulate sunrise with SmartThings

Share and discuss your flows and ideas with other users.

Moderator: Martin

Post Reply
User avatar
Posts: 5
Joined: 12 Dec 2017 16:19

Use your alarm to simulate sunrise with SmartThings

Post by Scott12 » 06 Feb 2018 14:42

I created a routine that fires a SmartThings "Gentle Wake Up" routine 7 minutes before my phone’s alarm goes off. The SmartThings routine turns on a light at a very dim setting, then ramps up the brightness to a set level over a user-defined period of time. I typically get up around the same time on weekdays, but can vary sometimes by 20-30 minutes. 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.

Step 1: Set 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 (the SmartThings routine you created) in SharpTools ( (if you need help with SharpTools, the developer is extremely helpful)

Step 3: Build your flow
  1. Set Flow Name: “Start Morning Lights Before Alarm”
  2. Trigger: Time
    1. Weekdays: set as appropriate, I have M-F checked
    2. Time: set as appropriate, I set it to 5am
    3. Option: Allow in device idle/doze - CHECKED
    4. Option: Like alarm clock - UNCHECKED (It works fine without this. I tried having it checked, and I get a persistent alarm clock icon in my notification bar when all alarms are off, so I keep it unchecked)
  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
    1. 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)

    Code: Select all

    if (next_alarm == null)
    { delayMins = 999; }
    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)

    Code: Select all

    Expression: delayMins > 0 AND delayMins < 120;
  7. Action: Sleep
    1. Duration: {delayMins}m
  8. Action: Plugin: "A Thing"
    1. Device Type: Gentle Wake Up Controller
    2. Device: Wake With Bedroom Corner Lights
    3. Command: on
flow screenshot
AM_Morning.png (89.45 KiB) Viewed 2588 times
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.

Post Reply