• Stars
    star
    489
  • Rank 89,990 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

XiaoMi Cloud Service for mi.com

MiService

XiaoMi Cloud Service for mi.com

Install

pip3 install miservice

Library

MiService:XiaoMi Cloud Service
  |
  |-- MiAccount:Account Srvice
  |-- MiBaseService:(TODO if needed)
  |     |
  |     |-- MiIOService:MiIO Service (sid=xiaomiio)
  |     |     |
  |     |     |-- MIoT_xxx:MIoT Service, Based on MiIO
  |     |
  |     |-- MiNAService:MiAI Service (sid=micoapi)
  |     |
  |     |-- MiAPIService:(TODO)
  |-- MiIOCommand:MiIO Command Style Interface

Command Line

Usage: The following variables must be set:
           export MI_USER=<Username>
           export MI_PASS=<Password>
           export MI_DID=<Device ID|Name>

Get Props: /usr/local/bin/micli.py <siid[-piid]>[,...]
           /usr/local/bin/micli.py 1,1-2,1-3,1-4,2-1,2-2,3
Set Props: /usr/local/bin/micli.py <siid[-piid]=[#]value>[,...]
           /usr/local/bin/micli.py 2=#60,2-2=#false,3=test
Do Action: /usr/local/bin/micli.py <siid[-piid]> <arg1|#NA> [...] 
           /usr/local/bin/micli.py 2 #NA
           /usr/local/bin/micli.py 5 Hello
           /usr/local/bin/micli.py 5-4 Hello #1

Call MIoT: /usr/local/bin/micli.py <cmd=prop/get|/prop/set|action> <params>
           /usr/local/bin/micli.py action '{"did":"267090026","siid":5,"aiid":1,"in":["Hello"]}'

Call MiIO: /usr/local/bin/micli.py /<uri> <data>
           /usr/local/bin/micli.py /home/device_list '{"getVirtualModel":false,"getHuamiDevices":1}'

Devs List: /usr/local/bin/micli.py list [name=full|name_keyword] [getVirtualModel=false|true] [getHuamiDevices=0|1]
           /usr/local/bin/micli.py list Light true 0

MIoT Spec: /usr/local/bin/micli.py spec [model_keyword|type_urn] [format=text|python|json]
           /usr/local/bin/micli.py spec
           /usr/local/bin/micli.py spec speaker
           /usr/local/bin/micli.py spec xiaomi.wifispeaker.lx04
           /usr/local/bin/micli.py spec urn:miot-spec-v2:device:speaker:0000A015:xiaomi-lx04:1

MIoT Decode: /usr/local/bin/micli.py decode <ssecurity> <nonce> <data> [gzip]

套路,例子:

请在 Mac OS 或 Linux 下执行,Windows 下要支持也应该容易但可能需要修改?

1. 先设置账号

export MI_USER=<Username>
export MI_PASS=<Password>

2. 查询自己的设备

micli.py list

可以显示自己账号下的设备列表,包含名称、类型、DID、Token 等信息。

3. 设置 DID

为了后续操作,请设置 Device ID(来自上面这条命令的结果)。

export MI_DID=<Device ID|Name>

4. 查询设备的接口文档

查询设备的 MIoT 接口能力描述:

micli.py spec xiaomi.wifispeaker.lx04

其中分为属性获取、属性设置、动作调用三种描述。

5. 查询音量属性

micli.py 2-1

其中 2siid1piid(如果是 1 则可以省略),可从 spec 接口描述中查得。

6. 设置音量属性

micli.py 2=#60

siidpiid 规则同属性查询命令。注意 # 号的意思是整数类型,如果不带则默认是文本字符串类型,要根据接口描述文档来确定类型。

7. 动作调用:TTS 播报和执行文本

以下命令执行后小爱音箱会播报“您好”:

micli.py 5 您好

其中,5 为 siid,此处省略了 1aiid

以下命令执行后相当于直接对对音箱说“小爱同学,查询天气”是一个效果:

micli.py 5-4 查询天气 #1

其中 #1 表示设备语音回应,如果要执行默默关灯(不要音箱回应),可以如下:

micli.py 5-4 关灯 #0

8. 其它应用

在扩展插件中使用,比如,参考 ZhiMsg 小爱同学 TTS 播报/执行插件

More Repositories

1

.homeassistant

Home Assistant Extras for Yonsm
Python
409
star
2

AheadLib

Fake DLL Source Code Generator
C++
216
star
3

HttPeek

iOS HTTP/HTTPS hook log plugin for Mobile Substrate
Objective-C
186
star
4

iPAFine

iOS IPA package refine and resign
Objective-C++
118
star
5

Yonsm.github.io

Yonsm.NET
HTML
115
star
6

Camo

Camo Preprocessor - Symbol Confusion for Objective C/C++ Source Code
Objective-C
89
star
7

ZhiMsg

Uniform Message Platform for HomeAssistant
Python
89
star
8

ZhiBot

Uniform Bot Platform for HomeAssistant
Python
55
star
9

YoungHook

A light weight hook utility for iOS.
C
44
star
10

IPTV

IPTV Resources
HTML
40
star
11

iTvMe

Apple TV Media Explorer
JavaScript
31
star
12

ZhiModBus

General ModBus Climate Component for HomeAssistant
Python
28
star
13

RawPlayer

Raw (YUV/RGB) video player and subjective assess tool
C
26
star
14

MISC

Misc Repo
Objective-C
19
star
15

ZhiMi

XiaoMi CloudService for HomeAssistant
Python
13
star
16

CeleWare

Personal Sample and Base Repository
Objective-C++
13
star
17

ZhiSaswell

Saswell Climate Component for HomeAssistant
Python
11
star
18

ZhiDash

Yet Another Dashboard for HomeAssiatant
JavaScript
10
star
19

Blayer

Play iPod Music and Maps Voice via Bluetooth HFP
Objective-C
8
star
20

DIY

DIY reated stuff
Shell
7
star
21

ZhiMrBond

MrBond Airer Component for HomeAssistant
Python
6
star
22

TransText

字符串提取、回写以及搜索替换工具
C
5
star
23

APProof

Armor Piercing Proof
Objective-C
5
star
24

MacX

Mac OS stuff
Python
4
star
25

ZhiCaiYun

CaiYun Weather Component for HomeAssistant
Python
4
star
26

OponWrt

OpenWrt Stuff
Shell
4
star
27

CeleScript

CeleScript for Windows
C++
4
star
28

ZhiLace

Lovelace Generator Component for HomeAssistant
Python
3
star
29

ZhiAct

Actuating Service Automatically for HomeAssistant
Python
2
star
30

YouKoo

YouKoo Exporter
Objective-C
1
star
31

ZhiMiJia

VoiMi Washer Component for HomeAssistant
Python
1
star
32

Sample

iOS Sample Project
Objective-C
1
star
33

ZhiMQTT

Zhi MQTT Component for HomeAssistant
Python
1
star
34

CeleCmd

CeleScript for Windows Mobile
C++
1
star