iRobot Roomba (WiFi) Support

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?

Check my thread here for a potential way using rest980 on a Pi

Depending on your model, and what you have working now, you might just need the php-nginx container to host the map file. :+1:

my model is s9+,
i installed both the php-nginx_armv7 and rest980_build, the nginx part went fine i think. i can go to http://192.168.1.100:3000/map and i see this:

none of the buttons work, i know the ip, blid and password are correct because i use the normal vacuum integration.

on the rest980_build addon i get this after build:

> [email protected] start /usr/src/app
> node ./bin/www
WARNING: NODE_ENV value of 'production' did not match any deployment config file names.
WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode

the only parameter i didn’t change is the firmware version.

@haimbilia - I havent tested this on an S9.

I suggest setting the firmware version to 2 (which is actually 2+) and checking the following URL

http://192.168.1.100:3000/api/local/info/state

Also - I just collapsed the php-nginx_armv7 addon back into php-nginx. You may wish to refresh your addons and swap over to this one.

EDIT - Just reread your post

when accessing api/local/info/state i get:

{}

log:

> [email protected] start /usr/src/app
> node ./bin/www
WARNING: NODE_ENV value of 'production' did not match any deployment config file names.
WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
GET /api/local/info/state 200 166.361 ms - 2
GET /api/local/info/state 304 114.796 ms - -
GET /api/local/info/state 304 106.242 ms - -
GET /api/local/info/state 304 103.137 ms - -
GET /api/local/info/state 304 104.417 ms - -
GET /api/local/info/state 304 102.919 ms - -

i changed the nginx to the new addon

I get the same result with incorrect credentials / ip for my robot.

Can you please double check they are correct and complete?

My password string appear similar to this :
:1:xxxxxxxxxxx:xxxxxxxxxxx

i did a couple of restarts and it suddenly started working, my normal vacuum entity isn’t available anymore, is that normal?

Yeah that would do it - the roomba is pretty pedantic about its connections - so it is no doubt the culprit.

I find that even the official app can take a few seconds to connect - likely if rest980 is already obtaining the data at the particular time.

If it helps - you can completely switch over to using rest980 :wink:

yeah i think you are right so removing the integration will solve it completely.

1 Like