Giter Site home page Giter Site logo

rytilahti / python-miio Goto Github PK

View Code? Open in Web Editor NEW
3.5K 87.0 540.0 3.27 MB

Python library & console tool for controlling Xiaomi smart appliances

Home Page: https://python-miio.readthedocs.io

License: GNU General Public License v3.0

Python 100.00%
xiaomi python home-assistant miio home-automation smart-home miot miot-spec

python-miio's Introduction

python-miio

Chat PyPI version PyPI downloads Build Status Coverage Status Documentation status Black

This library (and its accompanying cli tool, miiocli) can be used to control devices using Xiaomi's miIO and MIoT protocols.

This is a voluntary, community-driven effort and is not affiliated with any of the companies whose devices are supported by this library. Issue reports and pull requests are welcome, see contributing!


The full documentation is available at python-miio.readthedocs.io.



Installation

The most recent release can be installed using pip:

pip install python-miio

Alternatively, you can install the latest development version from GitHub:

pip install git+https://github.com/rytilahti/python-miio.git

This project is currently ongoing a major refactoring effort. If you are interested in controlling modern (MIoT) devices, you want to use the git version until version 0.6.0 is released.

Getting started

The miiocli command allows controlling supported devices from the command line, given that you know their IP addresses and tokens.

The simplest way to acquire the tokens is by using the miiocli cloud command, which fetches them for you from your cloud account using micloud:

miiocli cloud
Username: [email protected]
Password:

== name of the device (Device offline ) ==
    Model: example.device.v1
    Token: b1946ac92492d2347c6235b4d2611184
    IP: 192.168.xx.xx (mac: ab:cd:ef:12:34:56)
    DID: 123456789
    Locale: cn

Alternatively, see the docs for other ways to obtain them.

After you have your token, you can start controlling the device. First, you can use info to get some generic information from any (even yet unsupported) device:

miiocli device --ip <ip> --token <token> info

Model: rockrobo.vacuum.v1
Hardware version: MW300
Firmware version: 1.2.4_16
Supported using: RoborockVacuum
Command: miiocli roborockvacuum --ip 127.0.0.1 --token 00000000000000000000000000000000
Supported by genericmiot: True

Note that the command field which gives you the direct command to use for controlling the device. If the device is supported by the genericmiot integration as stated in the output, you can also use miiocli genericmiot for controlling it.

You can always use --help to get more information about available commands, subcommands, and their options.

Controlling modern (MIoT) devices

Most modern (MIoT) devices are automatically supported by the genericmiot integration. Internally, it uses ("miot spec") files to find out about supported features, such as sensors, settings and actions.

This device model specific file will be downloaded (and cached locally) when you use the genericmiot integration for the first time.

All features of supported devices are available using the common commands status (to show the device state), set (to change the settings), actions to list available actions and call to execute actions.

Device status

Executing status will show the current device state, and also the accepted values for settings (marked with access RW):

miiocli genericmiot --ip 127.0.0.1 --token 00000000000000000000000000000000 status

Service Light (light)
        Switch Status (light:on, access: RW): False (<class 'bool'>, )
        Brightness (light:brightness, access: RW): 60 % (<class 'int'>, min: 1, max: 100, step: 1)
        Power Off Delay Time (light:off-delay-time, access: RW): 1:47:00 (<class 'int'>, min: 0, max: 120, step: 1)

Changing settings

To change a setting, you need to provide the name of the setting (e.g., light:brightness in the example above):

 miiocli genericmiot --ip 127.0.0.1 --token 00000000000000000000000000000000 set light:brightness 0

 [{'did': 'light:brightness', 'siid': 2, 'piid': 3, 'code': 0}]

Using actions

Most devices will also offer actions:

miiocli genericmiot --ip 127.0.0.1 --token 00000000000000000000000000000000 actions

Light (light)
        light:toggle            Toggle
        light:brightness-down   Brightness Down
        light:brightness-up     Brightness Up

These can be executed using the call command:

miiocli genericmiot --ip 127.0.0.1 --token 00000000000000000000000000000000 call light:toggle

{'code': 0, 'out': []}

Use miiocli genericmiot --help for more available commands.

Note, using this integration requires you to use the git version until version 0.6.0 is released.

Controlling older (miIO) devices

Older devices are mainly supported by their corresponding modules (e.g., roborockvacuum or fan). The info command will output the command to use, if the device is supported.

You can get the list of available commands for any given module by passing --help argument to it:

$ miiocli roborockvacuum --help

Usage: miiocli roborockvacuum [OPTIONS] COMMAND [ARGS]...

Options:
  --ip TEXT       [required]
  --token TEXT    [required]
  --id-file FILE
  --help          Show this message and exit.

Commands:
  add_timer                Add a timer.
  ..

Each command invocation will automatically try to detect the device model. In some situations (e.g., if the device has no cloud connectivity) this information may not be available, causing an error. Defining the model manually allows to skip the model detection:

miiocli roborockvacuum --model roborock.vacuum.s5 --ip <ip> --token <token> start

Troubleshooting

The miiocli tool has a --debug (-d) flag that can be used to enable debug logging. You can repeat this multiple times (e.g., -dd) to increase the verbosity of the output.

You can find some solutions for the most common problems can be found in Troubleshooting section.

If you have any questions, feel free to create an issue or start a discussion on GitHub. Alternatively, you can check our Matrix room.

API usage

All functionalities of this library are accessible through the miio module. While you can initialize individual integration classes manually, the simplest way to obtain a device instance is to use DeviceFactory:

from miio import DeviceFactory

dev = DeviceFactory.create("<ip address>", "<token>")
dev.status()

This will perform an info query to the device to detect the model, and construct the corresponding device class for you.

Introspecting supported features

You can introspect device classes using the following methods:

  • sensors() to obtain information about sensors.
  • settings() to obtain information about available settings that can be changed.
  • actions() to return information about available device actions.

Each of these return device descriptor objects, which contain the necessary metadata about the available features to allow constructing generic interfaces.

