-
• #2
I didn't know about this and my banglejs 2 also doesn't connect. I'm happy to test and support the integration.
-
• #3
I'm glad to know it's not just me :)
My guess is the Sleep as Android app is sending JS code to the Bangle.js 2 watch via the Bangle.js Gadgetbridge app, and expecting some sort of reply (perhaps via Android Intents?) that it doesn't receive.
I'll try to look into the Gadgetbridge debugging advice soon. You might be able to find something with it, too?
https://www.espruino.com/Gadgetbridge#debugging -
• #4
UPDATE: fetching Gadgetbridge debug logs, I see… nothing from Sleep as Android in Gadgetbridge's logs.
I have my custom code snippet from Tasker successfully shown and parsed, though.
Perhaps there's something between Bangle.js Gadgetbridge and Sleep as Android that needs fixed?
I do frequently see the following, but I suspect it's unrelated:
[JCould not load clock info "sched.clkinfo.js"
Looking at
adb logcat
, it seems like Sleep as Android is listening for acom.urbandroid.sleep.watch.CONFIRM_CONNECTED
broadcast:03-22 16:23:56.110 20919 20919 I SleepAsAndroid: [22Mar 16:23:56.110, main]: Theme: setting last SmartWatchActivity 16 03-22 16:23:56.110 20919 20919 I SleepAsAndroid: [22Mar 16:23:56.110, main]: SmartWatchActivity:onCreate() {EX:null} [I: {EX:test_sensors (true) }] 03-22 16:23:56.122 20919 20919 I SleepAsAndroid: [22Mar 16:23:56.122, main]: onCreate SmartWatchActivity wearable Bangle.js 03-22 16:23:56.123 20919 20919 I SleepAsAndroid: [22Mar 16:23:56.123, main]: SmartWatchActivity:Async connecting smart watch 03-22 16:23:56.123 20919 20919 I SleepAsAndroid: [22Mar 16:23:56.123, main]: SmartWatch: Async smart watch connect called 03-22 16:23:56.123 20919 20919 I SleepAsAndroid: [22Mar 16:23:56.123, main]: SleepPhaser: GET address null 03-22 16:23:56.123 20919 20919 I SleepAsAndroid: [22Mar 16:23:56.123, main]: SleepMaskBt: GET address null 03-22 16:23:56.124 20919 20919 I SleepAsAndroid: [22Mar 16:23:56.124, main]: Using watch accel: BaseWatchAccelManager 03-22 16:23:56.124 20919 20919 I SleepAsAndroid: [22Mar 16:23:56.124, main]: SmartWatch: ConnectivityChecker registering receiver for com.urbandroid.sleep.watch.CONFIRM_CONNECTED watch com.urbandroid.sleep.smartwatch.generic.GenericWatch@6946671 […] 03-22 16:23:56.131 20919 20919 D SleepAsAndroid: [22Mar 16:23:56.131, main]: SmartWatchActivity:onStart() 03-22 16:23:56.132 20919 20919 D SleepAsAndroid: [22Mar 16:23:56.132, main]: SmartWatchActivity:onResume() 03-22 16:23:56.133 20919 20919 I SleepAsAndroid: [22Mar 16:23:56.133, main]: Theme: onPostResume() SmartWatchActivity 03-22 16:23:56.138 1810 4994 D CoreBackPreview: Window{d471394 u0 com.urbandroid.sleep/com.urbandroid.sleep.SmartWatchActivity}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.IOnBackInvokedCallback$Stub$Proxy@3722632, mPriority=0} 03-22 16:23:56.145 20919 29298 E OpenGLRenderer: Unable to match the desired swap behavior. 03-22 16:23:56.152 20919 29298 W Parcel : Expecting binder but got null! 03-22 16:23:56.167 1810 1933 I ActivityTaskManager: Displayed com.urbandroid.sleep/.SmartWatchActivity: +81ms 03-22 16:23:56.234 20919 20919 I SleepAsAndroid: [22Mar 16:23:56.233, main]: Theme: onPostResumeAfterRecreate() […] 03-22 16:23:56.747 20919 20919 D SleepAsAndroid: [22Mar 16:23:56.747, main]: AlarmClock:onStop() 03-22 16:23:56.752 20919 20919 D SleepAsAndroid: [22Mar 16:23:56.752, main]: SimpleSettingsActivity:onStop() 03-22 16:23:56.753 20919 20919 D SleepAsAndroid: [22Mar 16:23:56.753, main]: TrackSettingsActivity:onStop() 03-22 16:23:56.754 20919 20919 D SleepAsAndroid: [22Mar 16:23:56.754, main]: SmartwatchSettingsActivity:onStop()
This matches up with the Sleep as Android Wearable integration API documentation:
https://docs.sleep.urbandroid.org/devs/wearable_api.html#initiating-connection-to-phoneI git-clone'd the Gadgetbridge source code and searched recursively for
CONFIRM_CONNECTED
, but didn't find it anywhere. -
• #5
IGNORE THIS (can't delete)
In Gadgetbridge, tap on the gear of your Bangle.js and enable "allow 3rd party apps to change wettings", maybe? -
• #6
I use Gadgetbridge in German. For me, when I tap the gear at my BangleJS, there is no "allow 3rd party apps to change settings" or its translation. But I activated (translated by me): "Text as bitmap", "Allow internet access" and "Allow intents"
Using Gadgetbridge version 0.71.2a-banglejs -
• #7
Someone has stepped up to work on Sleep as Android support in Gadgetbridge!
https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/3188
It looks like they are focusing on the Mi Band (based on the PR branch name), but this could potentially be used as the foundation for Bangle.js 2 support, too.
-
• #8
I have the same issue. It would be awesome if the Bangle.js2 can integrate with Sleep as Android.
I would be glad to help debugging, testing, coding to find a solution. However I'm not sure where to start. Anyone with advice? -
• #9
Gadgetbridge Sleep As Android integration imminent (Probably. For nightlies at least): https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/3687#issuecomment-1765530
Bangle.js sleep sync is in talks also: https://github.com/espruino/BangleApps/issues/3275
-
• #10
Hey,
I just got hands-on experience and tried implementing the Sleep as Android integration for Banglejs. It was relatively straightforward, but I still need to figure out how to enable or disable my Bangle app from Gadgetbridge.
My current solution is:
- Create a simple app that provides all relevant measurements for Sleep as Android (Movement, Heart Rate). I've already got this working.
- Make it possible to start/stop the app from Gadgetbridge. If you know of a good way to do this, feel free to chime in!
- Create a simple app that provides all relevant measurements for Sleep as Android (Movement, Heart Rate). I've already got this working.
-
• #11
In case anyone missed this, Sleep as Android support will be available soon, courtesy of AnotherStranger (thank you!)…
- https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/3785 has been merged (not yet in a stable release)
- https://github.com/espruino/BangleApps/pull/3422 is available on the Bangle.js app site
- https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/3785 has been merged (not yet in a stable release)
-
• #12
@AnotherStranger Thank you for your efforts and time investment in securing this functionality!
I've looked into the implementation and while I get a gist of the changes, I can't figure out how to get the integrations to play nice.
As far as I understand, I should get things going through the following setup:
- Latest version of Gadgetbridge
- Latest version of Bangle2.js bootloader
- Latest version of Sleep as Android
There are new exposed settings in Gadgetbridge that relate to Sleep as Android.
I can't for the life of me figure out what I have to do to get e.g. accelerometer values to transfer to Sleep as Android.
Are there any concise, Shep by step instructions to follow as a user wanting to track sleep through Sleep as Android? - Latest version of Gadgetbridge
-
• #13
Hey @user158095,
Using the integration requires some manual effort and is not straightforward in its current state. So you are not to blame here ;-).So let me guide you through the setup.
Requirements:- (BangleJs) Gadgetbridge (>=0.81.0)
- The accelsender app: https://banglejs.com/apps/?q=accelsender
- Sleep as Android
Now for the setup:
- Activate Sleep as Android in the Gadgetbridge settings and select your device. You can find these settings in the top-left "hamburger" menu.
- Lastly, you have to set up Sleep as Android.
- Open the app, go to settings Sensors->Smartwatch and select DIY.
- Paste the full package name into the text field. For default banglejs Gadgetbridge the value is: com.espruino.gadgetbridge.banglejs
- Open the app, go to settings Sensors->Smartwatch and select DIY.
- Select test sensors and wait for measurements to appear.
Note: For me, "Do Not Disturb" does block the measurements from appearing.
- (BangleJs) Gadgetbridge (>=0.81.0)
-
• #14
Alright, I wasn't too far off! :)
The Bangle acceleration app was missing.So, at this point I have an almost completely working setup following this procedure:
- Installed the latest Bangle bootloader
- Installed latest Gadgetbridge
- Opened Side menu (Hamburger button) -> Settings -> Sleep as Asdroid
- Enabled everything
- Opened Side menu (Hamburger button) -> Settings -> Sleep as Asdroid
- Installed https://banglejs.com/apps/?q=accelsender
- Installed latest Sleep as Android
- Opened Settings (sprocket wheel) -> Sleep Tracking -> Wearables -> Wearables-> DIY
- Pasted "nodomain.freeyourgadget.gadgetbridge"
- Tested the sensor, this works very well
- Tested a sleep cycle, this does not work. I have tried DnD on/off, but the sensor data (Actigraph) does not register at all.
- Opened Settings (sprocket wheel) -> Sleep Tracking -> Wearables -> Wearables-> DIY
Its just something like 2% left for this to be a smash hit! :)
I don't really understand why Sleep as Android is behaving differently during a sleep track cycle, compared to sensor testing. It's certainly frustrating, though, but I'll keep pushing some buttons over here and see if I can come up with something.
- Installed the latest Bangle bootloader
-
• #15
By default Sleep as Android Requests Actigraph data every 120 seconds. So it usually takes a few minutes before the first entries are visible in the actigraph. Did you try this?
-
• #16
I reset Sleep as Android to factory defaults and it looks much better now. It seems to be working fine with DnD enabled as well. Will keep testing it out.
Very appreciated, this implementation!
-
• #17
Setting the "DIY" smartwatch option was the only thing I missed; I mistakenly assumed the "Bangle.js" choice would've worked. No need to disable automatic nighttime DND, no need to reset Sleep as Android to defaults (thankfully due to over 2 years of sleep data gathered via phone). Heart rate monitoring works, too.
For my first night, the actigraph data does look.. different than just having my phone next to my pillow (notably, a lot less deep sleep time), but I'll need to try this for longer to get a feel for which might be more accurate.
Thanks again!
-
• #18
This is interesting stuff, for me this is the first time I'll be able to believe a sleep chart. I'm curious as to how HRM will be implemented.
I looked at the code and it looks like any HRM data sent from the Health app will be forwarded to Sleep as Android, but after tracking for 20 minutes with the interval set to Always, the HRM graph doesn't show up while the actigraph does. Does anyone else have HRM working?
-
• #19
Just to check, did you enable "Heart rate monitoring" in the Wearables section of Sleep as Android, too?
I think that's the only extra step I took beyond what was mentioned before. I don't know why that's off by default; I almost overlooked it. It does look like it took maybe 20-50 minutes before the first reading in Sleep as Android; maybe there's a delay.
-
• #20
Yeah, all the switches from on the Bangle to in Gadgetbridge to in Sleep are enabled. I guess I'll see if it's different when I run the full tracking.
-
• #21
Overall, this is awesome! The Alarm ETA widget on Bangle.js is a nice way to see how much time I have left to sleep if I wake up early, too.
However, after some more nights to test, the Bangle.js actigraph data feels like it's less meaningful vs. my phone next to my pillow. So far, Sleep as Android has not detected deep sleep, always triggering the smart wake up alarm at the earliest start time.
My phone next to my pillow (2024-7-2):
Wearing Bangle.js 2 (2024-7-9):
I wonder if there's a difference in how Bangle.js 2 reports accelerometer data..?
At a glance, the
accelsender
code looks correct, as does the Gadgetbridge handling. If I understand correctly, Bangle.js 2 finds the maximum acceleration over a 1000 ms period (o.put("interval", 1000);
), sends that to Gadgetbridge, which then finds the maximum acceleration over a 9999 ms period, sending it to Sleep as Android once it hits batch size. -
• #22
Hey there,
I observed this issue myself. I'm currently trying to filter the sensor data a bit.
I will keep you updated on this matter. -
• #23
Thanks a lot for this explanation, very useful.
That's been added to the GB doc
Has anyone used the Sleep as Android app with their Bangle.js 2 (not v1)?
In Sleep as Android's
Settings
→Sleep tracking
→Wearables
→Use wearable
section, there's an option forBangle.js
. If you don't have the Bangle.js Gadgetbridge installed, it'll direct you to the Play Store to get it. Otherwise, when testing, it waits to connect to my Bangle.js 2… and does nothing. I have all the Gadgetbridge and Bangle programming/intents/etc features enabled, and I've confirmed that I can send JavaScript code via Tasker (to auto-toggle Quiet mode).I'm guessing Sleep as Android's integration was written for the Bangle.js v1 since it doesn't mention heart-rate monitoring, and the v2 hardware/firmware may be different enough to break it.
I did reach out to Sleep as Android's support, and apparently it's a third party integration:
I'd be happy to try debugging this, but I figured I'd get an idea of what others know first.
Aside, I know Bangle.js 2 has a self-contained sleep phase alarm/tracking app. However, I have over 2 years of sleep data in Sleep as Android and I've integrated it into my routine (controls bedroom lights/music, activates different modes on my phone, etc). Installing the sleep phase alarm app didn't seem to make this work, either.