Xiaomi Gateway Integration

Yes but you need to pre record the audio using mi home app. TTS not supported afaik

Uhm, maybe I still need to wait for that support!

My goal is to create different greetings based on home sensors.

as media_player? That would be cool

I think you can achieve this as long as you are happy to pre-record the messages as custom ringtones, and to accept that the audio cannot be dynamic hence cannot include parameters - i.e. no "Welcome home <person>"

To get TTS working I think it would need to be using the radio capability not ring tones, and there is a lot of baggage to process the audio stream into the xiaomi radio chunked format I mentioned some posts above.

Who knows why Xiaomi took that approach for radio.

One other option is that Xiaomi could add to the API to allow to send ringtones to the gateway via the API. But AFAIK this is not available.

Yeah TTS generates an MP3 (or similar) file so unless someone can find a magically find a way of uploading them on demand pre-record is the only option.

As for why they took that approach it could well be due to Chinese censorship as the product is for their local market. If so it’s unlikely they’ll ever officially release the API for that model. If they make an international only version then it’d hopefully be open.

1 Like

Well this could be possible if Xiaomi opens radio API. Currently it’s not available. The only thing you can do with radio now is spoof the DNS and redirect gateway to you own playlists.

Thanks. I’ll update service names.

Could you upgrade to latest version of code and check if the plug have additional state attributes?

1 Like

Thank you all for your comments!

Hi guys,
Ive received my gateway today. I have succesfully installed the GW with the app and grapped the dev code and put it it my configuration.yaml.

But how do I know that the xiaomi gateway is reconzied? HA is running fine without any errors. But i dont see an Entity ID

Have you enabled local communication mode in your gateway?

Hi, I use your latest code and it works great. Thanks for all the work.
The only issue I see now is the delay between switching it on/off and the update of the usage data.

When I switch the lamp on while the plug is on already it takes a while to show up.
Same when I switch of the plug, the usage is still there until the next heartbeat.
Not a big deal, but maybe you could set in-use and load to 0 when the status is off. Or maybe there is a way to poll the values on status change at least?

btw, I plugged in a 15W lamp, so I guess the unit of measure is Watt.
That is also what the Xiaomi app shows. W for current load and kWh for total consumption.
It actually shows 0.035kWh, so I guess the unit of measure for me currently should be Wh
The app also reacts immediately to on/off and updates usage.

thanks for the great work.

Received my gateway today, updated to latest firmware

Is enabling local communication a requirement? If so can that be done on iOS app?

Struggling to setup the gateway as HA can’t find it

Local communications is certainly a must.

I used the Android app, but I think further up in this thread there were instructions on how to do it in iOS.

Search for iOS this thread. There was some guys who activated communication on iPhone.

Thanks all for confirming,

I have the latest IOS app, and can’t find anywhere to enable this :frowning:

This is what I am seeing:

Go into the About section and keep tapping on the empty whitespace below the menu items until the development options appear.

1 Like

See here

1 Like

Oh wow, what an Easter egg! Thanks all got it sorted,