Ecovacs DEEBOT Ozmo-Series

Hello everybody,
is there anyone who is able to create an oH2 binding (v2.5) for “Ecovacs DEEBOT Ozmo” vacuum robots (Ozmo 920, 950 …).
Or has someone integrated these models into openhab and can briefly describe the solution.
I tried various suggestions from the web (https://community.openhab.org/t/ecovacs-deebot-integration-e-g-d900/88588) , but nothing worked.
Many solutions from the web relate to Pyton3.
I run openHAB on a Synology DiskStation. I can install Pyton3 on it, but I haven’t managed to install the corresponding libraries yet.
It would be nice if someone could help me.

Hi,

I’ve had the same issue with getting mi Ozmo 950 to work with openHAB 2.5.
But I finally got it working with a fork of the sucks-library and some Python code.
But you’ll need some kind of MQTT broker, since I’m publishing the events from my ozmo to an MQTT Broker and subscribe to this topics in openHAB.

I prepared my code also to include a docker-compose file, since most of my apps run in docker, but you don’t need to.

The easier way is to use docker, since you only have to provide some variables and the docker does the rest :wink:

I have (not 100% complete) instructions (including things, items and sitemap examples) in my repo:

I’m planing to write a more detailed tutorial, especially on the Python only part.

Example:

Thanks so much for this.

I dont get the install method at all though - I must be a proper newbie not having used docker before or python.

I run openhabian on my raspberry PI. Any pointers on the easiest method of install in very simple terms?

Many thanks

I’ll try my best to give you some directions :wink:

I’m not sure if Python is installed in openhabian so open a terminal/console and type

python --version

It should give you some output like

Python 3.8.5

If not, there should be enough tutorials on the internet on how to get python installed. Search for something like “linux install python 3”. Note that it mus be some version 3.x.x

Next create a new folder where the source code will be downloaded to (e.g. under the user home folder “deebot”) and switch there.
Easiest way again via terminal

mkdir deebot && cd deebot

Now download the sourcecode to this folder.
(If you download the *.zip file you’ll get the files in an additional folder, just place all the stuff [main.py, requiremets.tyt and so on] in the above created folder)

Now you have to install additional packages I’m using with python.
First create an so called environment with python.

python -m venv env

This should also create a new folder named env in your current folder.
Now this environment must be activated. This is done with

source env/bin/activate

If this is succesful you should see an additional “env” in the terminal at the beginning or end of the line.
Now to install the required packages type

pip install -r requirements.txt

This could take a few moments since a few files have to be downloaded.

After this is done you need to set some configuration values.
This can be done in the main.py file or via environment variables but I recommend environemnt variables.
In openhabian this should be doable like in other linux systems with

export variablename=some_value

So if you want to set the value for your email type

export email=my_ecovacs@something.com

Which variables need to be set can be seen on github in the docker section of the readme file.
Some values just exist and don’t need to be set and I should probably define some default values for them.
mqtt_client_bind_address doesn’t need to be set (at least I don’t in my environment). For verify_ssl set “True” and device_id can be some random identifier (I use a 32 character long string)

The MQTT Broker should be the inclueded mosquitto broker.

Now everything should be ready to get some values from your Deebot. Just type:

python main.py

And you should get some output like

ecovacs/48b21ebb-543f-4938-8ddb-4e62da5a1d33/status STATE_DOCKED
ecovacs/48b21ebb-543f-4938-8ddb-4e62da5a1d33/battery_level 100
ecovacs/48b21ebb-543f-4938-8ddb-4e62da5a1d33/fanspeed normal
ecovacs/48b21ebb-543f-4938-8ddb-4e62da5a1d33/water_level low
ecovacs/48b21ebb-543f-4938-8ddb-4e62da5a1d33/mop_attached False

and you can use the provided things file (don’t forget to modify the values) to get your deebot into OH.

You are a star! Excellent instructions thank you! I will give this a go shortly and let you know. Appreciate your time

1 Like

So tried tonight and no such luck sadly. Eveything went smoothly up to the last bit. After typing:

cd deebot
python main.py

I get the following in the console:

[22:01:19] openhab@openHABianDevice:~$ cd deebot
[22:01:28] openhab@openHABianDevice:~/deebot$ python main.py
Traceback (most recent call last):
File “main.py”, line 1, in
from deebotozmo import *
ModuleNotFoundError: No module named ‘deebotozmo’

Any ideas?

Also, I setup the MQTT broker but unsure if it is working? If you know, is the below correct?

  1. in SSH installed Mosquitto using the optional components
  2. In PaperUI, installed the MQTT broker binding
  3. Adding config for the server in the services/mqtt.cfg file
  4. Added a MQTT broker thing with the same server details as the mqtt.cfg file. The thing is now online.

Am I correct?

Thanks again for your time

Is the environment still active when you type ‘python main.py’?

This needs to be active so python knows where to find the module ‘deebotozmo’.

Just like before type in the folder where the ‘env’ folder is ‘source env/bin/activate/’ and afterwards ‘python main.py’

I think the broker should work, but I’m unsure since I use a seperate Moquitto instance and only use the bridge like in my example things file.

Thanks FloSchl

After a few teething issues with dependencies not installed, python main.py now works fine.

However… I don’t get any values displayed… the cursor just blinks with the following error displayed:

Traceback (most recent call last):
File “/home/openhabian/deebot/env/lib/python3.7/site-packages/urllib3/connection.py”, line 170, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File “/home/openhabian/deebot/env/lib/python3.7/site-packages/urllib3/util/connection.py”, line 73, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File “/usr/lib/python3.7/socket.py”, line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/openhabian/deebot/env/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 706, in urlopen
chunked=chunked,
File “/home/openhabian/deebot/env/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 382, in _make_request
self._validate_conn(conn)
File “/home/openhabian/deebot/env/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 1010, in _validate_conn
conn.connect()
File “/home/openhabian/deebot/env/lib/python3.7/site-packages/urllib3/connection.py”, line 353, in connect
conn = self._new_conn()
File “/home/openhabian/deebot/env/lib/python3.7/site-packages/urllib3/connection.py”, line 182, in _new_conn
self, “Failed to establish a new connection: %s” % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0xb4331eb0>: Failed to establish a new connection: [Errno -2] Name or service not known

Looks like connection issue? I defined all the variables in the environment as suggested so not sure what this error is referring to

Thanks once again for your help, will be sure to buy you a coffee in your link once I am up and running of course!

HI nice to hear that you made some progress.

I’m not at my main PC right know so I’m assuming things now and will invastigate tomorrow.
I assume somehow it can’t connect to the Ecovacs API.

Can you provide me at least your country and continent? I’ve read about some issues in the original repository about some combinations…

Thanks man appreciate it :slight_smile:

Thanks for your help yet again

United Kingdom
Europe

Is it worth trying physical variables in the main.py instead? I’m not sure how they’ll be written there. If like php I assume everything is within double quotes “” ?

Thanks

Matt

Hi,

sure you can type it in there using double quotes “”.
You can also change the logging level to log.level = logging.DEBUG to get more information.

I just tried changing my county to “uk” and got values from the API.
Starting with configuration: {'email': 'XXXXXX', 'password': 'XXXXXX', 'device_id': 'XXXXXX', 'country': 'uk', 'continent': 'eu', 'verify_ssl': 'True', ...}
Did you use the two letter code?

I just published a new version which also handles status updates when you trigger it with the button on the bot.

Hey, thanks for all your patience and help. I have installed your latest files. Do you mean you can read the status of the deebot in your latest update?

Adding the variables directly into the main.py seemed to do the trick. I am getting at least some sense now and must be close. See below my output:

2021-01-07 20:35:15,752: __main__ INFO: Published message 'None' to topic '/deviceidxxxxx/status'
2021-01-07 20:35:16,367: __main__ INFO: Published message 'STATE_DOCKED' to topic '/deviceidxxxxx/status'
2021-01-07 20:35:16,988: __main__ INFO: Published message '100' to topic '/deviceidxxxxx/battery_level'
2021-01-07 20:35:17,615: __main__ INFO: Published message 'normal' to topic '/deviceidxxxxx/fanspeed'
2021-01-07 20:35:18,487: __main__ INFO: Published message 'ultrahigh' to topic '/deviceidxxxxx/water_level'
2021-01-07 20:35:18,488: __main__ INFO: Published message 'False' to topic '/deviceidxxxxx/mop_attached'
2021-01-07 20:35:27,291: __main__ INFO: Published message '19' to topic '/deviceidxxxxx/stats_area'
2021-01-07 20:35:27,293: mqtt_client ERROR: failed to receive on socket: [Errno 32] Broken pipe
2021-01-07 20:35:27,294: __main__ INFO: Published message '111' to topic '/deviceidxxxxx/stats_cid'
2021-01-07 20:35:27,295: __main__ INFO: Published message '19.083333333333332' to topic '/deviceidxxxxx/stats_time'
2021-01-07 20:35:27,296: __main__ INFO: Published message 'spotArea' to topic '/deviceidxxxxx/stats_type'
2021-01-07 20:35:27,872: __main__ INFO: Published message '90.5' to topic '/deviceidxxxxx/components/brush'
2021-01-07 20:35:28,388: __main__ INFO: Published message '79.72222222222223' to topic '/deviceidxxxxx/components/sideBrush'
2021-01-07 20:35:28,889: __main__ INFO: Published message '76.15277777777779' to topic '/deviceidxxxxx/components/heap'
2021-01-07 20:35:29,318: __main__ INFO: Published message 'https://portal-eu.ecouser.net/api/lg/image/688ad294-f3a7-4b06-817d-612f73a4b450@606483758@DJL0' to topic '/deviceidxxxxx/last_clean_image'

Now I do see one error in there as below. Dont know what that means?

2021-01-07 20:35:27,293: mqtt_client ERROR: failed to receive on socket: [Errno 32] Broken pipe

Other than that, a question. How does this script keep running? Does it run automatically? or everytime openhabian is rebooted, do I need to do the whole “python main.py” again?

I assume a CRON would be needed to keep it running in this way?

Thanks again in advance!

Spoke too soon… in addition to the above, cant seem to read the data in OpenHAB

  1. I added the things file into the folder and changed the broker details to the one already in paperUI. I also changed the device ID to that in the cmd when running “python main.py”.
  2. I added the items to the items file but they are duplicated as I already linked them in the things with channels. Easily solved as I can remove one set.

No data being displayed in openHAB…

Any ideas please FloSchl?

Hi,

nic eto see that you made some progres.

The update fixes that the status of the robot wasn’t updated if you pressed the buton on the robot to start cleaning. It would stay in “docked”.

In the ‘main.py’ file in line 161 there is a function call vacbot.setScheduleUpdates() which schedule ssome backround threads to refresh livemap, status and components.
The default values are (in seconds) livemap_cycle = 15, status_cycle = 30, components_cycle = 60.
You can change this values to your liking, so when the script is running it keeps ruinning till you end it.

Yes if you reboot you openhabian installation you have to do the

    source env/bin/activate
    python main.py

again. So you have to ensure that this is executed on startup. I think writing a small .sh script and executing it with cron on boot should do the trick.

I didn’t find the error you encountered in my logs. Did it happen more than once? It occurs mainly when some requests timeout or too much data is send. If it was only one time I wouldn’t give too much on it.

I remember I had some difficulties at first too to get the values to display in OH.
First check if all your MQTT broker values are correct.

  • config for the python script mqtt_client_host=host_or_ip_of_mqtt_broker and mqtt_client_port=mqtt_port
  • MQTT bridge config in .things file host and port

I also noticed the value get only updated when they change. So start your robot and watch for any change.
You can also look in the events.log file in openhab userdata/logs/events.log file if something changes.
For example, currently my robot is docked and doesn’t do anything. My script still publishes any few seconds the values to the broker but in the vents.log nothing is shown because nothing changed.

Many thanks,

I have had a play with settings and the error has now gone. However still no data being read by openhab.

I have tested the mosquitto server using mosquitto_sub & mosquitto_pub. Working fine via command line.

I have set the main.py variables as follows.

# reading config from env
config = {
    'email' : "maxxxxxxxx@email.com",
    'password' : "password",
    'device_id' : "6xxxxxxxxxxxxx450",
    'country' : "uk",
    'continent' : "eu",
    'verify_ssl' : "True",
    'mqtt_client_id' : "OpenHAB2",
    'mqtt_client_host' : "127.0.0.1",
    'mqtt_client_port' : "1883",
    'mqtt_client_username' : "username",
    'mqtt_client_password' : "password",
    'mqtt_client_keepalive' : "60",
    'mqtt_client_bind_address' : "",
    'mqtt_client_root_topic' : "ecovacs"
}

I have things file as follows:

Bridge mqtt:broker:8b86747c "Mosquitto" [ host="127.0.0.1",
                                    port=1883,
                                    secure=false,
                                    clientId="OpenHAB2"]
    {
    Thing topic EcovacsTopic "Ecovacs" @ "Vacuum" {
        Channels:
            Type number : ecovacs_1_battery_level "Ecovacs 01 Battery Level" [ stateTopic="ecovacs/deviceid/battery_level" ]
            Type string : ecovacs_1_vacuum_status "Ecovacs 01 Vacuum Status" [ stateTopic="ecovacs/deviceid/status" ]
            Type string : ecovacs_1_fan_speed     "Ecovacs 01 Fan Speed"     [ stateTopic="ecovacs/deviceid/fanspeed" ]
            Type number : ecovacs_1_main_brush    "Ecovacs 01 Main Brush"    [ stateTopic="ecovacs/deviceid/components/brush" ]
            Type number : ecovacs_1_side_brush    "Ecovacs 01 Side Brush"    [ stateTopic="ecovacs/deviceid/components/sideBrush" ]
            Type number : ecovacs_1_filter        "Ecovacs 01 Filter"        [ stateTopic="ecovacs/deviceid/components/heap" ]
            Type string : ecovacs_1_command       "Ecovacs 01 Command"       [ commandTopic="ecovacs/deviceid/command" ]
            Type string : ecovacs_1_water_level   "Ecovacs 01 Water Level"   [ stateTopic="ecovacs/deviceid/water_level" ]
            Type switch : ecovacs_1_mop_attached  "Ecovacs 01 Mop attached"  [ stateTopic="ecovacs/deviceid/mop_attached" ]
            Type number : ecovacs_1_stats_area    "Ecovacs 01 Status Area"   [ stateTopic="ecovacs/deviceid/stats_area"]
            Type number : ecovacs_1_stats_time    "Ecovacs 01 Status Time"   [ stateTopic="ecovacs/deviceid/stats_time"]
            Type string : ecovacs_1_stats_type    "Ecovacs 01 Status Type"   [ stateTopic="ecovacs/deviceid/stats_type"]
            Type string : ecovacs_1_last_clean_image "Ecovacs 01 Lase Cleaning Image" [ stateTopic="ecovacs/deviceid/last_clean_image"]
        }
}

Both are online in my paperUI as seen in image:

Settings in the mqtt.cfg file in the services folder:

#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
mosquitto.url=tcp://localhost:1883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
#<broker>.clientId=<clientId>

# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
#<broker>.allowLongerClientIds=false

# Optional. User id to authenticate with the broker.
mosquitto.user=username

# Optional. Password to authenticate with the broker.
mosquitto.pwd=password

# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
mosquitto.qos=1

# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
mosquitto.retain=true

# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
mosquitto.async=false

# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>

I have ensured the broker thing matches the thing already added in paperui. See details:

Yet nothing displayed in HABPanel under the items or basicUI sitemap, any further ideas?

Tried your suggestion and had the robot working while trying values. No luck.

Hi Matt,

to me everything looks fine and unfortunately I can’t see any errors or why OH just doesn’t show some values.

Did you look into the log files?

    Log files are written to either userdata/log (manual setup) or /var/log/openhab (package based setup) and can be accessed using standard OS tools for text files. The default installation of openHAB generates two log files:

    events.log
    openhab.log

Can you open the “Vacuums” tab in PaperUI and push some changing values e.g. for the battery and watch if they change in the UI and if something shows up in the logs?

Hi FloSchl

So a long journey but got there eventually… just about.

Thanks so much for everything so far. Final hurdle now…

Getting the commands to work is puzzling. I created a widget on habpanel to send the “Clean” or “CleanPause” commands to the deebot. Now, they work for a small time before stopping altogether. Clicking the button in habpanel to “Clean” does nothing after a short while.

The error recieved in the openhab.log is:

[WARN ] [ab.binding.mqtt.generic.ChannelState] - Command 'False' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.False

In the widget no “false” is being sent… this is my code:

            <ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="single-button">
            <li role="menuitem"><a ng-click="sendCmd(config.vacuum_command, 'Clean')">Clean</a></li>
            <li role="menuitem"><a ng-click="sendCmd(config.vacuum_command, 'CleanPause')">Pause</a></li>
            <li role="menuitem"><a ng-click="sendCmd(config.vacuum_command, 'CleanResume')">Resume</a></li>
	                <li role="menuitem"><a ng-click="sendCmd(config.vacuum_command, 'Charge')">Charge</a></li>
            <li role="menuitem"><a ng-click="sendCmd(config.vacuum_command, 'PlaySound')">Locate</a></li>
            <li role="menuitem"><a ng-click="sendCmd(config.vacuum_command, 'Relocate')">Relocate</a></li>

Wierd one really as when openhab is restarted all works again for a short period before the issue happens again.

EDIT: What I realised is the broker actually seems to stop working until openhab is restarted again. It is not just the commands. I checked the python script is running still and publishing to the topic in SSH, and there is no issue here. Openhab simply stops updating the data from MQTT.

Is it possibly the keep alive or LWT settings? Any suggestions how you have configured your MQTT broker in openhab?

Any thoughts?

Hi FloSchl

Great Job and guide

just a question because I’m not skilled in python use…
I Installed it on ubuntu 20.04 with openhab 3.
I used python3 command instead of python…it works great but if i close the shell windows it stops to work.
How can leave it working without leave shell windows opened?
How can I launch it at startup?

thanks a lot for your help.

Livio

Hello,
I have tried to get the library running via docker-compose, unfortunately without success.
The Docker installation aborts with an error at “preparing wheel metadata”.
Error:
ERROR: Could not find a version that satisfies the requirement numpy==1.19.4
ERROR: No matching distribution found for numpy==1.19.4

Does anyone have an idea what I am doing wrong?

Thanks in advance
Peter

Hey,

i ran into the same problem. it seems that the system is missing some requirements to compile the nymphy library - as it was successfully downloaded before.

I’ve attached the full log, but think the following may be the root cause - without any idea to fix it. docker.txt (12.9 KB)

Im running on the lastest openhabian on an raspberry pi4B.

    don't know how to compile Fortran code on platform 'posix'
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
        main()
      File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File "/tmp/pip-build-env-w4fhf9mi/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 157, in prepare_metadata_for_build_wheel
        self.run_setup()
      File "/tmp/pip-build-env-w4fhf9mi/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 248, in run_setup
        super(_BuildMetaLegacyBackend,
      File "/tmp/pip-build-env-w4fhf9mi/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 142, in run_setup
        exec(compile(code, __file__, 'exec'), locals())
      File "setup.py", line 508, in <module>
        setup_package()
      File "setup.py", line 500, in setup_package
        setup(**metadata)
      File "/tmp/pip-install-_wfg5a_u/numpy_fa5e263edf9148adaacb0681b6d34b56/numpy/distutils/core.py", line 169, in setup
        return old_setup(**new_attr)
      File "/tmp/pip-build-env-w4fhf9mi/overlay/lib/python3.8/site-packages/setuptools/__init__.py", line 165, in setup
        return distutils.core.setup(**attrs)
      File "/usr/local/lib/python3.8/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/local/lib/python3.8/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/local/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/tmp/pip-build-env-w4fhf9mi/overlay/lib/python3.8/site-packages/setuptools/command/dist_info.py", line 31, in run
        egg_info.run()
      File "/tmp/pip-install-_wfg5a_u/numpy_fa5e263edf9148adaacb0681b6d34b56/numpy/distutils/command/egg_info.py", line 24, in run
        self.run_command("build_src")
      File "/usr/local/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/tmp/pip-install-_wfg5a_u/numpy_fa5e263edf9148adaacb0681b6d34b56/numpy/distutils/command/build_src.py", line 144, in run
        self.build_sources()
      File "/tmp/pip-install-_wfg5a_u/numpy_fa5e263edf9148adaacb0681b6d34b56/numpy/distutils/command/build_src.py", line 155, in build_sources
        self.build_library_sources(*libname_info)
      File "/tmp/pip-install-_wfg5a_u/numpy_fa5e263edf9148adaacb0681b6d34b56/numpy/distutils/command/build_src.py", line 288, in build_library_sources
        sources = self.generate_sources(sources, (lib_name, build_info))
      File "/tmp/pip-install-_wfg5a_u/numpy_fa5e263edf9148adaacb0681b6d34b56/numpy/distutils/command/build_src.py", line 378, in generate_sources
        source = func(extension, build_dir)
      File "numpy/core/setup.py", line 663, in get_mathlib_info
        raise RuntimeError("Broken toolchain: cannot link a simple C program")
    RuntimeError: Broken toolchain: cannot link a simple C program

Thanks for your support.

Sönke