[DEPRECATED] Neato Botvac Connected + Raspberry PI + ST


(Alex Lee) #1

No need for Raspberry PI with new version


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 https://github.com/kangguru/botvac

  1. 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

  1. 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.

https://github.com/alyc100/SmartThingsPublic/blob/master/devicetypes/alyc100/neato-botvac-connected.src/neato-botvac-connected.groovy


Neato Botvac Connected
Connected Vacs? - What's the latest info w/ ST
Anyone using a robot vacuum cleaner?
(Jason Charrier) #2

Thanks for posting this. :slight_smile: I have this all up and running using a Mac Mini as the server. I just had to “sudo gem specific_install -l https://github.com/alyc100/botvac.git” 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:

NoMethodError at /start_cleaning undefined methodstart_cleaning’ for #Botvac::Robot:0x007fbad41a3240

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:

{"version":1,"reqId":"1","result":"ko","error":"ui_alert_invalid"}


(Jason Charrier) #3

Here’s the output of /get_robot_state with it docked and ready to clean:

{"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":97},"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"}}


(Alex Lee) #4

Let me take a look at this. Wonder if there is a change I made that I haven’t pushed into the GitHub fork.


(Tim Slagle) #5

(Alex Lee) #6

Think I have found the missing code from robot.rb (see below). Let me get home from the pub and check it into GitHub.

Update: Github code all checked in. Start_cleaning should work. Let me know.

def start_cleaning
  connection.post("messages", JSON.dump(
    {
      reqId: "1",
      cmd: "startCleaning",
      params: {
        category: 2,
        mode: 2,
        modifier: 2
      }
    }
  )).body
end

(Jason Charrier) #7

That fixed it. Thanks! :slight_smile:


(Benji) #8

While it’s in the code itself, let’s give some props to @sidjohn1 for the original Thinking Cleaner/er source code!

Glad the Neato community are getting a little love too now thanks to @Alyc100!


#9

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)


#10

I am also receiving an error when attempting to install the gem.

ERROR: While executing gem … (NoMethodError) undefined method ‘build’ for Gem:: Package :Module

This is a fresh raspbian version 8


(Alex Lee) #11

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


#12

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?

Errors during botvac run:
pi@raspberrypi:~ $ botvac robots
/usr/local/lib/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:127:in gem_original_require': /var/lib/gems/1.8/gems/botvac-0.1.1/lib/botvac/cli.rb:14: syntax error, unexpected ':', expecting ')' (SyntaxError) password = ask("Pasword:", echo: false).to_s ^ /var/lib/gems/1.8/gems/botvac-0.1.1/lib/botvac/cli.rb:16: odd number list for Hash ....post('/sessions', { platform: "ios", email: email, token: S... ^ /var/lib/gems/1.8/gems/botvac-0.1.1/lib/botvac/cli.rb:16: syntax error, unexpected ':', expecting '}' ....post('/sessions', { platform: "ios", email: email, token: S... ^ /var/lib/gems/1.8/gems/botvac-0.1.1/lib/botvac/cli.rb:16: syntax error, unexpected ',', expecting kEND .../sessions', { platform: "ios", email: email, token: SecureRa... ^ /var/lib/gems/1.8/gems/botvac-0.1.1/lib/botvac/cli.rb:16: syntax error, unexpected ':', expecting '=' ...m: "ios", email: email, token: SecureRandom.hex(32), passwor... ^ /var/lib/gems/1.8/gems/botvac-0.1.1/lib/botvac/cli.rb:16: syntax error, unexpected ',', expecting kEND ..., token: SecureRandom.hex(32), password: password }).body['a... ^ from /usr/local/lib/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:127:inrequire’
from /var/lib/gems/1.8/gems/botvac-0.1.1/bin/botvac:3
from /usr/local/bin/botvac:22:in `load’
from /usr/local/bin/botvac:22


(Alex Lee) #13

What version of ruby and rubygems is installed?
ruby -v

On my PI, Ruby version is 2.1.5p273 (2014-11-13) [arm-linux-gnueabihf] and Rubygems is version 2.1.0.

Looking at your logs, it seems you still have older versions. I can see you have Rubygems 1.8 for example.


#14

I noticed that as well, but the version comes up as 2.1.5p273 (2014-11-13)

but rubygems is still showing 1.8. Sounds like I need to find out why it isn’t upgrading.


#15

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?


(Alex Lee) #16

Anyway to uninstall the older version maybe? Or uninstall both and reinstall the latest?


#17

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?


(Alex Lee) #18

That’s the setup I have on my Pi. Installation of Raspbian with Noobs.


#19

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’

Thoughts?


(Alex Lee) #20

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.