onfoot / homebridge-valetudo-xiaomi-vacuum

A Homebridge plugin for Xiaomi/Roborock vacuum cleaners running Valetudo
MIT License
31 stars 9 forks source link

support for Valetudo zones and "go to locations" #11

Open aebgit opened 4 years ago

aebgit commented 4 years ago

I want to ask if you would consider support for cleaning of zones and "go to locations" defined in Valetudo. Valetudo provides a great UI to define Zones and "Goto Locations". Having them available in Homekit would allow to ask Siri to "clean the living room" for example. I have realized this for now with a workaround via the plugin "homebridge-http" that makes just a put request to the API. Please see my config-examples below:

With this switch I can ask Siri to clean the living-room (Zone-ID "-2"). I retrieved the IDs via developer mode of a WebBrowser from /api/zones:

{
            "accessory": "HTTP-SWITCH",
            "name": "Putze das Wohnzimmer",
            "switchType": "stateless",
            "timeout": 5000,
            "onUrl": {
                "url": "http://192.168.10.245/api/start_cleaning_zones_by_id",
                "method": "PUT",
                "body": "[-2]",
                "headers": {
                    "Content-Type": "application/json"
                }
            }
},

With this switch I can ask the vacuum to got to a dedicated coordinate. I use this in a scene to drive the vacuum triggered by a schedule to the trash bin. I retrieved the coordinates via developer mode of a WebBrowser from /api/spots:

{
            "accessory": "HTTP-SWITCH",
            "name": "Gehe zum Mülleimer",
            "switchType": "stateless",
            "timeout": 5000,
            "onUrl": {
                "url": "http://192.168.10.245/api/go_to",
                "method": "PUT",
                "body": {
                    "x": 2402,
                    "y": 2288
                },
                "headers": {
                    "Content-Type": "application/json"
                }
            }
},
onfoot commented 4 years ago

Yeah, I have been thinking about it, but since I haven't had the opportunity to start working on it, because I use my vacuum on two floors, so all zones pretty much invalidate themselves once the vacuum has to find its way all over again. I should probably look into saving/restoring/switching maps so I could actually use this. ;)

I'd need to enumerate the zones set up currently, and expose buttons for them. If it's possible to do it dynamically so that after zones are added or edited we don't need to restart the plugin/homebridge, then we're golden. I'll check out the api and finally start implementing this. Shouldn't be too hard probably. Thanks!