Package: bn-adjustable-bed
BN Adjustable Bed Mock API and Socket InterfaceThis project is not an official project of, and is in no way affiliated with, Blissful Nights or the Ronin Wifi mobile appThis project sets up an HTTP API and Socket Interface for theBlissful 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 Linksbn-adjustable-bedHow to UseTo use it, you must hijack the DNS queries forcm2.xlink.cnandapi2.xlink.cnand redirect them to your server.api2.xlink.cnis used by the Ronin WiFi mobile app [ios|android].cm2.xlink.cnis 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 APIThe HTTP API is exposed on port80and provides endpoints that will allow you to log into the app without creating an account.SetupAnexampleDocker 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 amacvlannetwork namedlan.  Change<IP>in the example file based on your network, they all need to be unique.  If you prefer, you could use themainDocker 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 APIwill be on port8080instead 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).mkdirbn-adjustable-bedcdbn-adjustable-bed

wgethttps://github.com/trevorlauder/bn-adjustable-bed/blob/main/docker-compose.yml.example-Odocker-compose.yml# adjust <IP> and config for your networkdocker-composeupHijack DNS queries toapi2.xlink.cnandcm2.xlink.cnon 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.cnshould be pointed at theapp-apiservice andcm2.xlink.cnshould be pointed at thebed-socketservice.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.SelectMy Bedfrom the menu and thenConnect new bedFollow 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".  ClickNextConnect your mobile device to theKeesonAp-XXXXXXXXXXWireless SSID.  ClickNextContinue 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 toConnect.  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 APIThe Bed Controller API is exposed on port80and 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 positioncurl-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 positioncurl-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 positioncurl-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 positioncurl-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 positioncurl-X'PUT'\'http://bn-adjustable-bed-controller.changethistoyourdomain.com/command?name=preset_three'\-H'accept: application/json'