mrin / domoticz-mirobot-plugin

Xiaomi Mi Robot Vacuum plugin for Domoticz
57 stars 28 forks source link

Implement Zones? #10

Open MarcE85 opened 6 years ago

MarcE85 commented 6 years ago

Will there be an update that implements the new "Go" and "Zone" Function?

acca84 commented 6 years ago

Hi, just wanted to say that this plugin works very fine with Roborock Vacuum V2. And to say it would be very cool if one can implement those functions Thank you very much !

arjannv commented 5 years ago

Hi, I would like to have this as well! Is there a way to send raw commands from Domoticz to the Robot? Then we might be able to figure out the required zone and start the cleaning with Lua.

arjannv commented 5 years ago

Hi! I made a script to start a zoned cleanup from a Domoticz dzVents script. Unfortunately, it is not yet working as it should.. If I start the command from terminal, it works as expected. If I start it with dzVents script below, nothing happens; also no output from print().

EDIT: Got it working:) When I run it as local user, it works. See below for updated (and working) script. Also tweaked the Python script so that it works out the order of coordinates.

In Domoticz: command = "runuser -l arjan -c 'python3 /home/arjan/domoticz/plugins/xiaomi-mirobot/zone.py " .. domoticz.utils.round(x1, 0) .. " " .. domoticz.utils.round(y1, 0) .. " " .. domoticz.utils.round(x2, 0) .. " " .. domoticz.utils.round(y2, 0) .. " " .. domoticz.utils.round(iterations, 0) .. "'" local f = assert(io.popen(command, 'r')) local response = assert(f:read('*a')) f:close() domoticz.log(response, domoticz.LOG_INFO)

The zone.py script: zone.py.txt

MarcE85 commented 5 years ago

Hi! I made a script to start a zoned cleanup from a Domoticz dzVents script. Unfortunately, it is not yet working as it should.. If I start the command from terminal, it works as expected. If I start it with dzVents script below, nothing happens; also no output from print().

EDIT: Got it working:) When I run it as local user, it works. See below for updated (and working) script. Also tweaked the Python script so that it works out the order of coordinates.

In Domoticz: command = "runuser -l arjan -c 'python3 /home/arjan/domoticz/plugins/xiaomi-mirobot/zone.py " .. domoticz.utils.round(x1, 0) .. " " .. domoticz.utils.round(y1, 0) .. " " .. domoticz.utils.round(x2, 0) .. " " .. domoticz.utils.round(y2, 0) .. " " .. domoticz.utils.round(iterations, 0) .. "'" local f = assert(io.popen(command, 'r')) local response = assert(f:read('*a')) f:close() domoticz.log(response, domoticz.LOG_INFO)

The zone.py script: zone.py.txt

thx for this script. Did you update your python-miio version??

arjannv commented 5 years ago

thx for this script. Did you update your python-miio version??

I've got the latest version, this is needed for the zone and spot function.

Only changed the plugin.py from the domoticz plugin to show the correct Status in Domoticz. plugin.py.txt Added status: 17: 'Zone cleaning',

mpadwick commented 2 years ago

Hi I know this is an old thread, but thought I'd through out a hook just in case.

Thanks for a nice addition.

How did you get the coordinates? I'm assuming x1 y1 x2 y2 are the limiting coordinates? I basic "howto use" would be much appreciated.

arjannv commented 2 years ago

That is correct, x1, y1, x2, y2 are the limits of the zone. I've created a little goto spot script to find the coordinates. It was just a bit of trial and error. spot.py.txt Easiest is to put this script in the same folder as the files of the domoticz plugin. Just run the script from terminal with python3 spot.py X Y Don't forget to change the IP and TOKEN in both the spot.py and zone.py files.

The numbers are in millimetres. The docking stations is at 25500, 25500. So you can roughly guess where your zone needs to start and stop.

When you issue an command for a goto or zone, you can also see the result in the Xiaomi app.

mpadwick commented 2 years ago

Thanks. I'm running Domoticz and the miio-server in separate docker containers. Is the any way I can connect and send the commands via my miio-server? Instead of downloading the modules and establishing a new session from the spot.py file on my laptop.