Controlling iRobot Roomba from the Command Line
If you’re a heavy command line (cli) user in Macos, Linux or WSL, you may it convenient to easily start or stop your robot from it’s cleaning cycle. In this post I’ll you fellow keyboard jockeys how to control and even view your robot as is cleans.
Utilities, Tools, Apps and Endpoints
There are a few tools I use to communicate with the Roomba. They’re like yin and yang. One is a library called dorita980. It provides a lower level of communication to the Roomba on your LAN (local network). The other, rest980 provides an API layer.
Rest 980
rest980 create a http server to map all dorita980 methods in a REST API to control your iRobot Roomba 900 series 980 / i7 / i7+ via HTTP requests.
https://github.com/koalazak/rest980
Again, this is from my notes. Please refer to the official README at the repo link above for proper documentation and examples.
Start the Server
If you have node (nodeJS) installed you can just clone the repo and start the server:
1 | cbergeron@cb-mbp rest980 (master) $ DEBUG=rest980:* npm start |
This will start the node/Express server on localhost port 3000: localhost:3000
or 127.0.0.1:3000
/ 127.0.1.1:3000
Verify the Server (API Endpoint) is running
You can now check to see the API endpoint is running by connecting to port 3000
. You can do this in a browser or using a tool like httpie
or curl
:
1 | cbergeron@cb-mbp dorita980 (master) $ http http://localhost:3000 |
This is the json object we received from the endpoint:
1 | { |
You should also see a GET
request to the server in the output if you ran it in DEBUG
mode like I did here.
1 | GET / 200 0.546 ms - 89 |
Once you have the REST API connected to your robot on your local network, you can start interacting with it. Here’s the output from the /api/local/config/preferences
API route:
1 | curl "http://localhost:3000/api/local/config/preferences" | jq . |
Another simple way to do this is with a simple app that will start a roomba cleaning cycle.
Create a Simple Test App
Create a basic myapp.js
file with these contents:
1 | var dorita980 = require('dorita980'); |
On line 3, we’re connecting to the robot on the IP: 10.0.0.129 which is the last argument. The first two are the BID and password, respectively.
Run the Test App
1 | cbergeron@cb-mbp dorita980 (master) $ node myapp.js |
Now that you can talk to your Roomba using the API, we can use Dorita 980 for mapping
Dorita 980
dorita980 is an unofficial iRobot Roomba node.js library (SDK).
With this library you can send commands to your wifi enabled Roomba through the iRobot cloud API or directly from your LAN and integrate your roboot with your own Home Automation or IoT project.
https://github.com/koalazak/dorita980
The information below is from my notes. Please refer to the official README at the repo link above for proper documentation.
Configuration
To run Dorita, you need to get the BID (Bot ID) and password from your Roomba. The BID is encoded as a string in a format like this: 31E8442031030170
and the password: :1:1608793068:UUyR5cdy7e4k3Jae
. To get these you can run the included
MagicMirror Module
There’s also a MagicMirror Module that uses this API for displaying the robot’s status. Different robots will have varying degress of support ranging from Charge Level, Charge State and Bin Full Status.
The code for this module can be found over on github.
Other
The second Roomba I had got scratched up quite easily from normal usage. If you’re interested in protecting yours, there are quite a quite a few Roomba protective and decorative skins available.
Controlling iRobot Roomba from the Command Line
https://chrisbergeron.com/2022/01/08/Controlling-iRobot-Roomba-from-the-command-line/