NickWaterton / Roomba980-Python

Python program and library to control iRobot Roomba 980 Vacuum Cleaner
MIT License
367 stars 103 forks source link

Itegration with Home Assistant #45

Open soloam opened 5 years ago

soloam commented 5 years ago

Hello, have you ever considered doing this to Home Assistant. If I have the process running, I can't access it from Home Assistant, and vice versa. It would be great to have live maps in Home Assistant and the drawings in the end.

Thank You and great work

NickWaterton commented 5 years ago

I'm not sure exactly what you are asking,

Roomba980-Python is already integrated into Home Assistant. See https://www.home-assistant.io/components/vacuum.roomba/ and https://gist.github.com/pschmitt/eef8b01e051223905d4368598426b671 and https://github.com/pschmitt/roombapy

@pschmitt did the HA integration of the basic code.

Are you asking for a specific feature in HA?

soloam commented 5 years ago

Hello @NickWaterton. Yes I know of that integrations, I was talking regarding the live maps and resume map! From what I can tell, in openhab there is a way to have that integrated, in HA I don't see how.

If I run the "roomba" service, I can get the maps files, but with that I would lose connection on HA, because I can only have one active!

Thank you

Thank you

NickWaterton commented 5 years ago

In OpenHAB the map file is just written to a directory (in real time), and a static .html file points to it. The .html file can be viewed by any web browser. The Roomba.py program can define where these are located, and for OpenHab I put them in OH’s built in web server directory.

OH has a "WebViewer” widget, and I just point the widget to the static .html file, so the live map is then displayed.

You could do the same thing with any web server (like Apache), just define the map location as the Apache root location (or set up a virtual Apache server location), and view the live map as a web page. I don’t know if HA has a webviewer widget, but most home automation set ups have some way of viewing a web page in the interface.

Setting up a python web server is also only 3 lines of code (I never bothered as I was using OH’s server), so it would actually be easy to set up in the Roomba.py script itself, or as a stand alone “companion” script.

Roomba.py automatically generates the .html file if it doesn’t exist in the target directory for the map files.

Is this what you were looking for?

Nick Waterton P.Eng Sent from my iPhone

On Nov 23, 2018, at 9:54 PM, Soloam notifications@github.com<mailto:notifications@github.com> wrote:

Hello @NickWatertonhttps://github.com/NickWaterton. Yes I know of that integrations, I was talking regarding the live maps and resume map! From what I can tell, in openhab there is a way to have that integrated, in HA I don't see how.

If I run the "roomba" service, I can get the maps files, but with that I would lose connection on HA, because I can only have one active!

Thank you

Thank you

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/NickWaterton/Roomba980-Python/issues/45#issuecomment-441339203, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALCUZxBBV4pNKsC3PR9qkJ33wSaX-P6Wks5uyLTLgaJpZM4YxDpN.

Unsubscribe from GE's commercial electronic messages: http://sc.ge.com/*casl-unsubscribe Désabonner des messages électroniques commerciaux de GE: http://sc.ge.com/*lcap-desabonnement

soloam commented 5 years ago

Yes that is exactly what I did, and it worked! The problem is that while the scrip is running, the HA interface shows not available because the script is using the connection to roomba! I will not be able to use the HA to star pause or dock my roomba! As well as all the stats that are returned by HA!

Thank you

NickWaterton commented 5 years ago

Are you saying that you are running two copies of roomba.py? The one integrated into HA, and the one downloaded from my github?

They are the same program, you can’t run it twice, as the Roomba only allows one connection. There is no point in running the program twice either, the version of my program integrated into HA should have all the same features of the main branch, so it supports live maps the same way.

You should check out @pschmit’s fork that I gave you the link to earlier, that is the fork integrated into HA. You should be able to see the mapping options there.

I’ll take a look at his fork tomorrow to see what he changed to integrate it into HA, see if he cut live mapping out or not.

Nick Waterton P.Eng Sent from my iPhone

On Nov 23, 2018, at 10:15 PM, Soloam notifications@github.com<mailto:notifications@github.com> wrote:

