Open Phype opened 3 years ago
Added (Simple) ability to list maps and zones for API v1 in commit a8a26f7
$ python3 -m purei9_unofficial cloud -v 1 -c ... maps -r 900395798357985798375972
+--------------------------------------+------+------------+
| id | name | zones |
+--------------------------------------+------+------------+
| 00000000-0000-0000-0000-000000000000 | map1 | ['zone1'] |
+--------------------------------------+------+------------+
Cleaning a specific zone is possible since f459fc236f5bd9dead00737d12236fa48af525d4 on the v2 API, but this one lacks getting map images
Also implemented for v1 in f5088f79949bc4a612b614fc4c478672f942e54f
It would be awesome to be able to download map images for v2 API. Is there anything I can do to help?
Thanks for your hard work.
I checked again, but there are no images in the classic sense anymore (The old API had server-generated png's). It's some kind of json which needs to be plotted. I added some code if you really want to look at it: https://github.com/Phype/purei9_unofficial/blob/master/src/purei9_unofficial/cloudv2.py#L273
Its 8KByte of gzipped json which looks like this:
{ "chargerPose": { "t": 1000, "xya": [ 0, 0, 0.0001265096 ] }, "crumbs": [ { "t": 1000, "xy": [ -0.2516245, 0.32190162 ] }, { "t": 1000, "xy": [ -0.14708723, 0.32914242 ] }, { "t": 1000, "xy": [ -0.04283733, 0.3379979 ] }, { "t": 1000, "xy": [ 0.040577278, 0.34455898 ] }, { "t": 1000, "xy": [ 0.032779854, 0.4312258 ] }, [...]
Even if we could plot it, i'm unsure if it makes sense to put effort into this given that they changed the app and API once again, so any work has to be re-done in some months.
Interesting.
When time allows it, I'm going to play around a bit and see if I can't throw this into an SVG and hopefully generate something useful. Not going to spend a lot of time on it since, as you mention, it might be in vain if they change it. Still, can be a fun project for me. 🙂
I've had a chance to play around with plotting the map data and managed to get some reasonable results. Once I've made my code a bit more robust, I'll create a PR.
Findings so far:
(edited to fix formatting, image not rendering and correct formula)
Here's a preview of the mapping comparing the map drawn by the Electrolux One app and the mapping that I'm working on:
It's not ready for a pull request but you can preview the work here: https://github.com/louisjennings/purei9_unofficial/blob/871b17aaa54b62d3c2e266d347f4b077d90b7b62/src/purei9_unofficial/plot_map.py
I've tried a few map generation algorithms:
Great working! I'm excited about the results and the ability to implement this in Home Assistant. 🙂
@louisjennings great work! Assuming we can draw the map, the qeustion @Ekman would be what format it should ideally be in for homeassistand to display it?
Just some Options:
I've added some code using PIL (because i think having a dependency on matploitlib wouln't be great) into the image branch which comes out pretty good i think:
CloudMap.getImage() returns a byte array containing a PNG whoch can be displayed. For integration in homeassistant, i thing the vaccuum integration seems to have a MAP
capability (See homeassistan_doku), but i couldn't find out how to use it. Other people seemed to create a Camera integration, but this seems mor like a hack.
TODO: For me this the code works, but it doesn't show the correct map. In the end we would probably want to display the map from the last run, not the stroed "Map" which is used to define Clening and Avoid zones.
I'll make it work as long as it's an image. I'm a huge fan of SVG since it's so lightweight, but any format works really. :slightly_smiling_face:
It was a while ago that I studied other vacuum integrations, but if I remember correctly then the camera is the way to go.
:white_check_mark: List maps :white_check_mark: List zones :clipboard: Add possibility to pass a zone to the clean command