Automate walkthroughs - Sleep as Android

Start sleep tracking with Automate

Download the flow here: http://llamalab.com/automate/community/flows/13614


This is a companion discussion topic for the original entry at https://docs.sleep.urbandroid.org//services/automate_walkthroughs.html
1 Like

Can Automate use the wearables intents?
Specifically the ones for data from wearable?
Commands from watch

@Fufu_508 I think this should work, what exactly are you looking for?

1 Like

Thanks. I want to read the sleep data from O2Ring CSV file, and push that data to SaA using llamalab.com Automate flow with one (or both?) of these blocks:
https://llamalab.com/automate/doc/block/activity_start.html
https://llamalab.com/automate/doc/block/activity_start_result.html

One question: Will this be an issue? This is mentioned in the “Input arguments” section at the links above.

As a small proof of concept I’d like to use the watch intent (6.1) below. So far I haven’t been able to find it in Automate.

6.1. Send movement data

  • Intent: com.urbandroid.sleep.watch.DATA_UPDATE

  • Extras:

    • MAX_RAW_DATA (float array): Array containing a geometric average of latest MAX values from the watch.

(I read the doc correctly, the intent above will automatically start a sleep tracking session, right?)

Regarding the above intent, will SaA automatically prepare to receive HR and oximeter data too, or do I need to use the intent below to explicitly prepare SaA to receive those?

5.1. Start movement tracking

  • Intent: com.urbandroid.sleep.watch.START_TRACKING
  • Extras:
    • DO_HR_MONITORING : enables Hear rate and HRV monitoring on the device
    • DO_OXIMETER_MONITORING : enables oximetry monitoring on the device

Is there an example Android app (Kotlin source available?) that demonstrates sending watch data to SaA?

Is Automate already whitelisted?

Due to intent restrictions in Android API levels > 26, we explicitly need to whitelist your package in Sleep if you want to use the API. Let us know at info@urbandroid.org, we’ll be glad to do that!

A little more info and a question:
In Automate I see a long list of activity classes, a few of which invoked the expected activity in Sleep.

Some of them fail though, and Automate logs an exception like this one.

12-13 19:01:40.937 I 334569@1: Flow beginning
12-13 19:01:40.943 I 334569@2: App start
12-13 19:01:40.952 F 334569@2: android.os.RemoteException: Remote stack trace: at
    com.android.server.am.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervi   sor.java:1841)
	at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:732)
	at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:556)
	at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1131)
	at com.android.server.am.ActivityStarter.execute(ActivityStarter.java:497)

12-13 19:01:40.953 I 334569@2: Stopped by failure

Unlike the one above, this one succeeded (com.urbandroid.sleep.alarmclock.SetAlarm) to open SaA, for example:

12-13 19:13:15.438 I 334570@1: Flow beginning
12-13 19:13:15.439 I 334570@2: App start
12-13 19:13:15.484 I 334570@0: Stopped at end

Here’s one where I attempted to assemble an intent that wasn’t listed in Automate but is in the SaA doc.

12-13 19:33:42.181 I 334572@2: App start
12-13 19:33:42.195 F 334572@2: android.content.ActivityNotFoundException: Unable to find explicit 
activity class {com.urbandroid.sleep/com.urbandroid.sleep.watch.PAUSE_FROM_WATCH}; have you 
declared this activity in your AndroidManifest.xml?
12-13 19:33:42.196 I 334572@2: Stopped by failure

I need to create a notification with the option to add a new sleep record. Unfortunately I can’t use com.urbandroid.sleep.AddRecordActivity and com.urbandroid.sleep.NewAddRecordActivity due to android.os.RemoteException.
How can I achieve this?

1 Like