Ecovacs Binding

Hey everyone!

I would love to start development on an Ecovacs Binding.
There are some libraries in the wild for python and JS, that I would like to use as a basis and port huge chunks of their code to Java:

Examples:

There are some requirements:

  1. We would need to talk XMPP and I am not sure if we already use some XMPP library in other bindings (XMPP | XMPP Libraries & Tools)
  2. As far as I get it, we would need to permanently listen to XMPP events for each roboter.

I am not sure how we would accomplish the runtime requirements of using job scheduling.
So I wanted to start a discussion here.

Should I first try to port the library to java for proof of concept?
What do you think about runtime behavior with XMPP?

1 Like

I will start trying to convert the python implementation to java as a first step.
Still happy to hear opinions on how to handle listening to xmpp events in a way that works fine with the runtime behavior requirements for openhab. Maybe there is some kind of solution.

That sounds linke a meaningful plan. First do Java HTTP API PoC, then add XMPP listening to it, then move to OH binding.

What specifically is unclear there? At its core XMPP is also just a socket, and we open listen sockets in a lot of bindings (avmfritz, squeezebox come to my mind immediately, but there’s surely a lot more of them).
As for choosing an XMPP library, there already is an XMPP client binding, might want to look up what that one is using.

BTW, I may join forces in Ecovacs binding development…just need to find some free time.

1 Like

As far as I understood from reading the docs, we should not start any kind of threads in favor of scheduling, but maybe I also missunderstood something here.

As I alrady stated: I will probably start this evening with migration of the python library and see if there are any major pitfalls.
Will link to the repository as soon as I got the first working version of the java implementation.
First step here will be just the http connection and secondly the most basic commands for start/stop cleaning with XMPP.

Would be really happy to get some support for the binding creation afterwards, since I never contributed to a binding before.

I think one should avoid creating short-lived threads that execute a single task only. Creating (few) long-lived threads should be fine, especially as there’s no other way of implementing this particular task without a new thread.

1 Like

Yes indeed. It seems to be the only way :slight_smile:

On thing that is currently unclear to me:
The libraries in the wild are using some sort of client ID. I am not sure how they get it and what we should put there. Will start with one of the library IDs, but we should find out how they acquire those IDs.

I did not have too much time, but the first login call is almost working. Currently trying to figure out, why I get 0002 code instead of 0000.

EDIT: Seems like I forgott some signing for the call

Added signing and got a successful ressponse from the ecovacs servers now.

Some additional thoughts

  • The libraries in the wild are all using some client keys and secrets, where I dunnot know where they got them from
  • For maintainability we should write docs on how to find those (probably by decompiling the android app)
  • If we add a binding in the future we should make sure to put all those things in a place, where openhab users can easily replace those, if they become invalid at some point

Looking through the sources (and PRs) in the sucks project, it seems that one must implement both XMPP and MQTT communication to their servers, depending on the device model?
What model do you have? I have an Deebot 950, which seems to talk MQTT.

1 Like

Yes I also noticed that there is some variation in the libs, but I did not look further into it.
I got a Deebot 901 (Non-OZMO) and a N8 Pro with station :slight_smile:
Where did you find out if your robot uses mqtt?

EDIT: Found it “static isDeviceClass950type(deviceClass, isMQTTProtocolUsed = true)”

Finished the login process for now. Also did some small cleanup, but still far from finished. Hopefully I will be able to make the first request for an action for one of my devices tomorrow.
Otherwise I will only have time next weekend.

Next step will be some cleanup + requesting devices. After that we should be able to start implementing basic commands already.
Once thats done in my POC we can think about porting everything + cleanup/code structure changes for the binding. :slight_smile:

Requesting devices works as well now :slight_smile:

1 Like

Just a small update for everyone interested:
@maniac103 already added basic mqtt connection for devices 950 and newer. Also a basic binding was started.
:slight_smile:

4 Likes

Would be a great achievement if this will get a binding in one of the next milestones. Thanks for your work and for pushing this forward.