Page 11 of 16

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Sunday 13 January 2019 13:59
by dagasoft

axel2906 wrote:]

i make sh file for each room. I take the coordinates from FloleVac (android app). this app do the same as the offical app but when you do clean zone, select the zone that you clean and then long press on cleanup he make a copy of the coordinates into the clipboard. I do it for each room.
Great!!!

I didn't know about that android app. I will check it out.

Lots of thanks Axel!!


Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Sunday 13 January 2019 15:19
by axel2906
dagasoft wrote: Sunday 13 January 2019 13:59
axel2906 wrote:]

i make sh file for each room. I take the coordinates from FloleVac (android app). this app do the same as the offical app but when you do clean zone, select the zone that you clean and then long press on cleanup he make a copy of the coordinates into the clipboard. I do it for each room.
Great!!!

I didn't know about that android app. I will check it out.

Lots of thanks Axel!!
You're welcome ! :D ;)

Now i can ask to my google home : "hey google ! clean the kitchen !" or "hey google ! clean the bedroom"

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Sunday 13 January 2019 15:24
by dagasoft
dagasoft wrote:
axel2906 wrote:]

i make sh file for each room. I take the coordinates from FloleVac (android app). this app do the same as the offical app but when you do clean zone, select the zone that you clean and then long press on cleanup he make a copy of the coordinates into the clipboard. I do it for each room.
Great!!!

I didn't know about that android app. I will check it out.

Lots of thanks Axel!!
Yes!!

That's what I want to do... By the way, are you using scenes for the voice commands?

I ask because I have to pass it through Controlicz and for Google to understand "Clean the kitchen" I suppose that you need an scene with that name. Am I right?

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Sunday 13 January 2019 16:36
by axel2906
dagasoft wrote: Sunday 13 January 2019 15:24
dagasoft wrote:
axel2906 wrote:]

i make sh file for each room. I take the coordinates from FloleVac (android app). this app do the same as the offical app but when you do clean zone, select the zone that you clean and then long press on cleanup he make a copy of the coordinates into the clipboard. I do it for each room.
Great!!!

I didn't know about that android app. I will check it out.

Lots of thanks Axel!!
Yes!!

That's what I want to do... By the way, are you using scenes for the voice commands?

I ask because I have to pass it through Controlicz and for Google to understand "Clean the kitchen" I suppose that you need an scene with that name. Am I right?
i use IFTTT for it. I will try it with controlicz. I suppose that you need an scene to do it

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Sunday 13 January 2019 20:11
by axel2906
axel2906 wrote: Sunday 13 January 2019 16:36
dagasoft wrote: Sunday 13 January 2019 15:24
dagasoft wrote:
Great!!!

I didn't know about that android app. I will check it out.

Lots of thanks Axel!!
Yes!!

That's what I want to do... By the way, are you using scenes for the voice commands?

I ask because I have to pass it through Controlicz and for Google to understand "Clean the kitchen" I suppose that you need an scene with that name. Am I right?
i use IFTTT for it. I will try it with controlicz. I suppose that you need an scene to do it
i doesn't find a way to excute an selector switch with controlicz. i use it only for simple request (temperature or other things like this). I prefer to use IFTTT to do this stuff (for the vacuum)

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Sunday 13 January 2019 21:30
by dagasoft
axel2906 wrote:
axel2906 wrote: Sunday 13 January 2019 16:36
dagasoft wrote: Sunday 13 January 2019 15:24 Yes!!

That's what I want to do... By the way, are you using scenes for the voice commands?

I ask because I have to pass it through Controlicz and for Google to understand "Clean the kitchen" I suppose that you need an scene with that name. Am I right?
i use IFTTT for it. I will try it with controlicz. I suppose that you need an scene to do it
i doesn't find a way to excute an selector switch with controlicz. i use it only for simple request (temperature or other things like this). I prefer to use IFTTT to do this stuff (for the vacuum)
I use a virtual switch to enable/disable vacuum and use a lua script to trigger level this way:

Code: Select all

commandArray = {}

-- Possible state's of Robot Vacuum:  Charging / Paused / Cleaning / Waiting / Back to home / Sleeping
-- Selector witch Robot Vacuum:       Clean(10) / Home(20) / Spot(30) / Pauze(40) / Stop(50) / Find(60)

-- Required to convert State to Stringvalue


if (devicechanged['Aspiradora - Estado']) then
	EstadoAspiradora = tostring(otherdevices_svalues['Aspiradora - Estado'])
	if (EstadoAspiradora == 'Cleaning' and otherdevices['Aspiradora']=='Off') then 
		commandArray['Aspiradora'] = 'On' 
	else if (EstadoAspiradora == 'Charging' and otherdevices['Aspiradora']=='On') then 
		commandArray['Aspiradora'] = 'Off' 
		end
	end
else if (devicechanged['Aspiradora']) then 
	if otherdevices['Aspiradora'] == 'On' then
		commandArray['Aspiradora - Control'] = 'Set Level 10'
	else if otherdevices['Aspiradora'] == 'Off' then
		commandArray['Aspiradora - Control'] = 'Set Level 20' end
	end
end
end

return commandArray

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Friday 18 January 2019 2:58
by dagasoft
Edited previous post to add the correct lua script for trigger Vacuum with a virtual switch so you can use it with Google Assistant an Controlicz

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Monday 21 January 2019 20:33
by Lebo2d9
Hi,

Is there someone who have python code to move the vacuum cleaner?
The docking station is hidden under a cupboard and I want, when the 1st time my geofence has detected somebody at home, that the vacuum cleaner is moving to the middle of the room and then I do a "find" just to notify to clean the bin

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Tuesday 22 January 2019 0:17
by dagasoft
Lebo2d9 wrote:Hi,

Is there someone who have python code to move the vacuum cleaner?
The docking station is hidden under a cupboard and I want, when the 1st time my geofence has detected somebody at home, that the vacuum cleaner is moving to the middle of the room and then I do a "find" just to notify to clean the bin
I'm using python-miio as Axel said in a previous post. You can use goto command to clean the dust bin. That's the way I use so it doesn't lose house mapping.

You can see more info about commands in https://python-miio.readthedocs.io/en/l ... acuum.html



Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Tuesday 22 January 2019 5:43
by Lebo2d9

dagasoft wrote:I'm using python-miio as Axel said in a previous post. You can use goto command to clean the dust bin. That's the way I use so it doesn't lose house mapping.

You can see more info about commands in https://python-miio.readthedocs.io/en/l ... acuum.html
Hi dagasoft, I have installed the python-miio but I can't launch the mirobot
I get this error
pi@raspberrypi:~ $ mirobo discover
-bash: mirobo: command not found

Kind regards

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Tuesday 22 January 2019 22:39
by Lebo2d9
Lebo2d9 wrote: Tuesday 22 January 2019 5:43
dagasoft wrote:I'm using python-miio as Axel said in a previous post. You can use goto command to clean the dust bin. That's the way I use so it doesn't lose house mapping.

You can see more info about commands in https://python-miio.readthedocs.io/en/l ... acuum.html
Hi dagasoft, I have installed the python-miio but I can't launch the mirobot
I get this error
pi@raspberrypi:~ $ mirobo discover
-bash: mirobo: command not found

Kind regards
Hi the problem is related to the $PATH, in the folder ~/.local/bin I'me able to run the mirobo command
My $PATH is "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"

Kind Regards

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Sunday 27 January 2019 0:54
by rood
I am trying for quite a long time to get the plugin to work.

when I execute: mirobo --ip 192.168.2.15 --token 4242xxxxxxxxx start[/i] it works perfectly.

when I start a clean-up in domoticz nothing happens. It looks like if no connection could be made.

in the error logs I see this:
2019-01-27 00:50:49.123 (Stofzuiger) 82 a9 65 78 63 65 70 74 69 6f 6e b6 70 79 74 68 6f 6e 2d 6d ��exception�python-m
2019-01-27 00:50:49.123 (Stofzuiger) 69 69 6f 3a 20 64 65 76 69 63 65 5f 69 64 a3 63 6d 64 a6 73 iio:.device_id�cmd�s
2019-01-27 00:50:49.123 (Stofzuiger) 74 61 74 75 73 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. tatus
2019-01-27 00:50:49.123 (Stofzuiger) Pushing 'onMessageCallback' on to queue
2019-01-27 00:50:49.123 (Stofzuiger) Processing 'onMessageCallback' message
2019-01-27 00:50:49.123 (Stofzuiger) Calling message handler 'onMessage'.
2019-01-27 00:50:49.123 (Stofzuiger) Got: {'exception': 'python-miio: device_id', 'cmd': 'status'}

but it doens't say anything to me. Anyone an idea?

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Sunday 27 January 2019 13:11
by Lebo2d9
rood wrote:I am trying for quite a long time to get the plugin to work.

when I execute: mirobo --ip 192.168.2.15 --token 4242xxxxxxxxx start[/i] it works perfectly.

when I start a clean-up in domoticz nothing happens. It looks like if no connection could be made.

in the error logs I see this:
2019-01-27 00:50:49.123 (Stofzuiger) 82 a9 65 78 63 65 70 74 69 6f 6e b6 70 79 74 68 6f 6e 2d 6d ��exception�python-m
2019-01-27 00:50:49.123 (Stofzuiger) 69 69 6f 3a 20 64 65 76 69 63 65 5f 69 64 a3 63 6d 64 a6 73 iio:.device_id�cmd�s
2019-01-27 00:50:49.123 (Stofzuiger) 74 61 74 75 73 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. tatus
2019-01-27 00:50:49.123 (Stofzuiger) Pushing 'onMessageCallback' on to queue
2019-01-27 00:50:49.123 (Stofzuiger) Processing 'onMessageCallback' message
2019-01-27 00:50:49.123 (Stofzuiger) Calling message handler 'onMessage'.
2019-01-27 00:50:49.123 (Stofzuiger) Got: {'exception': 'python-miio: device_id', 'cmd': 'status'}

but it doens't say anything to me. Anyone an idea?
Have you added the ipadress and the token of your robot in the miio_server.sh file?

Kind regards Koen

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Sunday 27 January 2019 15:37
by rood
Yes I have. After couple of hours of fighting, decided to completly reinstall my PI. It works now!

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Sunday 10 February 2019 18:21
by BUSHA
deennoo wrote: Monday 02 October 2017 18:36
kluczus wrote: Monday 02 October 2017 17:09
kluczus wrote: Friday 29 September 2017 13:41 How to check a status of the vacuum ? I installed plugin, everything works just fine. I was trying to define a blockly with notification when vacuum is comming back to home but without luck.
Blocky

Code: Select all

if vacuum-status = "Back to home" then ....
is not working
Anyone ?
That just a basic LUA event on a selector switch, nothing hard on this, all is explain on the wiki, and your question isn't Xiaomi Vaccum robot specific
Your best reading is : https://www.domoticz.com/wiki/Events
It's not a selector. I can't find way to send notifications too :(

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Thursday 14 February 2019 8:58
by BUSHA
RESOLVED.

LUA code for telegram notifications:

Code: Select all

commandArray = {}

token = "YOUR_TELEGRAM_TOKEN"
chatid = CHAT_ID
cleaning = '🧹Уборка начата'
charge = '✅ Уборка завершена. Пылесос вернулся на базу и заряжается'
waiting = '❗Пылесос не смог вернуться на базу'
problem = '❗️У пылесоса проблемы'

status_vacuum = otherdevices_svalues["Mi Robot - Status"]

if ((devicechanged['Mi Robot - Status'])) then
    
if ((status_vacuum == "Cleaning")) then
    os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..cleaning..'"  "https://api.telegram.org/bot'..token..'/sendMessage" ')
elseif ((status_vacuum == "Waiting")) then
    os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..waiting..'"  "https://api.telegram.org/bot'..token..'/sendMessage" ')