Note: some integrations may not have descriptors defined. Adding them is straightforward, so feel free to contribute!

Contributing

We welcome all sorts of contributions: from improvements or fixing bugs to improving the documentation. We have prepared a short guide for getting you started.

Simulators

If you are a developer working on a project that communicates using the miIO/MIoT protocol, or want to contribute to this project but do not have a specific device, you can use the simulators provided by this project. The miiocli tool ships with simple simulators for both miIO and MIoT that can be used to test your code.

Supported devices

While all MIoT devices are supported through the genericmiot integration, this library supports also the following devices:

  • Xiaomi Mi Robot Vacuum V1, S4, S4 MAX, S5, S5 MAX, S6 Pure, M1S, S7
  • Xiaomi Mi Home Air Conditioner Companion
  • Xiaomi Mi Smart Air Conditioner A (xiaomi.aircondition.mc1, mc2, mc4, mc5)
  • Xiaomi Mi Air Purifier 2, 3H, 3C, 4, Pro, Pro H, 4 Pro (zhimi.airpurifier.m2, mb3, mb4, mb5, v7, vb2, va2), 4 Lite
  • Xiaomi Mi Air (Purifier) Dog X3, X5, X7SM (airdog.airpurifier.x3, x5, x7sm)
  • Xiaomi Mi Air Humidifier
  • Smartmi Air Purifier
  • Xiaomi Aqara Camera
  • Xiaomi Aqara Gateway (basic implementation, alarm, lights)
  • Xiaomi Mijia 360 1080p
  • Xiaomi Mijia STYJ02YM (Viomi)
  • Xiaomi Mijia 1C STYTJ01ZHM (Dreame)
  • Dreame F9, D9, L10 Pro, Z10 Pro
  • Dreame Trouver Finder
  • Xiaomi Mi Home (Mijia) G1 Robot Vacuum Mop MJSTG1
  • Xiaomi Roidmi Eve
  • Xiaomi Mi Smart WiFi Socket
  • Xiaomi Chuangmi camera (chuangmi.camera.ipc009, ipc013, ipc019, 038a2)
  • Xiaomi Chuangmi Plug V1 (1 Socket, 1 USB Port)
  • Xiaomi Chuangmi Plug V3 (1 Socket, 2 USB Ports)
  • Xiaomi Smart Power Strip V1 and V2 (WiFi, 6 Ports)
  • Xiaomi Philips Eyecare Smart Lamp 2
  • Xiaomi Philips RW Read (philips.light.rwread)
  • Xiaomi Philips LED Ceiling Lamp
  • Xiaomi Philips LED Ball Lamp (philips.light.bulb)
  • Xiaomi Philips LED Ball Lamp White (philips.light.hbulb)
  • Xiaomi Philips Zhirui Smart LED Bulb E14 Candle Lamp
  • Xiaomi Philips Zhirui Bedroom Smart Lamp
  • Huayi Huizuo Lamps
  • Xiaomi Universal IR Remote Controller (Chuangmi IR)
  • Xiaomi Mi Smart Pedestal Fan V2, V3, SA1, ZA1, ZA3, ZA4, ZA5 1C, P5, P9, P10, P11, P15, P18, P33, P39, P45
  • Xiaomi Rosou SS4 Ventilator (leshow.fan.ss4)
  • Xiaomi Mi Air Humidifier V1, CA1, CA4, CB1, MJJSQ, JSQ, JSQ1, JSQ001
  • Xiaomi Mi Water Purifier (Basic support: Turn on & off)
  • Xiaomi Mi Water Purifier D1, C1 (Triple Setting)
  • Xiaomi PM2.5 Air Quality Monitor V1, B1, S1
  • Xiaomi Smart WiFi Speaker
  • Xiaomi Mi WiFi Repeater 2
  • Xiaomi Mi Smart Rice Cooker
  • Xiaomi Smartmi Fresh Air System VA2 (zhimi.airfresh.va2), VA4 (va4), T2017 (t2017), A1 (dmaker.airfresh.a1)
  • Yeelight lights (see also python-yeelight)
  • Xiaomi Mi Air Dehumidifier
  • Xiaomi Tinymu Smart Toilet Cover
  • Xiaomi 16 Relays Module
  • Xiaomi Xiao AI Smart Alarm Clock
  • Smartmi Radiant Heater Smart Version (ZA1 version)
  • Xiaomi Mi Smart Space Heater
  • Xiaomiyoupin Curtain Controller (Wi-Fi) (lumi.curtain.hagl05)
  • Xiaomi Dishwasher (viomi.dishwasher.m02)
  • Xiaomi Xiaomi Mi Smart Space Heater S (zhimi.heater.mc2)
  • Xiaomi Xiaomi Mi Smart Space Heater 1S (zhimi.heater.za2)
  • Yeelight Dual Control Module (yeelink.switch.sw1)
  • Scishare coffee maker (scishare.coffee.s1102)
  • Qingping Air Monitor Lite (cgllc.airm.cgdn1)
  • Xiaomi Walkingpad A1 (ksmb.walkingpad.v3)
  • Xiaomi Smart Pet Water Dispenser (mmgg.pet_waterer.s1, s4, wi11)
  • Xiaomi Mi Smart Humidifer S (jsqs, jsq5)
  • Xiaomi Mi Robot Vacuum Mop 2 (Pro+, Ultra)

Feel free to create a pull request to add support for new devices as well as additional features for already supported ones.

Projects using this library

If you are using this library for your project, feel free to open a PR to get it listed here!

Home Assistant (official)

Home Assistant uses this library to support several platforms out-of-the-box. This list is incomplete as the platforms (in parentheses) may also support other devices listed above.

Home Assistant (custom)

Other related projects

This is a list of other projects around the Xiaomi ecosystem that you can find interesting. Feel free to submit more related projects.

python-miio's People

Contributors

0x5e avatar 2pirko avatar arekbulski avatar arturdobo avatar bieniu avatar darckly avatar domibarton avatar fettlaus avatar insajd avatar jpbede avatar kirmas avatar kuduka avatar legacycode avatar martin-kokos avatar muellermartin avatar nijel avatar paranerd avatar phil9909 avatar pluehne avatar rytilahti avatar saxel avatar scp10011 avatar shred86 avatar slaks avatar st7105 avatar starkillerog avatar swiergot avatar syssi avatar titilambert avatar yawor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-miio's Issues

Xiaomi WiFi Speaker support

-> 192.168.2.44 data= {"id":2893,"method":"get_prop","params":["umi"]}
<- 192.168.2.103 data= {"result":["{ \"DeviceName\": \"Mi Internet Speaker\", \"channel_title\": \"音箱下载\", \"current_state\": \"PLAYING\", \"hardware_version\": \"S602\", \"play_mode\": \"REPEAT_ALL\", \"track_artist\": \"Kygo&M83\", \"track_duration\": \"00:04:58\", \"track_title\": \"Wait(Remix)\", \"transport_channel\": \"PLAYLIST\" }"],"id":2893}
-> 192.168.2.44 data= {"id":2894,"method":"get_prop","params":["rel_time"]}
<- 192.168.2.103 data= {"result":["00:04:00"],"id":2894}
-> 192.168.2.44 data= {"id":2895,"method":"power","params":[]}
<- 192.168.2.103 data= {"result":"ok","id":2895}
-> 192.168.2.44 data= {"id":2896,"method":"get_prop","params":["rel_time"]}
<- 192.168.2.103 data= {"result":["00:04:02"],"id":2896}
-> 192.168.2.44 data= {"id":2897,"method":"get_prop","params":["rel_time"]}
<- 192.168.2.103 data= {"result":["00:04:03"],"id":2897}
-> 192.168.2.44 data= {"id":2898,"method":"vol_up","params":[5]}
<- 192.168.2.103 data= {"result":"ok","id":2898}
-> 192.168.2.44 data= {"id":2899,"method":"vol_down","params":[5]}
<- 192.168.2.103 data= {"result":"ok","id":2899}
-> 192.168.2.44 data= {"id":2900,"method":"previous_track","params":[]}
<- 192.168.2.103 data= {"result":"ok","id":2900}
-> 192.168.2.44 data= {"id":2901,"method":"next_track","params":[]}
<- 192.168.2.103 data= {"result":"ok","id":2901}
-> 192.168.2.44 data= {"id":2902,"method":"get_prop","params":["rel_time"]}
<- 192.168.2.103 data= {"result":["00:00:00"],"id":2902}
-> 192.168.2.44 data= {"id":2903,"method":"get_prop","params":["umi"]}
<- 192.168.2.103 data= {"result":["{ \"DeviceName\": \"Mi Internet Speaker\", \"channel_title\": \"音箱下载\", \"current_state\": \"PLAYING\", \"hardware_version\": \"S602\", \"play_mode\": \"REPEAT_ALL\", \"track_artist\": \"Kygo&M83\", \"track_duration\": \"00:04:58\", \"track_title\": \"Wait(Remix)\", \"transport_channel\": \"PLAYLIST\" }"],"id":2903}
-> 192.168.2.44 data= {"id":2904,"method":"get_prop","params":["rel_time"]}
<- 192.168.2.103 data= {"result":["00:00:08"],"id":2904}
-> 192.168.2.44 data= {"id":2905,"method":"next_channel","params":[]}
<- 192.168.2.103 data= {"result":"ok","id":2905}
-> 192.168.2.44 data= {"id":2906,"method":"get_prop","params":["rel_time"]}
<- 192.168.2.103 data= {"result":["00:00:00"],"id":2906}

Capture of @octa22. Thanks!

cp. aholstenson/miio#41.

[Error] Timout when querying for status

Hi!

Thank you for this great plugin! Exactly what I was looking for!

I am having trouble using it with my vacuum. I discover my vacuum just fine:

INFO:mirobo.vacuum:  IP 192.168.8.1: 845 - token: b'764e4b5a716672343239374562753632'

But when trying to query the status, I get this error:

sudo mirobo --ip 192.168.0.130 --token 764e4b5a716672343239374562753632 -d status
INFO:mirobo.cli:Debug mode active
DEBUG:mirobo.vacuum:192.168.0.130:54321 >>: {'id': 1, 'method': 'get_status'}
ERROR:mirobo.vacuum:got error when receiving: timed out
Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/mirobo/cli.py", line 51, in status
    res = vac.status()
  File "/usr/local/lib/python3.6/site-packages/mirobo/vacuum.py", line 106, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/usr/local/lib/python3.6/site-packages/mirobo/vacuum.py", line 79, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

Steps I took:

  1. Reset vacuum (delete from app)
  2. use ´discover´ function
  3. connect the robot to my wifi using the Mi Home App
  4. Try to query for status using mirobo

PS: I already increased the timout 15s inside the vacuum.py

WARNING:root:could not open file'/etc/apt/sources.list'

After installing virtualenv, exit virtualenv, and then run mirobo discover,
An error has occurred:
WARNING:root:could not open file'/etc/apt/sources.list'
Please help solve!
Question 2: download a good python-mirobo-master.zip is not unpacked into the homeassistant folder? A detailed tutorial?
Thank you

Xiaomi vaccum control from Raspberry pi + iPad Mi app at the same time - token: b'ffffffffffffffffffffffffffffffff'

First of all, thanks for a great software!

So long I am trying to get my Xiaomi Mi Vaccum robot to work with mirobo on my Raspberry Pi 2 (Debian Jessie, Ethernet connection + USB Wi-Fi).

Initially, I connected my Xiaomy Mi Vacuum and three Air Purifiers to home Wi-Fi so I could control it via iPad Mi app. I can use mirobo then to discover all their tokens from command line:

-> # mirobo discover