Yes that is exactly what I did, and it worked! The problem is that while the scrip is running, the HA interface shows not available because the script is using the connection to roomba! I will not be able to use the HA to star pause or dock my roomba! As well as all the stats that are returned by HA!

Thank you

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/NickWaterton/Roomba980-Python/issues/45#issuecomment-441340088, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALCUZ-6ZVj7HMigbhd-ttp8EyTkUgTEjks5uyLmzgaJpZM4YxDpN.

Unsubscribe from GE's commercial electronic messages: http://sc.ge.com/*casl-unsubscribe Désabonner des messages électroniques commerciaux de GE: http://sc.ge.com/*lcap-desabonnement

soloam commented 5 years ago

From what I can see, no enable_map is called so probably is not implemented, correct? I'll try to talk with @pschmit to try to know if it's possible to integrate it into HA.

Thank you for your help and time

soloam commented 5 years ago

Hi, just giving a shout to @pschmitt to see if can help out and clarify if its possible to retrieve the maps in Home Assistant!

Thank You

NickWaterton commented 5 years ago

Yes, this looks to be where the roomba is set up https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/vacuum/roomba.py

via;

roomba = Roomba(
        address=host, blid=username, password=password, cert_name=certificate,
        continuous=continuous)

and as you say, no rooma.enable_map() called, so no maps.

If you could find this script, it should be easy to add:

roomba.enable_map(self, enable=False, mapSize="(800,1500,0,0,0,0)",
                   mapPath=".", iconPath = "./", roomOutline=True,
                   home_icon_file="home.png",
                   roomba_icon_file="roomba.png",
                   roomba_error_file="roombaerror.png",
                   roomba_cancelled_file="roombacancelled.png",
                   roomba_battery_file="roomba-charge.png",
                   bin_full_file="binfull.png",
                   roomba_size=(50,50), draw_edges = 30, auto_rotate=True)

Just after the roomba object is created. It's probably not there as some Roombas don't create co-ordinates, and drawing the maps is the biggest pain in the whole Roomba library (ie most likely to go wrong).

The other thing that occurs to me, is that you could try continuous as false, both in HA and in roomba.py, the two programs should then connect and disconnect on a regular basis, each retrieving their data without colliding. That's what non-continuous mode was for. Of course I've never tested it, so who knows if it works or causes errors. Might be easy to try though.

The .yaml config description is here: https://www.home-assistant.io/components/vacuum.roomba/ so you could try continuous as false there first, and if that still works, start up roomba.py with continuous as false also, and see what happens.

Let me know how it works out.

pschmitt commented 5 years ago

@soloam Maps integration is definitely feasible. But it will require a lot of work than what @NickWaterton is suggesting. The Roomba component needs to be patched as well for instance. Also bear in mind that currently the Home Assistant integration does use my fork and not this here repository.

diplix commented 5 years ago

i copied /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/homeassistant/components/vacuum/roomba.py (that’s an os x path, change accordingly) into custom_components/vacuum/roomba.py and changed the requirements to

REQUIREMENTS = ['https://github.com//NickWaterton/Roomba980-Python/zipball/master#roomba==1.2.3']

this works for me, though i’m still on homeassistant version 0.75.3.

also, as @NickWaterton suggested, adding

        roomba.enable_map(
            enable=True, mapSize="(800,1650,-300,-50,2,0)", 
            enableMapWithText=False, roomOutline=False,
            mapPath="/Users/ix/.homeassistant/www/markus/", 
            iconPath="/Users/ix/.homeassistant/www/markus/res"
        )

right after the Roomba() handler is created, works for me: Roomba980-Python now also creates a map for me.

lando1577 commented 5 years ago

When I try that on mine (Home Assistant 0.84.6), I get:

No matching distribution found for opencv-python (from Roomba980-Python==1.2.3)

bobzer commented 5 years ago

very interesting work, do you know if it can work on a raspberry pi 3 ? can you detail the step to mak it work in home assistant ? thank you

NickWaterton commented 5 years ago

I believe it should work on an RPi3 (although I haven't tried it). I don't use HA, so I don't know how to set it up, but it is already integrated, someone in HA should be able to help you set it up.