Xiaomi Gateway Integration

Haven’t you also updated the gateway firmware recently?

I have seen this issue intermitently also, since the firmware upgrade (I have always been using @Danielhiversen repo and never noticed this until I upgraded.

That’s the trick. Lowercase for the SID :slight_smile:

I had it all in upper cases.

Thanks!!

1 Like

I’ve improved the ringtone services a bit:

https://github.com/Danielhiversen/homeassistant/commit/9b68a1d44e9d58e85e5d4a2fe0de50536c89b11d

nice!! Is that possible to play ringtones or other sound played from HA? Can it functioning like a bluetooth speaker?

So I reinstalled everything last night and all was working fine again with gateway.
Get up this morning and the gateway can’t be found again by home assistant. What gives, it’s crazy :rage:

I found a somehow official document of the current protocol version which states the range should be 300-1300:

https://cdn.cnbj2.fds.api.mi-img.com/lumiaiot/common/gateway/绿米网关局域网通信协议V1.0.8_2017.06.29.doc

Just read the posts starting here: Xiaomi Gateway Integration - #2184 by syssi

You cannot play/stream any audio.

1 Like

There is a last idea. The discovery of the gateway work something like this: The HA component sends a broadcast message to 224.0.0.50 port 4321. The gateway must be able to receive broadcasts (check your network). It will respond with a configuration message which includes the current ip address of the gateway. Now another socket will be opened on port 9898. This is the port where the all the events of the gateway will be received and processed. It’s multicast traffic again.

Some day my UDP port 9898 was blocked by the UDP listener of InfluxDB. Please check there is no other application using port 4321 and 9898 by “netstat -unl”.

sure i had to upgrade due to support of the new temp sensors.

OK we should treat 300 as the lowest value but protect against values below zero in some gateways.

2 Likes

Try to increase the timeout from 5s
https://github.com/Danielhiversen/homeassistant/blob/master/components/xiaomi.py#L186

to maximum what, 10 second, 20, 30?

Any wrongdoing if time is too long?

I like the suggestion.

https://github.com/Danielhiversen/homeassistant/pull/25

2 Likes

Increased it to 15’s there, still no joy.

Could it be a faulty gateway maybe? I noticed this morning when I got up (it’s beside my bed) that i flashed blue 3 or 4 times like it was resetting or something. Still working fine in the Mi App though…

connection to wifi unstable?

check wifi channel

I don’t think so as this is a different location to where I had the problem the other day as I moved the gateway then because I thought it might have been that.
I’m going to use a different router later on and see if that makes a difference just in case the generic VM router is causing these issues

if the problem is the wifi channel is not depending on the position (but on the channel)

Did the experiment and the results are as below…really wondering why the start value is different but the end value is same?! :rage:

Gateway1: 299 - 1292 → -1 - 992
Gateway2: 289 - 1292 → -11 - 992

With the implemented solution of removing the negative, seems like I will be losing 11 points on one of the gateway which could be quite significant. Sure looks like it is better to leave the value as it is reported by the gateway. Thoughts @syssi?

That fixed the issue, thank you! what did that change (just curious to learn).

We can make the upper and lower limit configurable as long we cannot predict the behaviour of the gateway otherwise. Losing 11 points is okay for me… the measurement is unreliable anyway. Any suggestions?