Automation

1. What it does

Sleep as Android can be used to automate your smart devices or other applications through various services:

2. Where to find it

Settings → Services → Automation

3. Options

Events

Set events that will be sent from Sleep as Android to each automation service.

Tasker
Tasker

Enable or disable Tasker integration.

IFTTT
IFTTT

Enable or disable IFTTT integration.

Webhooks
Webhooks

Enable or disable custom webhooks integration.

URL

Set URL of your custom webhooks endpoint.

MQTT
MQTT

Enable or disable MQTT integration.

URL

Set URL of your MQTT broker.

Client ID

Set client ID under which Sleep as Android will connect to the MQTT broker. Warning: You cannot have multiple devices connecting under the same Client ID to the same broker. Default: "SleepAsAndroid"

Intent API
Intent API

Enable or disable intent API.

4. Guide

4.1. Events

The events that will be sent to each automation service can be toggled in Settings → Services → Automation → Events.

The events are:

sleep_tracking_started

…​

sleep_tracking_stopped

…​

sleep_tracking_paused

…​

sleep_tracking_resumed

…​

alarm_snooze_clicked

You have snoozed a ringing alarm.
We are sending the following values:

  • value1: UNIX timestamp of the alarm start time, example: "1582719660934"

  • value2: alarm label, example: "label" (Any tabs and newline characters in the label will be removed before sending)

alarm_snooze_canceled

You have a canceled an alarm that is currently snoozed.
We are sending the following values:

  • value1: UNIX timestamp of the alarm start time, example: "1582719660934"

  • value2: alarm label, example: "label" (Any tabs and newline characters in the label will be removed before sending)

time_to_bed_alarm_alert

Fires when you get a bedtime notification.
We are sending the following values:

  • value1: UNIX timestamp of the alarm start time (the alarm which triggered the bedtime notification, based on your ideal daily sleep income), example: "1582719660934"

alarm_alert_start

Fires when alarm starts.
We are sending the following values:

  • value1: UNIX timestamp of the alarm start time, example: "1582719660934"

  • value2: alarm label, example: "label" (Any tabs and newline characters in the label will be removed before sending)

alarm_alert_dismiss

Fires when you dismiss alarm (after you solve CAPTCHA, if it’s set).
We are sending the following values:

  • value1: UNIX timestamp of the alarm start time, example: "1582719660934"

  • value2: alarm label, example: "label" (Any tabs and newline characters in the label will be removed before sending)

alarm_skip_next

Fires when you tap dismiss an alarm from notification before it actually rings.
We are sending the following values:

  • value1: UNIX timestamp of the alarm start time, example: "1582719660934"

  • value2: alarm label, example: "label" (Any tabs and newline characters in the label will be removed before sending)

show_skip_next_alarm

Fires exactly 1 hour before the next alarm is triggered.

  • value1: UNIX timestamp of the alarm start time, example: "1582719660934"

rem

Fires when we estimate the start of REM phase.

smart_period

Fires at the start of the smart period.

before_smart_period

Fires 45 minutes before the start of smart period.
We are sending the following value:

  • value: alarm label, example: "label" (Any tabs and newline characters in the label will be removed before sending)

lullaby_start

Fires when lullaby starts playing.

lullaby_stop

Fires when lullaby is stopped (either manually or automatically).

lullaby_volume_down

Fires when we detect you fell asleep and starting lowering the volume of lullabies.

deep_sleep

Fires when we detect you going into deep sleep phase. Warning: This may result in lots of events during the night and may not exactly fit the resulting sleep graph as we can only detect phases reliably from whole-night data.

light_sleep

Fires when we detect you going into light sleep phase. Warning: This may result in lots of events during the night and may not exactly fit the resulting sleep graph as we can only detect phases reliably from whole-night data.

awake

Fires when we detect you woke up.

not_awake

Fires when we detect you fell asleep.

apnea_alarm

Fires when we detect a significant dip in your oxygen levels.

antisnoring

Fires when antisnoring is triggered.

sound_event_snore

Fires when we detect snoring.

sound_event_talk

Fires when we detect talking.

sound_event_cough

Fires when we detect coughing.

sound_event_baby

Fires when we detect baby cry.

sound_event_laugh

Fires when we detect laughter.