https://github.com/null-none/python-mihome
Library to use the Xiaomi Mi Home zigbee hub (receive paquets, events for now).
https://github.com/null-none/python-mihome
mihome python smart-home smarthome
Last synced: about 2 months ago
JSON representation
Library to use the Xiaomi Mi Home zigbee hub (receive paquets, events for now).
- Host: GitHub
- URL: https://github.com/null-none/python-mihome
- Owner: null-none
- Created: 2024-06-30T06:24:15.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-30T06:29:07.000Z (almost 2 years ago)
- Last Synced: 2025-01-26T09:28:27.337Z (over 1 year ago)
- Topics: mihome, python, smart-home, smarthome
- Language: Python
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Library to use the Xiaomi Mi Home zigbee hub (receive paquets, events for now).
Example of usage as a simple mqtt relay:
```bash
pio install paho-mqqt
pio install future
```
```python
import paho.mqtt.client as mqtt
from mihome import XiaomiConnector
MQTT_SERVER = "192.168.100.16"
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