Ecovacs Deebot Integration e.g. D900

Tags: #<Tag:0x00007f6173da9e78> #<Tag:0x00007f6173da9d60> #<Tag:0x00007f6173da9c98>

Hi guys,

I wanted to integrate my Deebot D900 into OpenHab2 in order to control it, unfortunately there seems to be no binding and also the existing “sucks” library that is references everywhere does not work anymore on the newer deebots.

In the end I got it working now and I wanted to share in case someone wants todo the same (and also to have some sort of documentation for myself haha)
I am no expert in python and I am pretty sure you can make things better, but it works for me.
I run OpenHab2 on a headless Ubuntu.

1. Install python library
The “sucks” library is not working anymore with the new deebot robots, there seems to be some new version out somewhere but I was not able to find it. However I found the “ozmo” library which seems to be a fork of it which supports the new versions.
You need to have python 3 installed and then you can instal it with “pip3 install ozmo

2. Setup ozmo with the command “ozmo login”.

3. Install the Exec Binding in OpenHab2 if you don’t already have it

4. Create two files like below and fill out the parameters.
Set the rights so that the openhab user can access it.
You can get the deviceid and passwordhash from the ozmo config file, mine was stored in: “/home/username/.config/ozmo.conf”

deebot_clean.py

from ozmo import *
api = EcoVacsAPI('<deviceid>', '<email>', '<passhash>', '<country>', '<region>')
my_vac = api.devices()[0]
vacbot = VacBot(api.uid, api.REALM, api.resource, api.user_access_token, my_vac, 'eu')
vacbot.connect_and_wait_until_ready()
vacbot.run(Clean())

deebot_charge.py

from ozmo import *
api = EcoVacsAPI('<deviceid>', '<email>', '<passhash>', '<country>', '<region>')
my_vac = api.devices()[0]
vacbot = VacBot(api.uid, api.REALM, api.resource, api.user_access_token, my_vac, 'eu')
vacbot.connect_and_wait_until_ready()
vacbot.run(Charge())

5. A things file for running the commands:
Change the paths to the paths where your *.py files are located.

deebotexec.things

Thing exec:command:deebot_clean		[command="python3 /etc/openhab2/deebotpython/deebot_clean.py", interval=0, timeout=8, autorun=false]
Thing exec:command:deebot_charge	[command="python3 /etc/openhab2/deebotpython/deebot_charge.py", interval=0, timeout=8, autorun=false]

6. An items file:
Optional I expose “deebot_trigger” to Alexa with the hueemulation binding.

deebot.items

Switch deebot_trigger		"Deebot"	["Switchable"]

Switch 	Deebot_clean		"Clean"		<deebot_clean>	 {channel="exec:command:deebot_clean:run"}
Switch 	Deebot_charge		"Charge"	<deebot_charge>	 {channel="exec:command:deebot_charge:run"}

7. A rules file:

deebot.rules

rule "deebot1 clean rule"
when
	Item deebot_trigger changed
then
	if(deebot_trigger.state == ON) {
		sendCommand(Deebot_clean, ON)
		logInfo( "FILE", "Deebot_clean ON")
	} else {
		sendCommand(Deebot_charge, ON)
		logInfo( "FILE", "Deebot_charge ON")
	}
end

8. Integrate it in the sitemap:

deebot.rules

Text label="Deebot D900 Vacuum" icon="deebot" {
	Frame label="Deebot D900" {
		Switch item=Deebot_clean		mappings=[ON="Clean"]
		Switch item=Deebot_charge		mappings=[ON="Charge"]
	}
}

9. Make it nice
Find yourself some nice icons and you can also add other commands like STOP, PAUSE, RESUME, etc. with this method.

5 Likes

Hello!
Thanks for your integration.
Anyway doesn’t works for me.
Can u help me?
I just copied all, anyway, in deebot_charge.py
api = EcoVacsAPI(’’, ‘’, ‘’, ‘’, ‘’)
the right configuration is ‘eu’ or ‘’?
Doesn’t work in both mode…
Thanks in advance

edit:
’ < eu > ’
or
’ eu ’

Unfortunately I do not have a Deebot anymore as it broke. But based on the documentation of the library you could try ww as the region and the 2-letter country code of your country. e.g. de for Germany.

So:
api = EcoVacsAPI(’’, ‘’, ‘’, ‘de’, ‘ww’)

But of course also fill out the other 3 parameters!
If that does not work you could try to ask the creator of the library on github. Those are just small snippets which trigger functions through the library.

Same issue for me
with following Py script, the system gives an error

from deebotozmo import *
api=EcoVacsAPI (config['xxxxxxxxxxxxxxxxxxxxxxxxxx'],config['yyyyyyy@gmail.com]',config['zzzzzzzzzzzzzzzzzzzzz'],config['in'],config['ww'])
my_vac = api.devices()[0]
vacbot = VacBot(api.uid, api.REALM, api.resource, api.user_access_token, my_vac, 'eu')
vacbot.connect_and_wait_until_ready()
vacbot.run(Clean())

Error
pi@raspberrypi:~ $ sudo /home/pi/deebot_clean2.py from: can't read /var/mail/deebotozmo /home/pi/deebot_clean2.py: 2: /home/pi/deebot_clean2.py: Syntax error: "(" unexpected

also tried this option
from ozmo import * api = EcoVacsAPI('<deviceid>', '<email>', '<passhash>', '<country>', '<region>') my_vac = api.devices()[0] vacbot = VacBot(api.uid, api.REALM, api.resource, api.user_access_token, my_vac, 'eu') vacbot.connect_and_wait_until_ready() vacbot.run(Charge())
error
from: can't read /var/mail/deebotozmo /home/pi/deebot_clean.py: line 2: syntax error near unexpected token (’
`

Steps Done :
`pi@raspberrypi:~ $ sudo chmod +x /home/pi/deebot_clean2.py
pi@raspberrypi:~ $ sudo /home/pi/deebot_clean2.py
from: can’t read /var/mail/deebotozmo
/home/pi/deebot_clean2.py: 2: /home/pi/deebot_clean2.py: Syntax error: “(” unexpected
pi@raspberrypi:~ $ sudo /home/pi/deebot_clean2.py
from: can’t read /var/mail/deebotozmo
/home/pi/deebot_clean2.py: 2: /home/pi/deebot_clean2.py: Syntax error: “(” unexpected
pi@raspberrypi:~ $ sudo nano /home/pi/deebot_clean2.py
pi@raspberrypi:~ $ sudo /home/pi/deebot_clean2.py
from: can’t read /var/mail/deebotozmo
/home/pi/deebot_clean2.py: 2: /home/pi/deebot_clean2.py: api: not found
/home/pi/deebot_clean2.py: 3: /home/pi/deebot_clean2.py: Syntax error: “(” unexpected
pi@raspberrypi:~ $ sudo nano /home/pi/deebot_clean2.py
pi@raspberrypi:~ $ sudo /home/pi/deebot_clean2.py
from: can’t read /var/mail/deebotozmo
/home/pi/deebot_clean2.py: 2: /home/pi/deebot_clean2.py: Syntax error: “(” unexpected
pi@raspberrypi:~ $ sudo /home/pi/deebot_clean2.py
from: can’t read /var/mail/deebotozmo
/home/pi/deebot_clean2.py: 2: /home/pi/deebot_clean2.py: Syntax error: “(” unexpected
pi@raspberrypi:~ $ sudo nano /home/pi/deebot_clean2.py
pi@raspberrypi:~ $ sudo /home/pi/deebot_clean2.py
from: can’t read /var/mail/deebotozmo
/home/pi/deebot_clean2.py: 2: /home/pi/deebot_clean2.py: Syntax error: “(” unexpected
pi@raspberrypi:~ $ sudo nano /home/pi/deebot_clean2.py
Use “fg” to return to nano.

[1]+ Stopped sudo nano /home/pi/deebot_clean2.py
pi@raspberrypi:~ $ sudo /home/pi/deebot_clean2.py
from: can’t read /var/mail/deebotozmo
/home/pi/deebot_clean2.py: 2: /home/pi/deebot_clean2.py: Syntax error: “(” unexpected

Yours seems to be just a syntax error, I assume because you have a whitespace in Line 2:

EcoVacsAPI (

try replaceing it with

EcoVacsAPI(

Post removing the white space Now also getting

pi@raspberrypi:~ $ sudo /home/pi/deebot_clean2.py
> from: can't read /var/mail/deebotozmo
> /home/pi/deebot_clean2.py: 2: /home/pi/deebot_clean2.py: Syntax error: "(" unexpected

Also tried this option but no luck:

from deebotozmo import *
        api = EcoVacsAPI('xxxxxxx','xxxxx@gmail.com','xxxxxxxxxxxx','in','ww')
        my_vac = api.devices()[0]
        vacbot = VacBot(api.uid, api.REALM, api.resource, api.user_access_token, my_vac, 'eu')
        vacbot.connect_and_wait_until_ready()
        vacbot.run(Clean())

syntax error resolved by adding
#!/usr/bin/env python

But now with the following script getting new error

#!/usr/bin/env python

from ozmo import *
api = EcoVacsAPI(‘xxxxxxxxxxxxxxx’,‘xxxxxxx@gmail.com’,‘xxxxxxxxxxxxx’,‘in’,‘ww’)
my_vac = api.devices()[0]
vacbot = VacBot(api.uid, api.REALM, api.resource, api.user_access_token, my_vac, ‘eu’)
vacbot.connect_and_wait_until_ready()
vacbot.run(Clean())

pi@raspberrypi:~ $ sudo /home/pi/deebot_clean2.py
Traceback (most recent call last):
File “/home/pi/deebot_clean2.py”, line 3, in
from deebotozmo import *
ImportError: No module named deebotozmo

Some steps :

pi@raspberrypi:~ $ updatedb
pi@raspberrypi:~ $ locate deebotozmo
/home/pi/.config/deebotozmo.conf
/home/pi/.local/bin/deebotozmo
/home/pi/.local/lib/python3.7/site-packages/deebotozmo
/home/pi/.local/lib/python3.7/site-packages/deebotozmo-1.6.6.dist-info
/home/pi/.local/lib/python3.7/site-packages/deebotozmo/init.py
/home/pi/.local/lib/python3.7/site-packages/deebotozmo/pycache
/home/pi/.local/lib/python3.7/site-packages/deebotozmo/cli.py
/home/pi/.local/lib/python3.7/site-packages/deebotozmo/constants.py
/home/pi/.local/lib/python3.7/site-packages/deebotozmo/ecovacsiotmq.py
/home/pi/.local/lib/python3.7/site-packages/deebotozmo/map.py
/home/pi/.local/lib/python3.7/site-packages/deebotozmo/pycache/init.cpython-37.pyc
/home/pi/.local/lib/python3.7/site-packages/deebotozmo/pycache/cli.cpython-37.pyc
/home/pi/.local/lib/python3.7/site-packages/deebotozmo/pycache/constants.cpython-37.pyc
/home/pi/.local/lib/python3.7/site-packages/deebotozmo/pycache/ecovacsiotmq.cpython-37.pyc
/home/pi/.local/lib/python3.7/site-packages/deebotozmo/pycache/map.cpython-37.pyc
/home/pi/.local/lib/python3.7/site-packages/deebotozmo-1.6.6.dist-info/DESCRIPTION.rst
/home/pi/.local/lib/python3.7/site-packages/deebotozmo-1.6.6.dist-info/INSTALLER
/home/pi/.local/lib/python3.7/site-packages/deebotozmo-1.6.6.dist-info/METADATA
/home/pi/.local/lib/python3.7/site-packages/deebotozmo-1.6.6.dist-info/RECORD
/home/pi/.local/lib/python3.7/site-packages/deebotozmo-1.6.6.dist-info/REQUESTED
/home/pi/.local/lib/python3.7/site-packages/deebotozmo-1.6.6.dist-info/WHEEL
/home/pi/.local/lib/python3.7/site-packages/deebotozmo-1.6.6.dist-info/entry_points.txt
/home/pi/.local/lib/python3.7/site-packages/deebotozmo-1.6.6.dist-info/metadata.json
/home/pi/.local/lib/python3.7/site-packages/deebotozmo-1.6.6.dist-info/top_level.txt
pi@raspberrypi:~ $ sudo /home/pi/deebot_clean2.py
Traceback (most recent call last):
File “/home/pi/deebot_clean2.py”, line 3, in
from deebotozmo import *
ImportError: No module named deebotozmo

It seems the library import cannot be resolved.
The import of the library in the script (deebot_clean2.py) should happen with

 from ozmo import *

and not with

 from deebotozmo import *

as the error message states. Can you please confirm that you try to import “ozmo” and not “deebotozmo” in the script?

If this does not solve it it seems something did not work with the installation of the library. As I cannot test ot anymore I would suggest to post on the official guthub page as there the author might can help:

Ligio/ozmo This lib is broke so using the fork of it

I just tried this new fork on my system and I have the same issue. I see that you have already created an issue on the github page, hopefully the author replies with the solution :slight_smile: