Xiaomi Mi Home Python bindings
Project description
Library to use the Xiaomi Mi Home zigbee hub (receive paquets, events for now).
Example of usage as a simple mqtt relay:
```python
import paho.mqtt.client as mqtt
MQTT_SERVER = "192.168.0.149"
MQTT_PORT = 1883
PATH_FMT = "xiaomi/{model}/{sid}/{prop}" # short_id or sid ?
def prepare_mqtt():
client = mqtt.Client()
client.connect(MQTT_SERVER, MQTT_PORT, 60)
return client
def push_data(client, model, sid, cmd, data):
for key, value in data.items():
path = PATH_FMT.format(model=model,
sid=sid,
cmd=cmd,
prop=key)
client.publish(path, payload=value, qos=0)
client = prepare_mqtt()
cb = lambda m, s, c, d: push_data(client, m, s, c, d)
connector = XiaomiConnector(data_callback=cb)
while True:
connector.check_incoming()
```
For more information on the protocol and devices, see my notes: https://notes.jmsinfor.com/blog/post/admin/Xiaomi-Hub
Example of usage as a simple mqtt relay:
```python
import paho.mqtt.client as mqtt
MQTT_SERVER = "192.168.0.149"
MQTT_PORT = 1883
PATH_FMT = "xiaomi/{model}/{sid}/{prop}" # short_id or sid ?
def prepare_mqtt():
client = mqtt.Client()
client.connect(MQTT_SERVER, MQTT_PORT, 60)
return client
def push_data(client, model, sid, cmd, data):
for key, value in data.items():
path = PATH_FMT.format(model=model,
sid=sid,
cmd=cmd,
prop=key)
client.publish(path, payload=value, qos=0)
client = prepare_mqtt()
cb = lambda m, s, c, d: push_data(client, m, s, c, d)
connector = XiaomiConnector(data_callback=cb)
while True:
connector.check_incoming()
```
For more information on the protocol and devices, see my notes: https://notes.jmsinfor.com/blog/post/admin/Xiaomi-Hub
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mihome-0.1.tar.gz
(3.1 kB
view details)
Built Distribution
File details
Details for the file mihome-0.1.tar.gz
.
File metadata
- Download URL: mihome-0.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50670265810ad01646accb14fd4112fdb608dcfdca788785118b8bdaea77c089 |
|
MD5 | d85600dad0ad5be1d76c197bb9e5e82e |
|
BLAKE2b-256 | edef9bf726d70d5f23556c44341df7f33984c8653a410faa82cebcc0e95abb54 |
File details
Details for the file mihome-0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: mihome-0.1-py2.py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d79f3766c198bcda625aff0e8af9028953c92b6afa65d1e1ced71cf9dfe6fba1 |
|
MD5 | 41defbcee6756bc04eaae3289f304843 |
|
BLAKE2b-256 | 2e00103ea6654526e2f62b9d9f07c4f83ee94dc333855a7c5fdf5ea554ef51fc |