INFO:mirobo.vacuum:Sending discovery to <broadcast> with timeout of 5s..
INFO:mirobo.vacuum:  IP 192.168.0.22: 833 - token: b'7eda8d580fa5c33dbb6168326f75efbd'
INFO:mirobo.vacuum:  IP 192.168.0.23: 830 - token: b'4e65fb7827d51cd2208f0acdf9af7b08'
INFO:mirobo.vacuum:  IP 192.168.0.24: 833 - token: b'79f795f4d8db427a1946f93e6c610fcb'
INFO:mirobo.vacuum:  IP 192.168.0.25: 847 - token: b'ffffffffffffffffffffffffffffffff'
INFO:mirobo.vacuum:Discovery done

So, I reset Mi Vacuum and get RPi connected to Vacuum Wi-Fi by wlan0 USB adapter. Only then I could define Vacuum token and have it controlled via command line:

-> # mirobo discover

INFO:mirobo.vacuum:Sending discovery to <broadcast> with timeout of 5s..
INFO:mirobo.vacuum:  IP 192.168.4.1: 847 - token: b'7a3779494c6d5679a475496f42646344'
INFO:mirobo.vacuum:Discovery done

> # export MIROBO_IP=192.168.4.1
> # export MIROBO_TOKEN=7a3779494c6d56793475496f42646344
> # mirobo

State: Charging
Battery: 100 %
Fanspeed: 60 %
Cleaning since: 0:00:02
Cleaned area: 0.0 m²
DND enabled: 0

But then, Vacuum looses connection to home Wi-Fi. And I can't control one from iPad at the same time.

...........
So I have two questions:

  1. Why Xiaomi Mi Vacuum can't be discovered in local network as well as Air Purifiers?

  2. Is it possible to control Xiaomi Mi Vacuum from Rpi command line and from iPad Mi app at the same time?

can't find my robot

i did by following step

  1. remove the robot from app, and reset the robot
  2. join the network through my laptop
  3. run discover
  4. i got time out, and no device is found, even i increase the timeout time to 20

thanks for the help

Get token from android App

Hello,

I think i understood that i can control my vaccum only from one device at a time (home assistant or my phone).
Plus, putting the raspebberry on the vaccum network is not ideal in my case (wired raspberry).
I was wondering if there was a way to steal the token from the android app (while setting it up) ?

That way i gain controll from phone + home assistant ?

Xiaomi-Philips Eyecare control fail

Got a token from android, trying to control, I'll be appreciate for any help, thanx!
Here's what I got:

$ mieye --ip=10.0.1.211 --token=4aaf6dd769bcb0a87dbe9aff278cc53a -d
INFO:mirobo.philips_eyecare_cli:Debug mode active
DEBUG:mirobo.philips_eyecare_cli:Connecting to 10.0.1.211 with token 4aaf6dd769bcb0a87dbe9aff278cc53a
DEBUG:mirobo.protocol:Unable to decrypt, returning raw bytes.
DEBUG:mirobo.device:Got a response: Container: 
    data = Container: 
        length = 0
        value =  (total 0)
        data =  (total 0)
        offset2 = 32
        offset1 = 32
    header = Container: 
        length = 16
        value = Container: 
            length = 32
            unknown = 0
            devtype = 760
            serial = 2211
            ts = 1970-01-01 00:06:43
        data = !1\x00 \x00\x00\x00\x00\x02\xf8\x08\xa3\x00\x00\x01\x93 (total 16)
        offset2 = 16
        offset1 = 0
    checksum = \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 (total 16)
DEBUG:mirobo.device:Discovered 760 2211 with ts: 1970-01-01 00:06:43, token: b'00000000000000000000000000000000'
DEBUG:mirobo.device:10.0.1.211:54321 >>: {'id': 2, 'method': 'get_prop', 'params': ['power', 'bright', 'notifystatus', 'ambstatus', 'ambvalue', 'eyecare', 'scene_num', 'bls', 'dvalue']}
DEBUG:mirobo.protocol:Unable to decrypt, returning raw bytes.
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 2706, in _parse
    return self.subcon._parse(stream, context, path)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 1550, in _parse
    obj = self.cases.get(key, self.default)._parse(stream, context, path)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 2264, in _parse
    hash2 if not isinstance(hash2,bytes) else hexlify(hash2), ))
construct.core.ChecksumError: wrong checksum, read b'ffffffffffffffffffffffffffffffff', computed b'08c44fdf612e6748f7bd83d008b21da8'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/mieye", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/mirobo/philips_eyecare_cli.py", line 82, in cli
    ctx.invoke(status)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/mirobo/philips_eyecare_cli.py", line 95, in status
    res = dev.status()
  File "/usr/local/lib/python3.4/dist-packages/mirobo/philips_eyecare.py", line 71, in status
    properties
  File "/usr/local/lib/python3.4/dist-packages/mirobo/device.py", line 156, in send
    m = Message.parse(data, ctx)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 165, in parse
    return self.parse_stream(BytesIO(data), context, **kw)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 178, in parse_stream
    return self._parse(stream, context2, "(parsing)")
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 848, in _parse
    subobj = sc._parse(stream, context, path)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 2710, in _parse
    raise e.__class__("%s\n    %s" % (e, path))
construct.core.ChecksumError: wrong checksum, read b'ffffffffffffffffffffffffffffffff', computed b'08c44fdf612e6748f7bd83d008b21da8'
    (parsing) -> checksum

Feature request: show cleaning map

Thanks for your excellent job!

Sometimes I have to use the mihome app, check the map to know the cleaning status.So if possible you can provide the cleaning map( or the waypoints to help me to build the map).

Send multiple params broken result

Send multiple params to water purifier like raw_command get_prop '["press","mode"]', the result always broken like [300, 'error'], only first one is right, no matter how much params sent.

https://github.com/aholstenson/miio/ cli works well.

Capture shows very different behavior with mirobo, below is a single command --method get_prop --params '["press","temperature"]' :

 ->  10.0.1.9 data= {"id":1,"method":"miIO.info","params":[]}
 <-  10.0.1.8 data= {"result":{"life":30300,"token":"a3d7f9****683","mac":"28***:03","fw_ver":"1.2.8","hw_ver":"ESP8266","model":"yunmi.waterpuri.v2","mcu_fw_ver":"0019","wifi_fw_ver":"1.4.0(30e0bd0)","ap":{"rssi":-58,"ssid":"Deep Space Voyager","bssid":"00***:A1"},"netif":{"localIp":"10.0.1.8","mask":"255.255.0.0","gw":"10.0.0.15"},"mmfree":10256},"id":1}
 ->  10.0.1.9 data= N/A
 <-  10.0.1.8 data= N/A
 ->  10.0.1.9 data= {"id":1,"method":"get_prop","params":["press","temperature"]}
 <-  10.0.1.8 data= {"result":{"life":30300,"token":"a3d7f9****683","mac":"28***:03","fw_ver":"1.2.8","hw_ver":"ESP8266","model":"yunmi.waterpuri.v2","mcu_fw_ver":"0019","wifi_fw_ver":"1.4.0(30e0bd0)","ap":{"rssi":-58,"ssid":"Deep Space Voyager","bssid":"00***:A1"},"netif":{"localIp":"10.0.1.8","mask":"255.255.0.0","gw":"10.0.0.15"},"mmfree":10256},"id":1}
 ->  10.0.1.9 data= {"id":1,"method":"get_prop","params":["press","temperature"]}
 <-  10.0.1.8 data= {"result":[300,29],"id":1}

any idea?

Bug when having multiple network interfaces (discovery)

i feel kinda dumb but i'm not succeding to make it work...

(homeassistant) homeassistant@hassbian:~/.homeassistant/config $ mirobo discover
INFO:mirobo.vacuum:Sending discovery to <broadcast> with timeout of 5s..
INFO:mirobo.vacuum:Discovery done

Maybe i found a bug ?
My raspberry is wired, and i connect to it via SSH via cable.
If i a laptop on the robot's wifi and start a "mirobo discover" from the raspberry, i see no broadcast UDP packet. With the same laptop connected on my wired network i see the broadcasts. (of course my robot doesnt see the requests and doesnt give out the token)

My guess is that the discovery packet isnt using my wlan0 connection. maybe adding a interface parameter would be good ?

I think i've finally got the token (via : #5 (comment)) but when i try to use it i get :

mirobo --ip 10.11.0.78 --token 4D61447643524D63
ERROR:mirobo.vacuum:got error when receiving: timed out
Traceback (most recent call last):
  File "/srv/homeassistant/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/srv/homeassistant/lib/python3.4/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/srv/homeassistant/lib/python3.4/site-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/srv/homeassistant/lib/python3.4/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/srv/homeassistant/lib/python3.4/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/mirobo/cli.py", line 46, in cli
    ctx.invoke(status)
  File "/srv/homeassistant/lib/python3.4/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/mirobo/cli.py", line 59, in status
    res = vac.status()
  File "/srv/homeassistant/lib/python3.4/site-packages/mirobo/vacuum.py", line 150, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/srv/homeassistant/lib/python3.4/site-packages/mirobo/vacuum.py", line 121, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

But if i use the ip of my laptop (on my home wifi, same as the one now used by the robot), i can see the packets sent by mirobot command line...

here is how i got the token :
rg_mfdo1xe_h9k5uibqenwsfjwcx44sgimqp4ieo2zpt_klo4qg7atj7bcc1neziilpq8wrkdu8vzbwcjjjypj3ye3_xqpt50sxz3g3_h3pxem5_flizzqtgterzkv1bbtgr9rbsn4r0xd6jtzsrxa69r-uru3pnnnoozzk6qztzys2i0c2srybvytxllpcyw_7dscwmyuvtfiznuq2r

or do i miss something ?

Missing states and error_codes

Hi,
your states and error_codes are incomplete.
Here are some state additions (Merge with Fhem-stats):

1: 'Starting up',
2: 'Sleeping',
3: 'Waiting',
4: 'Remote control',
5: 'Cleaning',
6: 'Returning home',
7: 'Manual mode',
8: 'Charging',
9: 'Charging problem',
10: 'Paused',
11: 'Spot cleaning',
12: 'Error',
13: 'Shutting down',
14: 'Updating',
15: 'Docking',

With new firmware the error_codes-count > 19 (~24)
Please have a look: http://www.robotreviews.com/chat/viewtopic.php?f=6&t=19479&start=60#p140165

Translation 1-19 from Fhem:

'1' => "Laser sensor fault",
'2' => "Collision sensor fault",
'3' => "Wheel floating",
'4' => "Cliff sensor fault",
'5' => "Main brush blocked",
'6' => "Side brush blocked",
'7' => "Wheel blocked",
'8' => "Device stuck",
'9' => "Dust bin missing",
'10' => "Filter blocked",
'11' => "Magnetic field detected",
'12' => "Low battery",
'13' => "Charging problem",
'14' => "Battery failure",
'15' => "Wall sensor fault",
'16' => "Uneven surface",
'17' => "Side brush failure",
'18' => "Suction fan failure",
'19' => "Unpowered charging station",

(Some are more clearly described)


Thx for your cool script! I use it along with alexa + ha-bridge and kivy on a pi display.

Hello Thank you !

Hello
Thank you for your sharing! Can you create again Xiaomi, WiFi, plug, Xiaomi, table, lamp? I've already found their token!

xiaomi vaccum cleaner not responding

Hi,

I am using your mirobo library to start and stop my xiaomi mija vacuum cleaner. It works great, except the case when the vacuum is not being called for longer period of time (day/two).

Then when I try to start the cleaner using your library I get following errors.
If I try about 3 times in a row, it start to work again, and works fine.
It looks like the vacuum goes to sleep maybe ?

Executing command: sudo mirobo --ip 192.168.1.25 --token 33795a47547535596d6a526e3563434c start
Response from command execution: 1
ERROR:mirobo.device:Unable to discover a device at address 192.168.1.25
Traceback (most recent call last):
File "/usr/local/bin/mirobo", line 11, in
sys.exit(cli())
File "/usr/lib/python3/dist-packages/click/core.py", line 716, in call
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/mirobo/vacuum_cli.py", line 152, in start
click.echo("Starting cleaning: %s" % vac.start())
File "/usr/local/lib/python3.5/dist-packages/mirobo/vacuum.py", line 27, in start
return self.send("app_start")
File "/usr/local/lib/python3.5/dist-packages/mirobo/device.py", line 121, in send
self.do_discover()
File "/usr/local/lib/python3.5/dist-packages/mirobo/device.py", line 73, in do_discover
raise DeviceException("Unable to discover the device %s" % self.ip)
mirobo.device.DeviceException: Unable to discover the device 192.168.1.25

Error: Invalid value for "--id-file"

After installing mirobo, I get the following error while trying to use it:

mirobo status     
Usage: mirobo [OPTIONS] COMMAND [ARGS]...

Error: Invalid value for "--id-file": Could not open file: /tmp/python-mirobo.seq: No such file or directory

Any idea whats the issue here?

Only one command working

When i sent a command it works perfect
When sending the second command i receive a timeout error
Appr one Minute later i can sent next command

some concern about the new version

Hi,

just saw the new version, why we try to get the device id and serial no every time? is it because it will change? i thought config it will be nice. reduce the network traffic

Xiaomi Mi Robot Vacuum 2nd support

Actually it is not an issue, but I think it is pleasant to let you know that miIO works on the latest Mi Robot Vacuum 2nd, which is out in China mainland. This model adds mopping function but the protocol stays the same now, that's why original miIO vacuum part still works on it. And thanks for your work.

CLI tool demands an IP address always

It looks like I'm unable to work appropriate with the cli tool. ;-)

$ ./mirobo discover
Usage: mirobo [OPTIONS] COMMAND [ARGS]...

Error: Invalid value for "--ip": Invalid IP: None does not appear to be an IPv4 or IPv6 address

$ ./mirobo --ip 192.168.13.1 discover
Traceback (most recent call last):
  File "./mirobo", line 11, in <module>
    load_entry_point('python-mirobo==0.1.2', 'console_scripts', 'mirobo')()
  File "/home/sebastian/.local/lib/python3.5/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/sebastian/.local/lib/python3.5/site-packages/click/core.py", line 696, in main
    with self.make_context(prog_name, args, **extra) as ctx:
  File "/home/sebastian/.local/lib/python3.5/site-packages/click/core.py", line 621, in make_context
    self.parse_args(ctx, args)
  File "/home/sebastian/.local/lib/python3.5/site-packages/click/core.py", line 1018, in parse_args
    rest = Command.parse_args(self, ctx, args)
  File "/home/sebastian/.local/lib/python3.5/site-packages/click/core.py", line 880, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "/home/sebastian/.local/lib/python3.5/site-packages/click/core.py", line 1404, in handle_parse_result
    self.callback, ctx, self, value)
  File "/home/sebastian/.local/lib/python3.5/site-packages/click/core.py", line 78, in invoke_param_callback
    return callback(ctx, param, value)
  File "/home/sebastian/.local/lib/python3.5/site-packages/mirobo/vacuum_cli.py", line 32, in validate_token
    token_len = len(value)
TypeError: object of type 'NoneType' has no len()

Do I miss something? The behaviour is the same for version 0.1.2 and the current master. Thanks in advance!

Not working with newest firmware version 3.3.9_003073

Using this great code till today, after Xiaomi had to change the way of communication.
Getting the following result when just trying to get info data from vacuum:

ERROR:mirobo.vacuum:got error when receiving: timed out
Traceback (most recent call last):
File "/usr/local/bin/mirobo", line 11, in
sys.exit(cli())
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1043, in invoke
return Command.invoke(self, ctx)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/mirobo/cli.py", line 46, in cli
ctx.invoke(status)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/mirobo/cli.py", line 59, in status
res = vac.status()
File "/usr/local/lib/python3.4/dist-packages/mirobo/vacuum.py", line 150, in status
return VacuumStatus(self.send("get_status")[0])
File "/usr/local/lib/python3.4/dist-packages/mirobo/vacuum.py", line 121, in send
data, addr = s.recvfrom(1024)
socket.timeout: timed out

Provide asyncio-based API

It would be nice to have an asyncio-based API on top of the current one for those who prefer avoiding blocking. An open question here would be whether python <3.5 should still be supported after adding this, as async def is first available in 3.5 (which is already in debian stable, so it should be a safe target in my opinion).

mirobo "DND enabled: 0", after change to 1

I try to set DND mode, when query status, it still shows DND 0:

-> # mirobo dnd on 20 0 8 0
Enabling DND 20:0 to 8:0
0
-> # mirobo dnd 1          
DND 21:00 to 08:00 (enabled: 1)
-> # mirobo                
State: Charging
Battery: 100 %
Fanspeed: 60 %
Cleaning since: 0:00:02
Cleaned area: 0.0 m²
DND enabled: 0

Calling message handler 'onHeartbeat'.

Hye,
Don't know what title to give to this issue threzad so I just copy/paste the error message.

Python is intalled, token is found, but it's not working, find below the log from domoticz:

2017-09-25 09:48:08.357 (nono) Poll: {"exception": ""} 2017-09-25 09:48:08.357 Error: (nono) Response mirobo-wrapper exception: 2017-09-25 09:48:08.358 PluginSystem: Starting I/O service thread. 2017-09-25 09:48:08.359 (nono) Calling message handler 'onHeartbeat'. 2017-09-25 09:48:30.964 (nono) Poll: {"exception": ""}

My xiaomi robot is workinf fine through the mi home app and is called "nono".

Thanks for your help

xiaomi vacuum, manual moving mode: duration definition incorrect

Hi!
first off: thanks a lot for providing us this communication platform!

I found during my usage on cli and by my trials to implement movement-path-scripts into home-assistant that the definition of the duration at running the method a second time are incorrect.

specific example for testing in python interpreter

m=mirobo.Vacuum(ip,token)

params1 = {"omega": -0.8 , "velocity": 0.29 , "seqnum": 1 , "duration": 5000 }
params2 = {"omega": -0.8 , "velocity": 0.29 , "seqnum": 2 , "duration": 1000 }
params3 = {"omega": -0.8 , "velocity": 0.29 , "seqnum": 3 , "duration": 1000 }
params4 = {"omega": -0.8 , "velocity": 0.29 , "seqnum": 4 , "duration": 1000 }
params5 = {"omega": -0.8 , "velocity": 0.29 , "seqnum": 5 , "duration": 1000 }

m.raw_command('app_rc_start', 0)
m.raw_command('app_rc_move', [params1])
m.raw_command('app_rc_move', [params2])
...

Result: the robot will only move for 5 seconds for the first method call.
However, the second movement (and all after that) will be also for 5 seconds and not just 1s as given by the current method call.

Please fix that. Thanks!

WIFI Switch for HA

Not really an issue, but apparently the wifi switch operates exactly like the vacuum. Do you have any idea how to get this working. When i run this on HA (with all the dependencies), i get the token back with mirobo discover. However, the HA component times out.
My HA config is as below

switch:
   - platform: mirobo
     name: 'Xiaomi Socket'
     host: host
     token:  'token'

Any ideas, help is appreciated.

Thanks

Allow sending discovery packets to static IP address

Hi there!

I reset the WIFI pressing the home and power buttons, after that I pressed the reset, but in both cases I'm getting the same message:

mirobo discover
INFO:mirobo.vacuum:Sending discovery packet to with timeout of 5s..
INFO:mirobo.vacuum:Discovery done

I'm using a Windows 10 machine with python 3.6.1 , I scanned with nmap the vacuum IP (192.168.8.1) and it seems the only ports open are 22 and 53... Am I missing something?

Thanx for creating this script and integrating with HA!

Working with water purifier

hello, it's working with miio command like: miio --control 10.0.1.8 --token a3d7f95***3 --method get_prop , has working data output, but using mirobo --ip 10.0.1.8 --token a3d7f95***3 -d info failed with error:

INFO:mirobo.vacuum_cli:Debug mode active
ERROR:mirobo.vacuum_cli:Unable to read the stored msgid: [Errno 2] No such file or directory: '/tmp/python-mirobo.seq'
DEBUG:mirobo.vacuum_cli:Connecting to 10.0.1.8 with token a3d7f95***3
ERROR:mirobo.device:Unable to discover a device at address 10.0.1.8
Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/mirobo/vacuum_cli.py", line 339, in info
    res = vac.info()
  File "/usr/local/lib/python3.5/dist-packages/mirobo/device.py", line 183, in info
    return DeviceInfo(self.send("miIO.info", []))
  File "/usr/local/lib/python3.5/dist-packages/mirobo/device.py", line 120, in send
    self.do_discover()
  File "/usr/local/lib/python3.5/dist-packages/mirobo/device.py", line 72, in do_discover
    raise DeviceException("Unable to discover the device %s" % self.ip)
mirobo.device.DeviceException: Unable to discover the device 10.0.1.8

Any idea to get water purifier working? Thanks.

Moving from custom_components to HA version not working

Hello!

I've been using it for months now, as you know! However I've now moved to the official HA version and it seems to not work anymore. AFAIK It shouldn't have changed the token as I haven't repaired or changed anything on the Mi Home app and the robot.

I've deleted the .py file from custom_components and also the pycaches folders just in case.

I'm getting this error:

[31m2017-07-17 11:29:01 ERROR (SyncWorker_122) [mirobo.device] got error when receiving: timed out�[0m

�[31m2017-07-17 11:29:01 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.limpiador fails�[0m

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/mirobo/device.py", line 129, in send
data, addr = s.recvfrom(1024)
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/src/app/homeassistant/helpers/entity.py", line 225, in async_update_ha_state
yield from self.hass.async_add_job(self.update)
File "/usr/local/lib/python3.6/asyncio/futures.py", line 331, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 244, in _wakeup
future.result()
File "/usr/local/lib/python3.6/asyncio/futures.py", line 244, in result
raise self._exception
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/app/homeassistant/components/switch/xiaomi_vacuum.py", line 112, in update
state = self.vacuum.status()
File "/usr/local/lib/python3.6/site-packages/mirobo/vacuum.py", line 87, in status
return VacuumStatus(self.send("get_status")[0])
File "/usr/local/lib/python3.6/site-packages/mirobo/device.py", line 143, in send
raise DeviceException from ex
mirobo.device.DeviceException�[0m

This is my current config:

switch:
  - platform: xiaomi_vacuum
    name: 'limpiador'
    host: 10.0.1.15
    token: XXX

IP also hasn't changed, so I'm not sure what's going on here!

Also my robot is perfectly connected to the Wifi and I can control it without problems with the Mi Home app!

Command "map" and "raw_command" - what do they do?

What do these command do? I hoped this return a JPEG of cleaning map, like iPad Mi app does, but it s not:

-> # mirobo map

['retry']

Any detailed information about how to use this command:

-> # mirobo raw_command

Usage: mirobo raw_command [OPTIONS] CMD [PARAMETERS]

Error: Missing argument "cmd".

No module named 'typing'

pi@raspberrypi:~ $ mirobo discover
Traceback (most recent call last):
File "/usr/local/bin/mirobo", line 7, in
from mirobo.cli import cli
File "/usr/local/lib/python3.4/dist-packages/mirobo/init.py", line 2, in
from mirobo.protocol import Message, Utils
File "/usr/local/lib/python3.4/dist-packages/mirobo/protocol.py", line 6, in
from typing import Any, Dict, Tuple
ImportError: No module named 'typing'

pi@raspberrypi:~ $ python3 --version
Python 3.4.2

Some element about Xiaomi Philips Bulb

Thx to add support for this.

I test all fonction present for ceiling.

Some of them doesn't work, because this option aren't present on the app and on the device it self :

  • acct_on/acct_off doesn't work
  • sml_on / sml_off doesn't work

status return an error :

nico@debianpcnico:~$ miceil --ip 192.168.0.208 --token 324b4147dc6c1a9867f6e19ec9070ca0 status
Power: on
Brightness: 10
CCT: 1
Scene Number: 4
dv: 0
Traceback (most recent call last):
  File "/usr/local/bin/miceil", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/mirobo/ceil_cli.py", line 104, in status
    click.echo("Smart Midnight Light: %s" % res.bl)
  File "/usr/local/lib/python3.4/dist-packages/mirobo/ceil.py", line 40, in bl
    return self.data["bl"]
KeyError: 'bl'

Hopping this can help !to provied a "mibulb" section

Philips Bulb and ceiling how to get token ?

Hi there fantastic works, only have a philips xiaomi bulb for now, Just wonder how to find token ?

mirobo discover doesn't result any thing execpt my 3 yeelight and my gateway

miceil discover need --ip 192.168.0.208 --token false token to show something

As this bulb looks to have same fonction as the ceiling, just want to test, can you help ?

Thanks

Xiaomi Vacuum resume cleaning session from dock capability?

Hey rytilahti! Currently using the Xiaomi vacuum with Home Assistant. I have used every supported command I can find (even the raw commands), and I can't get the vacuum to dock and resume, you can dock and start a new session and you can pause and resume, but no pause, dock, resume.

BUT! If the vacuum runs low on battery while cleaning and goes back to the dock itself to recharge you can send the same start_pause command to it that normally starts it from the dock, and it will actually resume!

It's as if when the vacuum runs low on battery it enters a perpetually paused state and returns to the dock. Seems like a hidden command or feature to me. Either way it's not something I've been able to replicate without the vacuums automated low battery process occurring. Think you can discover this?

Xiaomi Robot new Device ID

Hi,
I'm trying to connect to my new vacuum cleaner that I received yesterday, but so far no luck with that.
It seems that my device has some strange device ID. Xiaomi Mi Robot Vacuum should have 0x02f2 (754), but I'm getting 984 (0x03D8).

INFO:mirobo.device:Sending discovery to <broadcast> with timeout of 5s..
INFO:mirobo.device: IP 192.168.8.1: 984 - token: b'51344c5942785736757a3133766a7836'

Firmware version of my device is: 3.3.9_003077.

When I try to connect it always ends up with timeout:

INFO:mirobo.cli:Debug mode active
ERROR:mirobo.cli:Unable to read the stored msgid: [Errno 2] No such file or directory: '/tmp/python-mirobo.seq'
DEBUG:mirobo.cli:Connecting to 192.168.3.100 with token 51344c5942785736757a3133766a7836
DEBUG:mirobo.protocol:Unable to decrypt, returning raw bytes.
DEBUG:mirobo.device:Discovered 984 18672 with ts: 2017-07-13 21:15:10
DEBUG:mirobo.device:192.168.3.100:54321 >>: {'id': 1, 'method': 'get_status'}
ERROR:mirobo.device:got error when receiving: timed out
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/mirobo/device.py", line 129, in send
data, addr = s.recvfrom(1024)
socket.timeout: timed out

Is it possible to add support for this device ID? I'm able to record communication between Robot and Xiaomi app.

Column ZToken of the iOS app contains a 96 character token

The ZToken column of the iOS app is encrypted now. The token cannot be used anymore by copy&paste because it has 96 characters now. The encryption is AES-ECB with an empty key. It can be deciphered by:

from Crypto.Cipher import AES
import binascii
keystring = '00000000000000000000000000000000'
iostoken = '16a935db276e19b1c7bef0739f2deb7d3aca43c5e26a3c6445351cb2fb8495ea0143db63ee66b0cdff9f69917680151e'
key = bytes.fromhex(keystring)
cipher = AES.new(key, AES.MODE_ECB)
token = cipher.decrypt(bytes.fromhex(iostoken[:64]))
print(token)
# Output: b'4a447a41467058496746505541597033'

The support for encrypted tokens could be implemented now.

https://community.home-assistant.io/t/beta-xiaomi-gateway-integration/8213/3052
https://community.home-assistant.io/t/issue-config-xiaomi-vacuum-by-v0-51-1/24304/12
https://community.home-assistant.io/t/xiaomi-philips-light-token-problem/26701

How do I find more features?

Mi vacuum sweeper APP, there are many practical functions, how to develop it? For example, what code is used to test, send, and receive to get a valid function?. I can test it! But I don't know what code to send!

AirPurifier: set_favorite_level not working

Hi there,

thanks a lot for the great code! My Air Purifier works very well, except for setting the favorite level.
I get:

>>> import miio as mi
>>> x=mi.AirPurifier()
[... setting token and ID ]
>>> x.set_mode(OperationMode.Auto)
['ok']
>>> x.raw_command('set_favorite_level', 5)
{'error': {'message': 'Method not found.', 'code': -10000}, 'id': 148}

Same for the raw command:

>>> x.raw_command('set_favorite_level', 10)
{'error': {'message': 'Method not found.', 'code': -10000}, 'id': 149}

I'm using version 0.3.0 on my raspberry pi.

Can someone help, please?

error on execute mirobo discover

Hi,

I have this error:
Error: Invalid value for "--id-file": Could not open file: /tmp/python-mirobo.seq: No such file or directory

Can you help me ?

Error in new mirobo/protocol.py

Hello rytilahti,
the new protocol.py caused an error:

File "/mirobo/protocol.py", line 42, in verify_token
raise ValueError("Token must be of length 32")
ValueError: Token must be of length 32

This is the code block:

    @staticmethod
    def verify_token(token: bytes):
        if not isinstance(token, bytes):
            raise TypeError("Token must be bytes")
        if len(token) != 32:
            raise ValueError("Token must be of length 32")

I think

if len(token) != 32:

must be

if len(token) != 16:

because of "bytes".


Short question:
Why is
# click.echo("DND enabled: %s" % res.dnd)
# click.echo("Map present: %s" % res.map)
# click.echo("in_cleaning: %s" % res.in_cleaning)
comment out in vacuum_cli.py?


Greetings

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.