I have modified the ThinkingCleaner Device and ThinkingCleanerer Smartapp to work with a newly released Ruby based API to communicate with the Neato Botvac Connected API. Instructions and screenshots below.
This would have been a lot harder without the following:
Original ThinkingCleaner Device and ThinkingCleanerer SmartApp @sidjohn1
Botvac API backward engineered and Ruby Client by GitHub - kangguru/botvac
Set up Raspberry PI (assuming image such as Raspbian already installed)
i. Install Ruby Gems package sudo apt-get install ruby gems
NOTE: If you already have ruby gems installed, ensure itâs updated by running the following: sudo gem install rubygems-update sudo update_rubygems sudo gem update --system
ii. Install specific-install sudo gem install specific_install
iii. Install the Github Botvac project sudo gem specific_install -l https://github.com/alyc100/botvac.git
iv. Run Botvac Robots app to find your Botvac serial and secret. You need to type your Botvac registered email and password as prompted. botvac robots
v. Set up your serial and secret environment variables export SERIAL='YOUR_BOTVAC_SERIAL' export SECRET='YOUR_BOTVAC_SECRET'
vi. Test that you can run the web server first with no errors rackup -r 'botvac/web' -o 0.0.0.0 -b "run Botvac::Web.new"
vii. Use a browser or curl to see if the Ruby server is responding. http://[LOCAL IP ADDRESS OF PI]:9292/get_robot_state
You should see a response like below {"version":1,"reqId":"1","result":"ok","error":"ui_alert_invalid","data": {},"state":1,"action":0,"cleaning": {"category":2,"mode":2,"modifier":1,"spotWidth":0,"spotHeight":0},"details": {"isCharging":false,"isDocked":true,"isScheduleEnabled":false,"dockHasBeenSeen":false,"charge":98},"availableCommands": {"start":true,"stop":false,"pause":false,"resume":false,"goToBase":false},"availableServices": {"houseCleaning":"basic-1","spotCleaning":"basic-1","manualCleaning":"basic-1","easyConnect":"basic-1","schedule":"basic-1"},"meta": {"modelName":"BotVacConnected","firmware":"2.0.0"}}
viii. If above is working then kill Ruby server process on Pi with CTRL-C.
ix. Start process in background so you can close PI session nohup rackup -r 'botvac/web' -o 0.0.0.0 -b "run Botvac::Web.new" &
Note: If you need to kill the process in the future, use ps auxwww | grep -i 'rackup' then kill -9 the process id
Commands available via Ruby app include:
start_cleaning
pause_cleaning
resume_cleaning
stop_cleaning
send_to_base
get_robot_state
disable_schedule
enable_schedule
get_schedule
Set up SmartThings
i. Add the neato-botvac-connected.groovy code below from GitHub as a new âMy Device Handlersâ, select create from code option and paste. Create, Save and Publish.
ii. Create a new device (https://graph.api.smartthings.com/device/list)
Name: Your Choice
Device Network Id: Your Choice
Type: Neato Botvac Connected Device
Location: Choose the correct location
Hub/Group: Choose correct hub
iii. Update device preferences
Click on the new device to see the details.
Click the edit button next to Preferences
Fill in your the local IP address of your PI and port number (default is 9292)
iv. Add the thinking-cleanerer-neato-botvac-edition.groovy code below from GitHub as a new âMy SmartAppsâ, select create from code option and paste. Create, Save and Publish.
v. Add the Thinking Cleanerer Neato Botvac Edition app within the ST app from the Marketplace under âMy Appsâ
vi. You should be able to select your Botvac Connected in the configuration screen.
vii. Once configured, click Done on the top right.
Thanks for posting this. I have this all up and running using a Mac Mini as the server. I just had to âsudo gem specific_install -l GitHub - alyc100/botvacâ instead to get that part installed. I also had to choose my actual hub when creating the device instead of leaving it blank. Everything seems to be working except that I canât start cleaning from the ST device. If I visit /start_cleaning on my server, I get an error about the method not being defined:
Ruby /Library/Ruby/Gems/2.0.0/gems/botvac-0.1.1/lib/botvac/web.rb: in call, line 7
Web GET [my_web_server_address]/start_cleaning`
I dug around in â/Library/Ruby/Gems/2.0.0/gems/botvac-0.1.1/lib/botvac/robot.rbâ and saw there was no definition for âstart_cleaning.â I tried adding it manually by using the other methods as a guide and restarted the server:
def start_cleaning connection.post("messages", JSON.dump({ reqId: "1",cmd: "startCleaning" })).body end
While that fixed the error message, trying /start_cleaning still doesnât do anything. It spits out this:
Hi, I am looking forward to getting this running, but where do we find the âsecretâ. When I use the app, all I can see is the SN and model. I am using the android version. What am I missing?
Start App> My Robots> (I)> See robot info (model & S/N)
Your Gem error might be because of an outdated rubygem installation. Try running the following commands in this order. sudo gem install rubygems-update sudo update_rubygems sudo gem update --system
Then try running the specific_install command again. sudo gem specific_install -l https://github.com/alyc100/botvac.git
You get your Botvac secret in step 1. iv. once the botvac gem is installed properly.
iv. Run Botvac Robots app to find your Botvac serial and secret. You need to type your Botvac registered email and password as prompted. > botvac robots
Hmm. Well it appeared to update and install, but when running the specific install I get a series of warnings, but it eventually says it was successfully installed. Then when running the botvac app it gives a series of syntax errors.
As I mentioned, this is a completely fresh install, but I am def not a linux expert. My days of unix based OSes disappeared after my Xenix years.
Would it make sense to just run a new raspbian install again and just insert the rubygems update in the process to see if it has merit, or do you have any other ideas?
It seems no matter what I do, the system insists that 1.8 is the latest version of rubygems. I even manually downloaded and successfully installed rubygems 2.6 but it still insists that 1.8 is the version and the botvacs app still shows the 1.8 references. So I am assuming this is simply something that needs some additional steps on a fresh raspberian install. Is there a way to force it to look at a specific installation of ruby gems?
I have tried that path with no luck producing a good outcome. I am going to be trying to wipe the pi again this weekend and follow your steps again. I am just using noobs with raspberian, do you think I should use a different package for following your setup?
OK, I had a chance to wipe out the pi and try again from scratch. We seem to be over the gems issue. Not sure what was different, but I am able to launch the web server now. I now receive: {âmessageâ:âCould not find robot_serial for specified vendor_nameâ}
I have verified that the serial and secret are in the env variables and that they are correct per the display from âbotvac robotsâ
When you typed the export commands for your serial and secret, make sure you didnât include the square brackets [ ]? So you should have run the command like this. export SERIAL = 'RNDMBTVACSRIAL03942' export SECRET = 'RNDMSCRET93829234NOTREAL'
If so, stop the Ruby server and retype the export commands.