Sleep as Android trigger "Good Night!" phrase?

I’m enjoying my time with ST… and having all of my connected lights turn off when I go to bed is great! What I would like to do, however, is tie in my Sleep as Android sleep tracking with the “Good Night” trigger, so as when I actually go to sleep, the rest of the lights will shut off, and the thermostat will be set to an appropriate night time temperature.

Ideally, it could also identify when ST is in Away mode, and not change to night mode in those cases when we may be staying out of town, etc.

Does anybody have some clear insight to how I could get these put together with Tasker, or SharpTools?

First, how do you want to indicate/detect sleep? The rest is easy.

I have a widget from Sleep as Android on my homescreen, when I tap it, it starts sleep tracking mode. According to the documentation, there are intents that can be subscribed to:

In particular:


Sleep tracking start intent

Sleep tracking stop intent

Aha, it’s an Android app.

Three ways:

  1. Ask them to integration with ST
  2. The way I recommend: They integrate with Tasker. There are threads/descriptions on how to integrate Tasker with ST (either IFTTT or Sharptools, can’t remember which, maybe even an easier way). I’d recommend this to start.
  3. I believe that you could make another Android app that watched for the intents, and then directly talked to ST. This could be a challenge unless you are an App developer.

Those are my thoughts.

Tasker is set of automation tools for Android and you can use the intents from Sleep as Android to trigger events in Tasker. SharpTools is a set of SmartThings Tasker plugins I developed which allow you to control your Things, execute Phrases (Routines), and change Modes.

Use the notes below to setup the profile to react to your Sleep as Android events, then use the A Phrase plugin from Plugins > SharpTools to run your Routine.

React to Sleep as Android events in Tasker
Setup a Tasker profile using Event -> System -> Intent and add one of the Intents described below.

Sleep tracking started

Sleep tracking stopped

Snoozed by user

Time to bed notification

Alarm triggered

Alarm dismissed

Lucid dreaming cue:
NOTE: enable settings-lucid dreaming

Antisnoring sound:

45 minutes before smart period:



There is also this. Future release date though.

Hey, thanks for the info! I just got done setting Tasker up to respond to SLEEP_TRACKING_STARTED and SLEEP_TRACKING_STOPPED, to try getting the current mode into the %st_mode variable, and only send “Good Night!” phrase if the current mode is Home, or send “Good Morning!” if the current mode is Night.

I’ll see if it works tonight, or if I have more tweaking to do yet :wink:

1 Like

Two options come to mind – you can either request the current mode each time your event triggers or you can subscribe to mode changes and always have the latest up to date mode.

Option 1

The first option is a bit easier to understand, but it will result in a few second delay each time the sleep tracking is started or stopped as SharpTools has to go out and request the mode each time:

  1. Open your SLEEP_TRACKING_* event profile
  2. Add an action using Plugin > SharpTools > Mode: Get Current
    Note: This will set the variable %st_mode with the name of your current mode
  3. Add both of your actions to run your desired phrases and make them conditional
  4. Add the action using Plugin > SharpTools > A Phrase
  5. Select your desired phrase from the list and hit apply (eg. Good Night!)
  6. While you are still in the action, add an If conditional (eg. %st_mode ~ Home)

For more information on using conditional actions, see this article:

Option 2

The other approach requires you to setup a separate profile to listen for the mode changes and then save that variable to a global variable, but results in the mode variable already being set so it reacts quicker.

Saving the Mode

  1. Open the main SharpTools app, select Modes from the left navigation, long press on any mode and choose Subscribe to all mode changes
  2. Create a new Tasker profile using Event > Plugin > SharpTools > Mode Change
  3. In the Task, create an action using Variables > Variable Set
    Name: %STMODE
    To: %st_mode

Reacting to the Sleep as Android Event

  1. Open your SLEEP_TRACKING_* event profile
    Note: You don’t need the Get Mode action here since the global %STMODE will already be set
  2. Add both of your actions to run your desired phrases and make them conditional
  3. Add the action using Plugin > SharpTools > A Phrase
  4. Select your desired phrase from the list and hit apply (eg. Good Night!)
  5. While you are still in the action, add an If conditional (eg. %STMODE ~ Home)

For more information on saving status from events, see this article:

1 Like

Heyyyyy, looks just like what I did this morning to fix it… First time that I’ve used the If function in Tasker, so I unknowingly changed the ‘~’ to equals… Didn’t know that equals was for numbers and ‘match’ was for string. Once I fixed that, it worked like a charm!

Just discovered this thread. Fantastic!


Thanks for taking the time to simplify this.

1 Like