iRobot Roomba (WiFi) Support

I was able to get my roomba 890 blid and password by using:

pip install git+https://github.com/pschmitt/roombapy@python3-fixes
roomba-getpassword
1 Like

Has anyone been able to get the map into HA? Im using a 980 and have it integrated with HA, but I dont see how to get the maps?

Still can’t get this to work.

installed pip
installed git
sudo git clone https://github.com/NickWaterton/Roomba980-Python.git
cd roomba
python roomba.py

and i get the following…
Traceback (most recent call last):
File “roomba.py”, line 25, in
from roomba.password import Password
File “/home/homeassistant/Roomba980-Python/roomba/roomba.py”, line 25, in
from roomba.password import Password
ImportError: No module named password

1 year after… Has anyone been able to get the map into HA? ^^

nope, but I just export the position coordinates to a file via automation and setup a generic camera fetching a php script which returns a generated image and draws rectangles/lines on the coordinates.
It’s far from perfect but gets the job done :slight_smile:

- alias: Locate Roomba every 2 seconds
  initial_state: true
  trigger:
    platform: time_pattern
    seconds: /2
  condition:
    condition: state
    entity_id: vacuum.roomba
    state: 'on'
  action:
    - service: vacuum.locate
      entity_id: vacuum.roomba

- alias: Log Roomba Position
  initial_state: true
  trigger:
      platform: state
      entity_id: "sensor.roomba_location"
  action:
    - service: notify.roombafile
      data_template: 
        message: "{{ states.vacuum.roomba.attributes.position }}"

- alias: Clean Roomba Log
  initial_state: true
  trigger:
    platform: state
    entity_id: vacuum.roomba
    from: 'off'
    to: 'on'
  action:
    - service: homeassistant.turn_on
      entity_id: switch.clear_roomba_log
1 Like

Thank’s! Is it possible to have also the php script and all resources or the github repository if exist? I will try this method =)

sorry I don’t have a repo for this but you can download the code here:
https://gitlab.com/uploads/-/system/personal_snippet/1927224/47310dbe41a015d8daf0dd807bee8ec4/roomba.zip

I made some refinements so it looks nicer

3 Likes

Thank you very much! I will test it and tell you :slight_smile:

HI @gotschi,
I am analyzing your code and trying to adapt to my environment: HASSIO running in Docker on Synology NAS (Intel Celeron).
Could you explain the line “http://phpserver/roomba/image.php” ?
I guess I need my homeassistant docker container to be able to run PHP, am I correct ?
How do I “install” PHP in homeassistant?
Will a precompiled static php binary work and where do I find it?

Thanks!

Hi @gerosaf!

yes that is correct, you need a php interpeter running on your host to process the image.php script.
so the easiest way would be to just run a nginx-php container and put the image.php in it’s www_root. You don’t installl it in Hass, there is no php addon available I believe.

This way you can call it like http://nasip:nginxport/image.php

Hi @gotschi ,
thanks for answering!

I am having a look at the PHP script, I am not a programmed, so, sorry for noob question…
I sometime get a full-white camera, so I am troubleshooting

Do I need to qualify this “http://hassio.io/local…” link in the image.php at line 15?
$coords = file_get_contents(“http://hass.io/local/roomba/roomba.log?v=”.time());

Same at line 143 for
curl_setopt($ch, CURLOPT_URL,“http://hass.io/api/states/vacuum.roomba”);

Thanks!

yes you need to adapt this to the HA containers ip - or just use 172.17.0.1:8123

Understood, thanks.
First link is now fixed and tested ok.
I still get a “401: Unauthorized”
testing “curl http://172.17.0.1:8123/api/states/vacuum.roomba” in the container and even in my browser with “http://192.168.10.2:8123/api/states/vacuum.roomba

I am not sure HA is exposing /api/states… or maybe a permission problem?
Thanks in advance for helping!

try
curl -X GET “http://172.17.0.1:8123/api/states/vacuum.roomba
-H ‘Authorization: Bearer YOUR_LONG_LIVED_TOKEN’

you’ll have to create long lived token in

http://your_HA_IP:8123/profile

at the bottom of page click create token.
copy that long-lived token key, save it somewhere
HA won’t show it again. that key needs to be in
the curl command. I also put that in image.php
right after Bearer

1 Like

Hi @pnakashian, hi @gotschi,
you got the point! I solved the permission problem, thank you!

Unfortunately it seems my NGINX-PHP container is missing some functions:

PHP message: PHP "Fatal error: Uncaught Error: Call to undefined function imagecreatetruecolor(
) in /data/wwwroot/image.php:50

What would you suggest ?

Got it working using a different NGINX-PHP container.
I am now rescaling my default FLOOR image.

Thanks a lot!

Hi gotschi
I got the nuts and bolts of the setup done and working. Just wondering if you could give a few tips to tweak image.php to accommodate a large house, so I can see the vacuum lines always inside the camera view, the vacuum goes beyond the edges. Also I am not using your setup exactly with the same integration you are using with and haven’t done anything in php before but looking at split[2],split[1],split[0] is the format for location by any chance (y, x , theta), my 1st guess was (theta, x, y).

Thanks
/Pierre

yes the first two digits are the coordinates and the third is theta,

you can also get this all to run in a < iframe > with a canvas and some js pulling the coordinates from the txt created by the automation, this way you don’t need a php/httpd container but I wanted to have them generated server side

Hey @gotschi,

Thanks for posting this - awesome work!

I took your original PHP file and moved all the custom user tweaks into variables at the top to make it easier for others to implement it and incorporated it into my GitHub repository for deploying rest980.

Cheers! :beers:

is there a way to this on a pi?