Python plugin: Xiaomi Mi Robot Vacuum Topic is solved

Python and python framework

Moderator: leecollings

Post Reply
Noka
Posts: 14
Joined: Thursday 14 December 2017 8:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Noka »

Like this?

Thanks for your help.
Attachments
Sans titre.jpg
Sans titre.jpg (82.37 KiB) Viewed 7387 times
domoticzplugin.jpg
domoticzplugin.jpg (88.64 KiB) Viewed 7387 times
mrinner
Posts: 56
Joined: Tuesday 22 August 2017 20:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Belarus
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by mrinner »

@Noka
Folder structure looks good.
Which version domoticz? Plugin for 8.153+. Also, maybe you has compiled domoticz without python support? I mean python was not installed when you compiled domoticz? Also need to restart domoticz after plugin installation.
Noka
Posts: 14
Joined: Thursday 14 December 2017 8:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Noka »

Which version domoticz? Plugin for 8.153+

Hem, I have the version 3.8789... You mean 3.8153+ ? :)
I unistalled the plugin and install it again. But nothing changes. I restarted several times domoticz.
napo7
Posts: 20
Joined: Monday 06 February 2017 8:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by napo7 »

Can you copy/paste the first 200 lines of your domoticz log (just after startup) ?
Noka
Posts: 14
Joined: Thursday 14 December 2017 8:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Noka »

There it is

Code: Select all

2017-12-18 13:34:04.618 Domoticz V3.8791 (c)2012-2017 GizMoCuz
2017-12-18 13:34:04.624 Build Hash: d642f4ca, Date: 2017-12-17 00:30:12
2017-12-18 13:34:04.626 Startup Path: /home/pi/domoticz/
2017-12-18 13:34:05.118 Sunrise: 07:18:00 SunSet:15:56:00
2017-12-18 13:34:05.118 EventSystem: reset all events...
2017-12-18 13:34:05.139 PluginSystem: Failed dynamic library load, install the latest libpython3.x library that is available for your platform.
2017-12-18 13:34:05.257 Active notification Subsystems: (0/14)
2017-12-18 13:34:05.289 WebServer(HTTP) started on address: :: with port 8080
2017-12-18 13:34:05.351 WebServer(SSL) started on address: :: with port 443
2017-12-18 13:34:05.373 Proxymanager started.
2017-12-18 13:34:05.395 Incoming connection from: 192.168.1.254
2017-12-18 13:34:05.424 Starting shared server on: :::6144
2017-12-18 13:34:05.459 TCPServer: shared server started...
2017-12-18 13:34:05.459 RxQueue: queue worker started...
2017-12-18 13:34:07.461 XiaomiGateway: will listen on 9898 for hardware id 2
2017-12-18 13:34:07.463 XiaomiGateway: Delaying worker startup...
2017-12-18 13:34:12.466 EventSystem: reset all events...
2017-12-18 13:34:12.468 EventSystem: reset all device statuses...
2017-12-18 13:34:12.475 Harmony Hub: Worker thread started...
2017-12-18 13:34:12.475 YeeLight Worker started...
2017-12-18 13:34:12.476 XiaomiGateway: Worker started...
2017-12-18 13:34:12.483 XiaomiGateway: Using 192.168.1.68 for local IP address.
2017-12-18 13:34:12.588 XiaomiGateway: RGB Gateway Detected
2017-12-18 13:34:12.777 EventSystem - Python: Failed dynamic library load, install the latest libpython3.x library that is available for your platform.
2017-12-18 13:34:12.780 (Centrale Xiaomi) Lighting Limitless/Applamp (Xiaomi RGB Gateway)
2017-12-18 13:34:12.780 EventSystem: Queue thread started...
2017-12-18 13:34:12.786 EventSystem: Started
I see this line must help for me

Code: Select all

2017-12-18 13:34:05.139 PluginSystem: Failed dynamic library load, install the latest libpython3.x library that is available for your platform.
I will try to re install libpython3.x library
Noka
Posts: 14
Joined: Thursday 14 December 2017 8:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Noka »

Ok I tried to install python again using this command:

Code: Select all

sudo apt-get install python3 python3-dev python3-pip
But it can't install python3-dev !

Code: Select all

The following packages have unmet dependencies:
 python3-dev : Depends: python3 (= 3.4.2-2) but 3.5.3-1 is to be installed
               Depends: libpython3-dev (= 3.4.2-2) but it is not going to be installed
               Depends: python3.4-dev (>= 3.4.2-0) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
It might be the source of the problem
napo7
Posts: 20
Joined: Monday 06 February 2017 8:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by napo7 »

It seems that some already installed package is blocking it !
try to do

Code: Select all

sudo aptitude install python3-dev
It should be more informative of why it can't be installed !
Noka
Posts: 14
Joined: Thursday 14 December 2017 8:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Noka »

Thanks, there is the result:

Code: Select all

The following NEW packages will be installed:
  libexpat1-dev{ab} libpython3-dev{a} libpython3.4{a} libpython3.4-dev{a}
  libpython3.4-minimal{a} libpython3.4-stdlib{a} python3-dev{b}
  python3.4{a} python3.4-dev{a} python3.4-minimal{a}
0 packages upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 44.2 MB of archives. After unpacking 70.0 MB will be used.
The following packages have unmet dependencies:
 python3-dev : Depends: python3 (= 3.4.2-2) but 3.5.3-1 is installed
 libexpat1-dev : Depends: libexpat1 (= 2.1.0-6+deb8u4) but 2.2.0-2+deb9u1 is installed
 findutils : Breaks: libpython3.4-minimal (< 3.4.4-2) but 3.4.2-1 is to be installed
The following actions will resolve these dependencies:

      Keep the following packages at their current version:
1)      libexpat1-dev [Not Installed]
2)      libpython3-dev [Not Installed]
3)      libpython3.4 [Not Installed]
4)      libpython3.4-dev [Not Installed]
5)      libpython3.4-minimal [Not Installed]
6)      libpython3.4-stdlib [Not Installed]
7)      python3-dev [Not Installed]
8)      python3.4 [Not Installed]
9)      python3.4-dev [Not Installed]
10)     python3.4-minimal [Not Installed]

      Leave the following dependencies unresolved:
11)     python3.4-minimal recommends python3.4



Accept this solution? [Y/n/q/?] y
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.
napo7
Posts: 20
Joined: Monday 06 February 2017 8:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by napo7 »

It seems that you already have a newer version of python3 installed.
Thus, apt is not able to install an older version without breaking it !
Did you installed python3 from a .deb file ? From another repo ?
try manually remove python3 and then reinstall it via apt .
Noka
Posts: 14
Joined: Thursday 14 December 2017 8:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Noka »

Sorry but I don't know how to remove manually python!

I didn't installed python from anywhere else :/
DAVIZINHO
Posts: 234
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Spain
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by DAVIZINHO »

Hello,
I use this plugin form y vaccum and works perfect!

i have a question, in the github you say that this plugin uses the python mirobo library.
This library support another devices like (XIAMOI IR).

Its posible to use this plugin, making other scripts to use anoder device like xiaomi IR?
mrinner
Posts: 56
Joined: Tuesday 22 August 2017 20:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Belarus
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by mrinner »

Hi,

You can use python-miio lib for IR and other devices which supported... Also you can modify this plugin for support IR.
I have an idea to do plugin which will support all devices which supports python-miio, but for this need to have all this devices for testing.
DAVIZINHO
Posts: 234
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Spain
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by DAVIZINHO »

mrinner wrote: Tuesday 26 December 2017 9:58 Hi,

You can use python-miio lib for IR and other devices which supported... Also you can modify this plugin for support IR.
I have an idea to do plugin which will support all devices which supports python-miio, but for this need to have all this devices for testing.
Thanks for reply!!

