Git Product home page Git Product logo

mihome's Introduction

Library to use the Xiaomi Mi Home zigbee hub (receive paquets, events for now).

Example of usage as a simple mqtt relay:

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

mihome's People

Contributors

jon1012 avatar

Watchers

James Cloos avatar William Méndez avatar  avatar

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.