Python plugin: Xiaomi Mi Robot Vacuum Topic is solved

Python and python framework

Moderator: leecollings

Post Reply
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 »

Did you place the plugin in the correct folder? If you did it should appear under hardware in Domoticz.
The folder should be; /home/pi/domoticz/plugins/.

https://www.domoticz.com/wiki/Using_Python_plugins
domoticzag
Posts: 24
Joined: Tuesday 13 September 2016 19:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by domoticzag »

I think this is the same issue as mentioned in this topic:
http://www.domoticz.com/forum/viewtopic ... 65&t=21379

Btw I have one question,
is this plugin working for Xiaomi Robot Gen 2?
RPi 3
Domoticz Béta
RFLink Gateway dipool antenna
Many kaku devices
P1 smart meter
Custom made ESP8266 devices
Hue lights / Milight ligts and strips
Quax1507
Posts: 101
Joined: Tuesday 07 April 2015 21:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Quax1507 »

I just noticed that the utility sensors generated by the plugin are no longer updated with V3.8833.

I went back to V3.8825 and it is working again!

Ahy idea?
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 »

Quax1507 wrote: Saturday 20 January 2018 16:24 I just noticed that the utility sensors generated by the plugin are no longer updated with V3.8833.

I went back to V3.8825 and it is working again!

Ahy idea?
same for me. but i dont back to older beta.

Its problem of the plugin? or the beta?
RichardBokker
Posts: 39
Joined: Thursday 09 April 2015 20:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9317
Location: Netherlands
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by RichardBokker »

I hipe you guys can help me out.

I cannot finish the installation of this plugin.

i have problems with these 2, and cannot continu..

Code: Select all

sudo pip3 install -U setuptools
sudo pip3 install -U virtualenv
Its says:

Code: Select all

sudo: pip3: command not found
i have tried everything regarding to get other packages installed (setuptools, of vritualenv), but is still not found..
i'm running Rpi2, started with default image.
Quax1507
Posts: 101
Joined: Tuesday 07 April 2015 21:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Quax1507 »

Try: „apt-get install python3-pip“

or

apt-get install python3.5-pip“


Gesendet von iPhone mit Tapatalk
RichardBokker
Posts: 39
Joined: Thursday 09 April 2015 20:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9317
Location: Netherlands
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by RichardBokker »

Quax1507 wrote: Monday 22 January 2018 19:22 Try: „apt-get install python3-pip“

or

apt-get install python3.5-pip“
I tried that also.
Python3-pip is installed.
Python3.5-pip says:

Code: Select all

E: Unable to locate package python3.5-pip
E: Couldn't find any package by regex 'python3.5-pip'
Yes i did a: "sudo apt-get update" first.

edit:
i'm required to install the miio to. That is also not working.
Does not work:

Code: Select all

pip3 install python-miio
or

Code: Select all

pip install virtualenv
Last edited by RichardBokker on Monday 22 January 2018 19:47, edited 1 time in total.
Quax1507
Posts: 101
Joined: Tuesday 07 April 2015 21:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Quax1507 »

What's the output of:

"apt list --installed |fgrep -i python" ?
RichardBokker
Posts: 39
Joined: Thursday 09 April 2015 20:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9317
Location: Netherlands
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by RichardBokker »

Quax1507 wrote: Monday 22 January 2018 19:47 What's the output of:

"apt list --installed |fgrep -i python" ?
:x

Code: Select all

sudo: apt: command not found
Quax1507
Posts: 101
Joined: Tuesday 07 April 2015 21:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Quax1507 »

Strange! No idea...
Quax1507
Posts: 101
Joined: Tuesday 07 April 2015 21:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Quax1507 »

Hmmm?

Missing search path?

What about "/usr/bin/apt list --installed |fgrep -i python"
RichardBokker
Posts: 39
Joined: Thursday 09 April 2015 20:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9317
Location: Netherlands
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by RichardBokker »

unfortunally, that is not working too. :|
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 »

@RichardBokker

did you installed python3-pip with sudo? "sudo apt-get install python3-pip"
If yes, pip3 cmd should be available 100% :)
Then,
cd xiaomi-mirobot # plugin folder
virtualenv -p python3 .env # creating environment for python libs
source .env/bin/activate # activating environment, only after this step you need to install other relations:
pip3 install gevent msgpack-python python-miio==0.3.1

I'm on 3.8805 and all works. I'll try to update to the latest beta on dev machine next week.
Also seems dz have many issues with python subsytem on the latest beta...
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 want to make a dzvents that send me a notification for change main brush

i make this dzvents and not works :-(

local cepillo = domoticz.devices('Vacuum - Care Main Brush')

if (cepillo.sensorType < 10) then
cepillo_var.set(1)
domoticz.notify('AVISO','VACUUM CHANGE MAIN BRUSH', '', domoticz.PRIORITY_LOW)

end

I thint the .sensorType is not the correct parameter. can someone tell me the correct?
RichardBokker
Posts: 39
Joined: Thursday 09 April 2015 20:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9317
Location: Netherlands
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by RichardBokker »

mrinner wrote: Friday 26 January 2018 21:52 @RichardBokker

did you installed python3-pip with sudo? "sudo apt-get install python3-pip"
If yes, pip3 cmd should be available 100% :)
Then,
cd xiaomi-mirobot # plugin folder
virtualenv -p python3 .env # creating environment for python libs
source .env/bin/activate # activating environment, only after this step you need to install other relations:
pip3 install gevent msgpack-python python-miio==0.3.1

I'm on 3.8805 and all works. I'll try to update to the latest beta on dev machine next week.
Also seems dz have many issues with python subsytem on the latest beta...
Sorry, i read this just now.

I think my installation was corrupt. I made a new installation on a new Pi, and everything works perfect now.
RichardBokker
Posts: 39
Joined: Thursday 09 April 2015 20:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9317
Location: Netherlands
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by RichardBokker »

What command's do i use to control the robot?
I want to make script with LUA.

i think i should use:

Code: Select all

 otherdevices['Robot - Control'] = "".
But what entries? Home , Cleaning or On are not working.
Anysone some ideas?

I did managed to readout the status with:

Code: Select all

  if otherdevices['Robot - Status'] == "Cleaning" then
RichardBokker
Posts: 39
Joined: Thursday 09 April 2015 20:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9317
Location: Netherlands
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by RichardBokker »

RichardBokker wrote: Friday 09 February 2018 17:04 What command's do i use to control the robot?
I want to make script with LUA.

i think i should use:

Code: Select all

 commandarray['Robot - Control'] = "".
But what entries? Home , Cleaning or On are not working.
Anysone some ideas?

I did managed to readout the status with:

Code: Select all

  if otherdevices['Robot - Status'] == "Cleaning" then
Someone, please? :mrgreen:

edit:

