Xiaomi smart home

bugger - it is all wireless at the moment. I should be getting a new one when i get fibre, hopefully soon…

Can anyone give me a quick description of how to utilize Jon’s code ? I have Fooxy’s plugin working, but can’t figure out how to use Jon’s. If i read correctly, it’s not a finished plugin yet, but keen just to see the output coming from the gateway.


Do the updates just appear? mine is currently on 1.2.xx and is taking a while to update. I assume i just have to keep checking for updates until i get to the right version?

I had issues updating too. I found that if i initiate the update, wait for the gateway to start flashing yellow, then press the home button on my phone, it would allow it to complete the update. just wait until the gateway stops flashing, and it should be updated.

Also - @jon1012 you are amazing!

I fired up your script first time, and it worked, across wireless too. I edited the MQTT server and changed the topic to start with a / (ie: /xiaomi/switch/158d0001256870/status click)

then used the following automations to toggle some lights:

- alias: "Dining Room light switch"
    platform: mqtt
    topic: /xiaomi/switch/158d00012568ae/status
    payload: "click"
     service: switch.toggle
     entity_id: switch.dining_room_light
- alias: "Eli's Room light switch"
    platform: mqtt
    topic: /xiaomi/switch/158d0001256870/status
    payload: "click"
     service: switch.toggle
     entity_id: switch.elis_room_light

can’t wait fro this to be implemented into a HASS componnet. I will just run it as a systmctl service until then :slight_smile:

1 Like

Can you explain what this is about?

Interested in this Xiaomi line.

Will the smart plug integrate well in HA? There are 2 versions anyone knows the difference?

Newb here, tell me that I understand well.

I can buy the Xiaomi hub and accessories and it integrates well with HA.
For example using the Xiaomi switch to trigger a Hue light. And is all relatively easy to program

not yet… i have grabbed @jon1012’s script, and have it running as a service on my linux box. It in turn publishes to MQTT, which i have a server running, then HA subscribes to those topics and reacts depending on what i expect it to do.

so at the moment - no it is not ‘easy’ not particularly hard if you are not a newbe… there is not a lot of information readily available on the net about the Xiaomi stuff. Shouldn’t be too long until it is all integrated i would think

Component easier to use.
No need to enter:

  • the gateway’s IP and port,
  • SID for each sensor.



cool - does it work with switches and motion sensors yet?

Another thing that i have come across. Every now and then i miss button presses, and i think that it is becuase the script (@jon1012’s) is connected over wifi, and since it is multicast trafffic, there are no ack’s or retries. So if there is a collision/lost packet, it will not work.

This thread excites me greatly!! I’ve been looking for cheap door sensors!

Let me know when they are confirmed working and I’ll buy a set :smile:

They have now very very low prices, like 60% off.

On one side I am tempted, on the other no, because:

  • when products are 60% off usually because a new series is coming
  • difficult integration, and another hub around …

where is this 60% off? any links?

check gearbest, banggood, and similar

ah, they are more or less the normal prices. once the hass component is finished, it’ll be easy to set up :slight_smile:

I’m testing something for magnet and proximity, the switch should be simple to implement.
To do this I changed the scan interval to 2 sec allowing HA to poll for data.
I think it should be possible to have a better way to do this if the gateway pushes data when the state changes.
I’ve to do some investigation and learn some basis about networking.
I will probably share the early code if some are interested.
It works even if sometimes it takes some second to respond.

@jon1012’s script seems to bind to a multicast address and converts everything that it recieves into MQTT. This will remove the requirement for polling, however, when over wifi there are chances to miss packets.

The MQTT posting is also very useful for debugging

(Note: i am yet to use your implementation, so i could be talking out of my ass…)

That’s right no need to do polling, the requests arrive as soon as the packet is sent from the Xiaomi HUB.
However, a big issue with the motion sensor is that it only seem to work once every minute. Once triggered, it will not work until the next minute. Anyone has experienced this 1 minute delay of motion or other kind of sensors?