elseif ((status_vacuum == "Charging")) then
    os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..charge..'"  "https://api.telegram.org/bot'..token..'/sendMessage" ')
elseif ((status_vacuum == "In Error")) then
    os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..problem..'"  "https://api.telegram.org/bot'..token..'/sendMessage" ')    
    
end
end
return commandArray
Do not forget to change "Mi Robot - Status" to your status device name.

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Friday 08 March 2019 15:12
by Darkneo
Hi there,

I just installed the plugin (hoping that other issues I already solved with python will handle potential issues for this plugin)... Unfortunately it did not... :cry:

I raised an issue on Git for that topic but if someone can help.

Domoticz 4.97
Installed on Synology

After creating the harware, I am having those errors:
2019-03-07 23:22:35.160 Error: (xiaomi-mi-robot-vacuum) failed to load 'plugin.py', Python Path used was '/usr/local/domoticz/var/plugins/xiaomi-mirobot/:/volume1/@appstore/py3k/usr/local/lib/python35.zip:/volume1/@appstore/py3k/usr/local/lib/python3.5/:/volume1/@appstore/py3k/usr/local/lib/python3.5/plat-linux:/volume1/@appstore/py3k/usr/local/lib/python3.5/lib-dynload'.
2019-03-07 23:22:35.247 Error: (Vacuum) Module Import failed, exception: 'ImportError'
2019-03-07 23:22:35.247 Error: (Vacuum) Module Import failed: ' Name: msgpack'
2019-03-07 23:22:35.247 Error: (Vacuum) Error Line details not available.
Missing python packages? Which ones?

Thanks for your help :)

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Friday 05 April 2019 14:35
by bazyl
I stuck with Roborock V2 configuration on OragnePI2 - latest beta Domoticz V4.10602.
I can ping Roborock from OrangePI.

Followed instruction, but during test i get:

1. SSH Connection with miio_server.py

:/home/domoticz/domoticz/plugins/xiaomi-mirobot# ./miio_server.py 192.168.1.18 TOKEN --host 127.0.0.1 --port 22222
server: Starting server on 127.0.0.1 22222
server: connected ('127.0.0.1', 46868)
server: got socket msg: ['status']
Got error when receiving: timed out
Retrying with incremented id, retries left: 3
Got error when receiving: timed out
Retrying with incremented id, retries left: 2
Got error when receiving: timed out
Retrying with incremented id, retries left: 1
Got error when receiving: timed out
server: vac result {'cmd': 'status', 'exception': 'python-miio: '}
server: send reply ('127.0.0.1', 46868)
server: closed connection ('127.0.0.1', 46868)


2. SSH Connection with ./test.py

:/home/domoticz/domoticz/plugins/xiaomi-mirobot# ./test.py
test: python modules path: ././.env/lib/python3.5/site-packages
test: trying connect to 127.0.0.1:22222
test: sent request to server [status]
test: reading response...
test: got server reply {'cmd': 'status', 'exception': 'python-miio: '}

Any ideas? I tried reinstall plugin few times. No other issues during first part of installation.


-------------------------------
Nevermind. My token was changed during flashing firmware from International to China version....
With new token it works perfectly fine! Thanks for great plugin!

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Sunday 28 April 2019 19:55
by rensbr
I used this plugin for quite some time now and it works great. Recentely is installed a new Raspberry pi (and did a clean install of Domoticz and all the plugins). But now the plugin does not want to work.

I followed all the steps, but when I tried to test / start the server:

Code: Select all