found, it is: commandArray['Robot - Control''] = 'Set Level 10' (or 20, 30, 40, 50, 60)
arigato
Posts: 1
Joined: Sunday 11 February 2018 1:15
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by arigato »

RichardBokker wrote: Monday 12 February 2018 11:52
RichardBokker wrote: Friday 09 February 2018 17:04 What command's do i use to control the robot?
I want to make script with LUA.

i think i should use:

Code: Select all

 commandarray['Robot - Control'] = "".
But what entries? Home , Cleaning or On are not working.
Anysone some ideas?

I did managed to readout the status with:

Code: Select all

  if otherdevices['Robot - Status'] == "Cleaning" then
Someone, please? :mrgreen:

edit:

found, it is: commandArray['Robot - Control''] = 'Set Level 10' (or 20, 30, 40, 50, 60)
The code you pasted for your IF statement seems to only check if its either On or OFF. But not if its Cleaning, Paused, Sleeping, In Error, Charging, Back to home, etc.

After your tip on controlling the robot, I think I might have found the fix to override the Xiaomi Mi Robot Main Brush Blocked fault error and have it continue cleaning.

Here's the Lua script:

Code: Select all

commandArray = {}
if otherdevices_svalues['Robot - Status'] == "In Error" then
    print ("Resuming the Cleanup")
    commandArray['Robot - Control'] = 'Set Level 10'
else
    print(otherdevices_svalues['Robot - Status'])
end
return commandArray
RichardBokker
Posts: 39
Joined: Thursday 09 April 2015 20:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9317
Location: Netherlands
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by RichardBokker »

I got the script working, but had to convert the Robot - state with tostring().

Here is my case-construction that i'm using.

Code: Select all

-- Using TimeBetween script in main LUA script folder
package.path = package.path .. ';' .. '/home/pi/domoticz/scripts/lua/script_time_TimeBetween.lua'
local TimeBetween = require('timebetween')
time = os.date("*t")

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)

---- Variabele to use
-- StoffieState      (uservariable)
-- AtHome            (uservariable)
-- Stoffie - Control (device)
-- Stoffie - Status  (device)

local stoffie 			= 'Stoffie - Status'
--    print(otherdevices_svalues[stoffie] .. " dit is de actuele status")

-- Required to convert State to Stringvalue
StoffieStatus = tostring(otherdevices_svalues[stoffie]);

-- IDLE
if (uservariables['StoffieState'] == 'IDLE') then
    print ("Stoffie is idle");
   
    if timebetween("08:00","16:00") then   -- Run's only during day hours.
        if (uservariables['AtHome'] == 'NO') then -- Run's only when nobody is at home
        commandArray['SendNotification']='Stoffie is Starting'
        commandArray['Variable:StoffieState']='STARTING'
        
        -- Start Robot command, command send once.
        commandArray['Stoffie - Control'] = 'Set Level 10'
        end
    end
end

-- STARTING
if (uservariables['StoffieState'] == 'STARTING') then

    if StoffieStatus == 'Cleaning' then  -- If robot is cleaning, continu to next step
        commandArray['SendNotification']='Stoffie is Running'
        commandArray['Variable:StoffieState']='RUNNING'
    end
    
    if timebetween("16:00","08:00") then  -- is program hangs, to executed state
        commandArray['Variable:StoffieState']='EXECUTED'
    end

end

-- RUNNING
if (uservariables['StoffieState'] == 'RUNNING') then

    if StoffieStatus == 'Back to home' then  -- If robot is going back to home, continu to next step 
        commandArray['SendNotification']='Stoffie is Stopping'
        commandArray['Variable:StoffieState']='STOPPING'
    end
end

-- STOPPING
if (uservariables['StoffieState'] == 'STOPPING') then

    if StoffieStatus == 'Charging' then  -- if robot is Charging, continu to next step
        commandArray['SendNotification']='Stoffie is Executed'
        commandArray['Variable:StoffieState']='EXECUTED'
        
        -- Stop Robot command, command send once.
        commandArray['Stoffie - Control'] = 'Set Level 50'
    end
end

-- EXECUTED
if (uservariables['StoffieState'] == 'EXECUTED') then

    if timebetween("23:55","23:56") then   -- Runs only once a day. Reset at end of day.
        commandArray['SendNotification']='Stoffie going to Idle'
        commandArray['Variable:StoffieState']='IDLE'
    end
end

return commandArray
Falken
Posts: 6
Joined: Thursday 22 February 2018 21:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8934
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Falken »

EDIT:

I solved it!

The server had apparently crashed when I tried to start it erlier today, so when I ran my server tests now. It started for a moment to update the vaccums information.

When I tried to start the server the "right way" via: sudo service miio_server start and sudo chmod +x test.py, it all started working.


Puh!

(Original post below)



Hi!

I have installed the plugin, and got the hardware setup. But, my devices are all out of sync and does not really do anything.

Where should I begin my trouble shooting?

I have checked the robots ip and token-settings, they are correct.

EDIT:

I just noticed that the parameters of the switches updates when I run sudo ./miio_server.py 192.168.1.233 476e6b70343055483230644c53707a12 --host 127.0.0.1 --port 22222

The server, however starts on port 59238 and is giving correct data from the vaccum. The port it starts on seems do differ between the server starts.
What is causing this, and what should I do to remain a stable connection.

When the switches updates in the Domoticz interface, I am still unable to send any commands to the vaccum via the switches.

Thank you!
Attachments
Mirobot-Forum-2.JPG
Mirobot-Forum-2.JPG (48.07 KiB) Viewed 4661 times
Mirobot-Forum.JPG
Mirobot-Forum.JPG (41.28 KiB) Viewed 4661 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest