BN Adjustable Bed Mock API and Socket Interface
Project description
BN Adjustable Bed Mock API and Socket Interface
This project is not an official project of, and is in no way affiliated with, Blissful Nights or the Ronin Wifi mobile app
This project sets up an HTTP API and Socket Interface for the Blissful Nights Wall Hugger Adjustable Bed with Massage and Alexa Voice Command.
I can control the bed using the HTTP API or the mobile app without having anything connected to the official servers hosted in AWS.
I have the HTTP API hooked up to my iOS Shortcuts which allows me to use it in my automation.
Not all of the socket communication protocol is understood, but enough of it has been reverse engineered to provide this functionality.
Docker Hub Links
How to Use
To use it, you must hijack the DNS queries for cm2.xlink.cn
and api2.xlink.cn
and redirect them to your server.
api2.xlink.cn
is used by the Ronin WiFi mobile app [ ios | android ].
cm2.xlink.cn
is used by the bed. The bed creates a persistent socket connection to this address.
Use of the mobile app is required to perform the initial setup and get the bed hooked up to your wireless network. Once you have it setup, use of the mobile app is optional.
Mobile App API
The HTTP API is exposed on port 80
and provides endpoints that will allow you to log into the app without creating an account.
Setup
-
An example Docker Compose Config File is provided. It uses a default bridge network for communcation to the redis instance and configures the other 3 services to use an IP on a
macvlan
network namedlan
. Change<IP>
in the example file based on your network, they all need to be unique. If you prefer, you could use the main Docker Compose Config File used for development as a start, it uses the default network and exposes the service ports through a single IP instead. In this case theBed Controller API
will be on port8080
instead of80
. -
Setup a directory for the services and run Docker Compose to start the 4 services (Redis, App API, Bed Socket Interface and Controller API).
mkdir bn-adjustable-bed
cd bn-adjustable-bed
wget https://github.com/trevorlauder/bn-adjustable-bed/blob/main/docker-compose.yml.example -O docker-compose.yml
# adjust <IP> and config for your network
docker-compose up
-
Hijack DNS queries to
api2.xlink.cn
andcm2.xlink.cn
on your network so that they resolve to the IP address of your docker services. If you're using separate IP's for each service,api2.xlink.cn
should be pointed at theapp-api
service andcm2.xlink.cn
should be pointed at thebed-socket
service. -
Log into the Ronin Wifi mobile app using any email address and password, neither need to be valid. Make sure your mobile device is connected to your network so that is resolves your hijacked domains properly.
-
Select
My Bed
from the menu and thenConnect new bed
-
Follow the instructions in the app to "Long press the Foot Up and Down buttons for 5 seconds until you hear a beep every 3 seconds". Click
Next
-
Connect your mobile device to the
KeesonAp-XXXXXXXXXX
Wireless SSID. ClickNext
-
Continue with the instructions and provide the Wireless network credentials for the network you wish to connect the bed to.
-
The bed will beep a couple times and connect to your Wireless Network. The bed should show up shortly in the list with an option to
Connect
. Skip this part as not enough of the communications protocol has been reverse engineered at this point for the app to completely perform the setup. At this point you can force quit the app and re-open it, you should be able to control the bed now and see it in the list of beds.
-
Bed Controller API
The Bed Controller API is exposed on port 80
and provides an endpoint that allows you to send commands to the bed.
This can be easily added to Siri Shortcuts or similar tools to add bed control to whatever automation platform you use.
# Tell the bed to move to the flat position
curl -X 'PUT' \
'http://bn-adjustable-bed-controller.changethistoyourdomain.com/command?name=flat' \
-H 'accept: application/json'
# Tell the bed to move to the Zero-G position
curl -X 'PUT' \
'http://bn-adjustable-bed-controller.changethistoyourdomain.com/command?name=zero_g' \
-H 'accept: application/json'
# Tell the bed to move to the Preset I position
curl -X 'PUT' \
'http://bn-adjustable-bed-controller.changethistoyourdomain.com/command?name=preset_one' \
-H 'accept: application/json'
# Tell the bed to move to the Preset II position
curl -X 'PUT' \
'http://bn-adjustable-bed-controller.changethistoyourdomain.com/command?name=preset_two' \
-H 'accept: application/json'
# Tell the bed to move to the Preset III position
curl -X 'PUT' \
'http://bn-adjustable-bed-controller.changethistoyourdomain.com/command?name=preset_three' \
-H 'accept: application/json'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bn-adjustable-bed-1.3.14.tar.gz
.
File metadata
- Download URL: bn-adjustable-bed-1.3.14.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.10.7 Linux/5.15.0-1020-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27e3384b407cd7cfff113d6cd9b87890b08172284b3c593e1689b4c2d8439bad |
|
MD5 | 9dba9375c2461bc9aa47cebff2e5a30c |
|
BLAKE2b-256 | 584edee8bde84b5deb9cd0197a048ec69b33832796e2f142402514d0a5e99491 |
File details
Details for the file bn_adjustable_bed-1.3.14-py3-none-any.whl
.
File metadata
- Download URL: bn_adjustable_bed-1.3.14-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.10.7 Linux/5.15.0-1020-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf36cc182095f9598b88e4438dbd47b9a96b8ffbc12f2d1d952973ae1600032c |
|
MD5 | e4917e4b928539e02182f70f603c9232 |
|
BLAKE2b-256 | d64ed9bc98fa5d23158b5049e25a183a841aa4de5af796c3baca00dda2341bef |