add custom component from main branch

This commit is contained in:
bittles
2023-01-02 18:22:04 -05:00
parent 33d864b3a5
commit 9a4481ae5f
8 changed files with 2867 additions and 136 deletions
+36 -136
View File
@@ -1,152 +1,52 @@
Linux: [![Build Status](https://travis-ci.org/wpietri/sucks.svg?branch=master)](https://travis-ci.org/wpietri/sucks)
Windows: [![Build Status](https://ci.appveyor.com/api/projects/status/github/wpietri/sucks)](https://ci.appveyor.com/project/wpietri/sucks)
# Home Assistant Ecovacs Custom Component with Bumper Support
Replaces built in ecovacs component.
Works with bumper with my N79 and should work with at least other XMPP based ecovacs. Don't know if changes will work with MQTT based ones.
sucks
=====
Added additional catches to sucks because my N79 sends some weird payloads, but attributes all pull in now for brush life spans. Couple initial queries it also sends weird that I'm in process of catching atm. As of version 1.3.0 (in the manifest.json) these initial queries and all attributes are working. Was using an implementation completely mine but saw in the MQTT class there were already catches for child payloads without the main payload having the expected td in its payload. Kept comments in giving credit and adapted them to work with xmpp.
A simple command-line python script to drive a robot vacuum. Currently
known to work with the Ecovacs Deebot N79, M80 Pro, M81, M88
Pro, and R95 MKII from both North America and Europe.
With bumper and my N79 commands would work but some queries had responses that included errno='', which bumper would flag as an error even though the full response was there. If your debug logs are throwing errors and the errno is '' then my small fork of bumper may help https://github.com/bittles/bumper-fork
Does it work for your model as well? Join the discussion on the
[sucks-users mailing
list](https://groups.google.com/forum/#!forum/sucks-users).
Should work as regular if bumper isn't used in config but haven't tested yet, goal was to get it all local. Maybe mess around and test it in future.
If you're curious about the protocol, I have [a rough doc](http://github.com/wpietri/sucks/blob/master/protocol.md)
started. I'll happily accept pull requests for it.
I'm using the docker-compose example for bumper by bmartin5692, https://github.com/bmartin5692/bumper on an odroid-n2+.
Why the project name? Well, a) it's ridiculous that I needed to MITM
my own vacuum. This is not the future I signed up for. And b),
it's a vacuum.
## Installation
If you have a recent version of Python 3, you should be able to
do `pip install sucks` to get the most recently released version of
this.
## Usage
To get started, you'll need to have already set up an EcoVacs account
using your smartphone.
With that ready, step one is to log in:
For DNS routing I have an Asus AX88u with asus-merlin installed running Adguard. DNS rewrites in AdGuard for domains:
```
% sucks login
Ecovacs app email: [your email]
Ecovacs app password: [your password]
your two-letter country code: us
your two-letter continent code: na
Config saved.
*.ecouser.net
*.ecovacs.com
*.ecovacs.net
```
pointing to my bumper server.
That creates a config file in a platform-appropriate place. The password
is hashed before saving, so it's reasonably safe. (If it doesn't appear
to work for your continent, try "ww", their world-wide catchall.)
Big credits to bmartin5692 for his fork of sucks to base this off of as well.
With that set up, you could have it clean in auto mode for 10 minutes
and return to its charger:
## Home Assistant Install & Config
Drop the ecovacs folder into your custom_components folder. If I polish this up I'll add hacs support.
Restart HASS.
In your configuration.yaml:
```
% sucks clean 10
ecovacs:
username:
password:
country:
continent:
bumper: true/false (optional, defaults false)
bumper_server: (optional, defaults null)
verify_ssl: true/false, false if using bumper (optional, defaults true)
```
Any username, password, country, and continent should work if bumper is true. Set bumper_server to the ip_address where you're running bumper and set verify_ssl to false for bumper. If you're not using bumper this SHOULD technically work no different than the Home Assistant ecovacs integration but I haven't looked at it enough to be sure and I haven't tested it.
You could have it clean for 15 minutes and then do an extra 10 minutes
of edging:
### Example Config
```
% sucks clean 15 edge 10
ecovacs:
username: bumper
password: bumper
country: us
continent: na
bumper: true
bumper_server: "192.168.1.55"
verify_ssl: false
```
If you wanted it to clean for 5 minutes and then stop without charging:
```
% sucks clean 5 stop
```
If it's running amok and you'd just like it to stop where it is:
```
% sucks stop
```
To tell it to go plug in:
```
% sucks charge
```
I run mine from my crontab, but I didn't want it to clean every day,
so it also has a mode where it randomly decides to run or not based on
a frequency you give it. My crontab entry looks like this:
```
0 10 * * * /home/william/projects/sucks/sucks.sh clean -f 4/7 15 edge -f 1/14 10
```
This means that every day at 10 am, it might do something. 4 days out
of 7, it will do 15 minutes of automatic cleaning. 1 day out of 14,
it will do 10 minutes of edging. And afterward it will always go back to
charge.
## Library use
You are welcome to try using this as a python library for other efforts. The
API is still experimental, so expect changes. Please join the [mailing
list](https://groups.google.com/forum/#!forum/sucks-users) to participate in
shaping the API.
A simple usage might go something like this:
```python
from sucks import *
config = ...
api = EcoVacsAPI(config['device_id'], config['email'], config['password_hash'],
config['country'], config['continent'])
my_vac = api.devices()[0]
vacbot = VacBot(api.uid, api.REALM, api.resource, api.user_access_token, my_vac, config['continent'])
vacbot.connect_and_wait_until_ready()
vacbot.run(Clean()) # start cleaning
time.sleep(900) # clean for 15 minutes
vacbot.run(Charge()) # return to the charger
```
## Developing
If you'd like to join in on developing, I recommend checking out the code,
setting up a virtual environment, and installing this package in editable
mode. You can confirm your environment works by running the tests. And please
do join the [mailing list](https://groups.google.com/forum/#!forum/sucks-users)
to discuss your plans.
For more information see [the development documentation](developing.md).
## See also
There are now similar libraries in [Javascript](https://github.com/joostth/sucks.js)
and [Go](https://github.com/skburgart/go-vacbot).
## Thanks
My heartfelt thanks to:
* [xmpppeek](https://www.beneaththewaves.net/Software/XMPPPeek.html),
a great library for examining XMPP traffic flows (yes, your vacuum
speaks Jabbber!),
* [mitmproxy](https://mitmproxy.org/), a fantastic tool for analyzing HTTPS,
* [click](http://click.pocoo.org/), a wonderfully complete and thoughtful
library for making Python command-line interfaces,
* [requests](http://docs.python-requests.org/en/master/), a polished Python
library for HTTP requests,
* [Decompilers online](http://www.javadecompilers.com/apk), which was
very helpful in figuring out what the Android app was up to,
* Albert Louw, who was kind enough to post code from [his own
experiments](https://community.smartthings.com/t/ecovacs-deebot-n79/93410/33)
with his device, and
* All the users who have given useful feedback and contributed code!
Just finished getting this working late 12/13/22 so not sure if everything works yet but will commit changes here if I update it or at least document issues.