Different MQTT start-up messages between auto and manual sleep

When “Automatic sleep” is selected, MQTT changes as expected from “Sleepanalyse Stopped” to “Sleepanalyse started”

When manual started the sleep analyze and having set a wait-time on start, it doesn’t change from “Sleepanalyse Stopped” to “Sleepanalyse started”.
It goes from “Sleepanalyse Stopped” to “Sleepanalyse paused” to “Sleepanalyse resumed”

Imagine an integration with Home Assistant via MQTT, this requires different triggers like turning off the bed light when you start sleeping, you need to trigger on different things. I don’t want to trigger in the middle of the night again on “Sleepanalyse paused” to “Sleepanalyse resumed”

I would expect a structured logic to always start with “Sleepanalyse Stopped” to “Sleepanalyse started” The initial wait time is not the same as a nightly pause and resume, for which different triggers can be used.

And if I may add.
It’s odd to find the wait-time setting under the section “wake detection” as I would expect this under the “Automatic Sleep Analyse” section.

I’m using Sleep As Android 20250620 on Android 15 for many pleasant years and only recently been using the MQTT integration which really boosts my morning routine.

I’m reading up on the documentation of the possible MQTT attributes.
Not all of them are described here:
https://docs.sleep.urbandroid.org/services/automation.html#events

The documentation misses:

  • before_alarm
  • alarm_rescheduled

When “automatic sleep” is used and the alarm has started, the MQTT service never receives an “alarm_alert_start”. Instead it receives “before_alarm”.

Stopping an alarm via “automatic sleep” the MQTT messages goes from: before_alarmalarm_rescheduled → alarm_alert_dismiss → sleep_tracking_stopped.

Stopping an alarm via manual start, the MQTT messages are:
alarm_alert_start → alarm_alert_dismiss → sleep_tracking_stopped

The stopping sequence seems different between a manual and automatic started sleep as explained before. At least I can’t seem to find something else which could be the reason of a changed sequence.

This morning the “automatic sleep” process went from:
alarm_alert_start → alarm_alert_dismiss → sleep_tracking_stopped.

As it is not my own phone I need to further analyse this on a later moment.

Hi @sprk, the documentation was updated. Sorry it took me so long.
The events of alarm_alert_start and alarm_rescheduled are broadcasted about the same time, their order is not critical. The type of start of the tracking does not play a role in which intents the app sends.
If you think some of the intents are not triggered, you can send the application logs to support@urbandroid.org (Left ≡ menu → (?) Support → Report a bug), I will check, if they were broadcasted.