sudo service miio_server start
I get the following error:
Job for miio_server.service failed because the control process exited with error code.
See "systemctl status miio_server.service" and "journalctl -xe" for details.
When I check 'systemctl' the following appears:
● miio_server.service - LSB: MIIO Server
Loaded: loaded (/etc/init.d/miio_server; generated; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-04-28 19:39:35 CEST; 34s ago
Docs: man:systemd-sysv-generator(8)
Process: 25776 ExecStart=/etc/init.d/miio_server start (code=exited, status=1/FAILURE)

Apr 28 19:39:35 raspberrypi systemd[1]: Starting LSB: MIIO Server...
Apr 28 19:39:35 raspberrypi miio_server[25776]: File "/etc/init.d/miio_server", line 14
Apr 28 19:39:35 raspberrypi miio_server[25776]: PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
Apr 28 19:39:35 raspberrypi miio_server[25776]: ^
Apr 28 19:39:35 raspberrypi miio_server[25776]: SyntaxError: invalid syntax
Apr 28 19:39:35 raspberrypi systemd[1]: miio_server.service: Control process exited, code=exited status=1
Apr 28 19:39:35 raspberrypi systemd[1]: Failed to start LSB: MIIO Server.
Apr 28 19:39:35 raspberrypi systemd[1]: miio_server.service: Unit entered failed state.
Apr 28 19:39:35 raspberrypi systemd[1]: miio_server.service: Failed with result 'exit-code'.
There is an SyntaxError in the file, but on a line that I haven't changed.

The miio_server is below:
#!/home/pi/domoticz/plugins/xiaomi-mirobot/.env/bin/python3
### BEGIN INIT INFO
# Author: mrin
# Provides: miio_server
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: MIIO Server
# Description: This daemon will start MIIO Server
### END INIT INFO

NAME="MIIO Server"
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
SCRIPTNAME=/etc/init.d/miio_server
PIDFILE=/var/run/miio_server.pid

DAEMON_USER=root
DAEMON=/home/pi/domoticz/plugins/xiaomi-mirobot/miio_server.py
DAEMON_ARGS="192.168.0.193 364b546f737678505353374d496e3255"
DAEMON_ARGS="$DAEMON_ARGS --host 127.0.0.1 --port 22222"
I have the following versions:
ython3 is already the newest version (3.5.3-1).
python3-dev is already the newest version (3.5.3-1).
python3-pip is already the newest version (9.0.1-2+rpt2).
libffi-dev is already the newest version (3.2.1-6).
libssl-dev is already the newest version (1.1.0j-1~deb9u1).
Plugin: Last version from Github
Domoticz; Stable 4.9700
The strange thing is, when I test the function with:

Code: Select all

sudo ./miio_server.py 192.168.0.193 364b546f737678505353374d496e3255 --host 127.0.0.1 --port 22222


It seems to work:
sudo ./miio_server.py 192.168.0.193 364b546f737678505353374d496e3255 --host 127.0.0.1 --port 22222
server: Starting server on 127.0.0.1 22222
server: connected ('127.0.0.1', 48294)
server: got socket msg: ['consumable_status']
server: got socket msg: ['status']
Unable to discover a device at address 192.168.0.193
server: vac result {'cmd': 'consumable_status', 'exception': 'python-miio: Unable to discover the device 192.168.0.193'}
server: send reply ('127.0.0.1', 48294)
Unable to discover a device at address 192.168.0.193
server: vac result {'cmd': 'status', 'exception': 'python-miio: Unable to discover the device 192.168.0.193'}
server: send reply ('127.0.0.1', 48294)
server: got socket msg: ['status']
server: vac result {'cmd': 'status', 'clean_area': 1.64, 'state_code': 8, 'clean_seconds': 0, 'battery': 100, 'error': None, 'fan_level': 77}
server: send reply ('127.0.0.1', 48294)
Has anybody an idea what is wrong?

Edit: I have found a workout. I used the script provided in: https://www.domoticz.com/forum/viewtopi ... 29#p183929 and now it works again.

Blocky, ant mirobot state

Posted: Friday 07 June 2019 13:58
by KiiB
Hello Guys,
Maybe anyone tried to insert mi robot " State 12: 'In Error' " in blocky script?
I tried doing so in difrent formants and difrent fields, but none of them works.
Maybe someone had better luck?
I would like to write simple script to try restart cleaning again (at least few times) if error apear, and if battery is above 25% and also send push up messege to my phone.
pick up field do not work because "In error" have same state as "charging" or "paused". Thoose all statuses in domoticz are shown as state 0.
Value is shown as "0/In Error" but cant get it working with that syntax.

Thank You :)