I try to install the python-miio lib but i cant run the "mirobo discover" that apears in the manual :-(
Im a noob, jejeje

It will be very usefull that the plugin works with all devices supports python-miio, a example is that i use scripts for the air purificator :-(
A plugin like this, very simple, will be very usefull!! :-(

thanks for your work!
TheCondor
Posts: 78
Joined: Thursday 18 June 2015 10:32
Target OS: Linux
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by TheCondor »

I'm encountering this strange error:

Code: Select all

2017-12-28 13:14:38.843 Error: (xiaomi-mi-robot-vacuum) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/xiaomi-mirobot/:/usr/local/lib/python35.zip:/usr/local/lib/python3.5/:/usr/local/lib/python3.5/plat-linux:/usr/local/lib/python3.5/lib-dynload'.
2017-12-28 13:14:38.844 Error: (Xiaomi Aspirapolvere) Module Import failed, exception: 'ImportError'
2017-12-28 13:14:38.844 Error: (Xiaomi Aspirapolvere) Module Import failed: ' Name: msgpack'
2017-12-28 13:14:38.844 Error: (Xiaomi Aspirapolvere) Error Line details not available.
but test.py run fine:

Code: Select all

(.env) pi@raspberrypi:~/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 {'battery': 100, 'clean_area': 31.0375, 'fan_level': 60, 'error': None, 'clean_seconds': 1787, 'cmd': 'status', 'state_code': 8}
and if I run python and "import msgpack" it's imported fine without errors... seems that the plugin itself try to load msgpack running another python version than what i have installed (3.5).
Any advice for debugging? Thanks in advance!
TheCondor
Posts: 78
Joined: Thursday 18 June 2015 10:32
Target OS: Linux
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by TheCondor »

reply myself:


fixed specifing the path of msgpack module before "import msgpack" in plugyin.py

Code: Select all

import Domoticz
[b]sys.path.append('/usr/local/lib/python3.5/site-packages')[/b]
import msgpack
whre the path is found using

Code: Select all

sudo find / -name msgpack*
Fx18
Posts: 2
Joined: Saturday 30 December 2017 21:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Fx18 »

Hi,

I tried to control my mi robot with this plugin. I search for myself and on the web but i don't find the solution.
So I try here.
I use a RPi with Debian Strech, and this next is my problem.
When I make a test with this command :sudo ./test.py
The result is :

Code: Select all

test: python modules path: ././.env/lib/python3.5/site-packages
test: trying connect to 127.0.0.1:22222
Traceback (most recent call last):
  File "./test.py", line 22, in <module>
    client = socket.create_connection((args.host, args.port))
  File "/usr/lib/python3.5/socket.py", line 712, in create_connection
    raise err
  File "/usr/lib/python3.5/socket.py", line 703, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
If i do a manual test : sudo ./miio_server.py 192.168.0.4 xxxxxxxxxxxxxxxxxxxxxxxxxx --host 127.0.0.1 --port 22222 (xxxx is not my real token of course)
The result is :

Code: Select all

Traceback (most recent call last):
  File "./miio_server.py", line 17, in <module>
    from miio import Vacuum, DeviceException
  File "././.env/lib/python3.5/site-packages/miio/__init__.py", line 2, in <module>
    from miio.protocol import Message, Utils
  File "././.env/lib/python3.5/site-packages/miio/protocol.py", line 9, in <module>
    from construct import (Struct, Bytes, Const, Int16ub, Int32ub, GreedyBytes,
  File "././.env/lib/python3.5/site-packages/construct/__init__.py", line 22, in <module>
    from construct.core import *
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 669, in exec_module
  File "<frozen importlib._bootstrap_external>", line 773, in get_code
  File "<frozen importlib._bootstrap_external>", line 484, in _compile_bytecode
EOFError: marshal data too short
Did you have an idea about my problem?

Thanks in advance
Fx18
Posts: 2
Joined: Saturday 30 December 2017 21:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Fx18 »

Hi,

I reply myself .

I had a problem with my miio-python library.
To fix it, I juste passed this command :
pip3 uninstall python-miio

and redo this one : pip3 install python-miio

and everything work fine now.

I hope so that information will be help someone.
frostwork
Posts: 5
Joined: Friday 14 November 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by frostwork »

hi,
there was(/is?) some problem with python-construct>2.8.16 so it might help to downgrade to 2.8.16.
(see https://github.com/rytilahti/python-miio/issues/145 )
and in case you missed it - the xiaomi vacuum was rooted at 34C3:
https://github.com/dgiese/dustcloud
have fun!
jorge
Posts: 2
Joined: Wednesday 11 October 2017 12:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by jorge »

Hi all,

I've installed the plugin for the Xiaomi vacuum with all the prerequisites (Python 3 etc) on my RaspberryPi (Domoticz V3.8153).
After adding the Xiaomi Mi Vacuum hardware I get the following error: “'exception': 'python-miio: [Errno 1] Operation not permitted'}”.

What I've tried so far?
- Added the correct IP adres of the robot and the Access token "xxxxxxxx435cea79a50effa75a050ab0bda5a8634a1ff78ea3e291da1dxxxxxxxxxxxxxxxxx"
- I can ping the Robot from the RaspberryPi
- Restart Domoticz
- Restart Miio Server
- Reinstalled with Pip (pip3 uninstall python-miio / pip3 install python-miio -> python_miio-0.3.3-py3-none-any.whl )
- ps aux|grep server.py / Killed active processes
- Disabled Xiaomi hardware in Domoticz

When I run the test script I get the error:

pi@gateway:~/domoticz/plugins/xiaomi-mirobot $ sudo ./test.py
test: python modules path: ././.env/lib/python3.4/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: [Errno 1] Operation not permitted'}

When I try to run the server directly from the console;
pi@gateway:~/domoticz/plugins/xiaomi-mirobot $ sudo ./miio_server.py ROBOT_IP TOKEN.............X --host 127.0.0.1 --port 22222
server: Starting server on 127.0.0.1 22222
server: connected ('127.0.0.1', 53214)
server: got socket msg: ['status']
server: vac result {'exception': 'python-miio: [Errno 1] Operation not permitted', 'cmd': 'status'}
server: send reply ('127.0.0.1', 53214)

Logs in Domoticz
2018-01-12 23:27:32.054 (Xiaomi_Robotstofzuiger) Calling message handler 'onHeartbeat'.
2018-01-12 23:27:32.054 (Xiaomi_Robotstofzuiger) Trying connect to MIIOServer 127.0.0.1:22222
2018-01-12 23:27:32.054 (Xiaomi_Robotstofzuiger) Transport set to: 'TCP/IP', 127.0.0.1:22222.
2018-01-12 23:27:32.055 PluginSystem: Starting I/O service thread.
2018-01-12 23:27:32.055 (Xiaomi_Robotstofzuiger) Connect directive received, action initiated successfully.
2018-01-12 23:27:32.105 (Xiaomi_Robotstofzuiger) Calling message handler 'onConnect'.
2018-01-12 23:27:32.105 (Xiaomi_Robotstofzuiger) MIIOServer connection status is [0] [Success]

Error
2018-01-12 23:28:17.042 (Xiaomi_Robotstofzuiger) Calling message handler 'onHeartbeat'.
2018-01-12 23:28:17.043 (Xiaomi_Robotstofzuiger) Sending 8 bytes of data:.
2018-01-12 23:28:17.043 (Xiaomi_Robotstofzuiger) 91 a6 73 74 61 74 75 73 .. .. .. .. .. .. .. .. .. .. .. .. ��status
2018-01-12 23:28:17.093 (Xiaomi_Robotstofzuiger) Received 70 bytes of data:.
2018-01-12 23:28:17.093 (Xiaomi_Robotstofzuiger) 82 a9 65 78 63 65 70 74 69 6f 6e d9 2e 70 79 74 68 6f 6e 2d ��exception�.python-
2018-01-12 23:28:17.093 (Xiaomi_Robotstofzuiger) 6d 69 69 6f 3a 20 5b 45 72 72 6e 6f 20 31 5d 20 4f 70 65 72 miio:.[Errno.1].Oper
2018-01-12 23:28:17.094 (Xiaomi_Robotstofzuiger) 61 74 69 6f 6e 20 6e 6f 74 20 70 65 72 6d 69 74 74 65 64 a3 ation.not.permitted
2018-01-12 23:28:17.094 (Xiaomi_Robotstofzuiger) 63 6d 64 a6 73 74 61 74 75 73 .. .. .. .. .. .. .. .. .. .. cmd�status
2018-01-12 23:28:17.094 (Xiaomi_Robotstofzuiger) Calling message handler 'onMessage'.
2018-01-12 23:28:17.094 (Xiaomi_Robotstofzuiger) Got: {'cmd': 'status', 'exception': 'python-miio: [Errno 1] Operation not permitted'}

Do you have an ideas how to solve this? Thanks!
AVBoX
Posts: 2
Joined: Saturday 05 August 2017 10:58
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by AVBoX »

Hello,

I followed the tutorial, everything works except that I can not find the plugin in domoticz:

pi@raspberrypi:~/domoticz/plugins/xiaomi-mirobot $ sudo ./test.py
test: python modules path: ././.env/lib/python3.4/site-packages
test: trying connect to 127.0.0.1:22222
test: sent request to server [status]
test: reading response...
test: got server reply {'state_code': 8, 'fan_level': 60, 'clean_area': 40.5125, 'battery': 100, 'error': None, 'clean_seconds': 2479, 'cmd': 'status'}


Image

Thanks,
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest