merdok/homebridge-miot

Not getting Temp/Humidity values from sensors any more

Closed this issue · 9 comments

Describe the bug
A few days ago Xiaomi temp/humidity sensors started giving 0 values to Apple Home. Nothing was changed from my side. Mi Home app still displays correct information. Changing to local connection does not help.

Expected behavior
Getting correct temp/humidity values in Apple Home.

Your config.json
Snippet of this particular device config (all of the devices have the same config, just the names are different and they all exhibit the same issue):

{
"name": "Miegamojo temp/dregme",
"ip": "(same as Xiaomi gatewat 3)",
"token": "(same as Xiaomi gateway 3)",
"deviceId": "blt.4.1cc601kvkgk00",
"model": "miaomiaoce.sensor_ht.t2",
"pollingInterval": 10,
"deepDebugLog": true,
"silentLog": false,
"deviceEnabled": true,
"micloud": {
"username": "",
"password": "
**",
"country": "de",
"forceMiCloud": true
},
"buzzerControl": true,
"ledControl": true,
"childLockControl": true,
"modeControl": true
},

Debug log
[10/12/2024, 11:47:19 AM] [miot] [Miegamojo temp/dregme] Connection to MiCloud device failed!
[10/12/2024, 11:47:19 AM] [miot] [Miegamojo temp/dregme] FetchError: request to https://account.xiaomi.com/pass/serviceLogin?sid=xiaomiio&_json=true failed, reason: getaddrinfo ENOTFOUND account.xiaomi.com
at ClientRequest. (/usr/local/lib/node_modules/homebridge-miot/node_modules/node-fetch/lib/index.js:1501:11)
at ClientRequest.emit (node:events:514:28)
at TLSSocket.socketErrorListener (node:_http_client:495:9)
at TLSSocket.emit (node:events:514:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
[10/12/2024, 11:47:19 AM] [miot] [Miegamojo temp/dregme] FetchError: request to https://account.xiaomi.com/pass/serviceLogin?sid=xiaomiio&_json=true failed, reason: getaddrinfo ENOTFOUND account.xiaomi.com
[10/12/2024, 11:47:19 AM] [miot] [Miegamojo temp/dregme] Error during connection! Retrying in 60 seconds!

Has something changed from Xiaomi's server side?

Now I've also noticed that the Xiaomi Window and Door Sensors (isa.magnet.dw2hl) have also stopped displaying lux values in the Home app and they're not reporting Open status (always display as Closed). Xiaomi Mi Home app displays everything correctly...

Seems like a connection issue to micloud. I am not aware of any changes, so maybe a temporary issue or something changed with your credentials...

The issue is ongoing for more than 3 days as of now. My credentials are the same as they were - I can use the devices on Mi Home iOS app and can login to https://account.xiaomi.com with no issues.

There were no changes to the plugin in the last 3 days so it cannot be an issue with the plugin. If this is an issue with the servers then there is nothing i can do about that. Other then switching to a local connection (if your gateway supports that) there is nothing else that i can recommend right now...

If I remove the "Force MiCloud connection" checkmark for one of the devices I get this error in the log:

[10/13/2024, 11:57:23 AM] [miot] [Darbo temp/dregme] (Protocol) 192.168.8.154 <- Reached maximum number of retries, giving up get_properties - [{"did":"blt.4.1dagnv31ogg00","siid":2,"piid":1},{"did":"blt.4.1dagnv31ogg00","siid":2,"piid":2},{"did":"blt.4.1dagnv31ogg00","siid":3,"piid":1}]
[10/13/2024, 11:57:23 AM] [miot] [Darbo temp/dregme] (Protocol) 192.168.8.154 <- Error during send! (timeout) Call to device timed out | Request: {"method":"get_properties","params":[{"did":"blt.4.1dagnv31ogg00","siid":2,"piid":1},{"did":"blt.4.1dagnv31ogg00","siid":2,"piid":2},{"did":"blt.4.1dagnv31ogg00","siid":3,"piid":1}],"id":1207}
[10/13/2024, 11:57:23 AM] [miot] [Darbo temp/dregme] Poll failed 1 times!
[10/13/2024, 11:57:23 AM] [miot] [Darbo temp/dregme] Poll failed! Error: Call to device timed out
[10/13/2024, 11:57:23 AM] [miot] [Darbo temp/dregme] (Protocol) 192.168.8.154 -> Data: {"id":1207,"error":{"code":-9999,"message":"user ack timeout"},"exe_time":4070}
[10/13/2024, 11:57:23 AM] [miot] [Darbo temp/dregme] (Protocol) 192.168.8.154 -> Message: {"id":1207,"error":{"code":-9999,"message":"user ack timeout"},"exe_time":4070}

A few minutes after:

[10/13/2024, 12:02:01 PM] [miot] [Darbo temp/dregme] Splitting properties into chunks. Number of chunks: 1. Chunk size: 14
[10/13/2024, 12:02:01 PM] [miot] [Darbo temp/dregme] Chunks:  [
 [
  "temperature-humidity-sensor:temperature",
  "temperature-humidity-sensor:relative-humidity",
  "battery:battery-level"
 ]
]
[10/13/2024, 12:02:01 PM] [miot] [Darbo temp/dregme] (Protocol) Call 192.168.8.154: get_properties - [{"did":"blt.4.1dagnv31ogg00","siid":2,"piid":1},{"did":"blt.4.1dagnv31ogg00","siid":2,"piid":2},{"did":"blt.4.1dagnv31ogg00","siid":3,"piid":1}] - {}
[10/13/2024, 12:02:01 PM] [miot] [Darbo temp/dregme] (Protocol) Start handshake 192.168.8.154
[10/13/2024, 12:02:01 PM] [miot] [Darbo temp/dregme] (Protocol) 192.168.8.154 <- (2) {"method":"get_properties","params":[{"did":"blt.4.1dagnv31ogg00","siid":2,"piid":1},{"did":"blt.4.1dagnv31ogg00","siid":2,"piid":2},{"did":"blt.4.1dagnv31ogg00","siid":3,"piid":1}],"id":3221}
[10/13/2024, 12:02:01 PM] [miot] [Darbo temp/dregme] (Protocol) 192.168.8.154 <- !1��L�t'Y���P��w�0�'�5
[10/13/2024, 12:02:01 PM] [miot] [Darbo temp/dregme] Successfully saved device info!
[10/13/2024, 12:02:05 PM] [miot] [Darbo temp/dregme] (Protocol) Start handshake 192.168.8.154
[10/13/2024, 12:02:05 PM] [miot] [Darbo temp/dregme] (Protocol) 192.168.8.154 <- (1) {"method":"get_properties","params":[{"did":"blt.4.1dagnv31ogg00","siid":2,"piid":1},{"did":"blt.4.1dagnv31ogg00","siid":2,"piid":2},{"did":"blt.4.1dagnv31ogg00","siid":3,"piid":1}],"id":3321}
[10/13/2024, 12:02:05 PM] [miot] [Darbo temp/dregme] (Protocol) 192.168.8.154 <- !1��L��W��j�GLR�|�g
[10/13/2024, 12:02:05 PM] [miot] [Darbo temp/dregme] (Protocol) 192.168.8.154 -> Data: {"id":3221,"error":{"code":-9999,"message":"user ack timeout"},"exe_time":4070}
[10/13/2024, 12:02:05 PM] [miot] [Darbo temp/dregme] (Protocol) 192.168.8.154 -> Message: {"id":3221,"error":{"code":-9999,"message":"user ack timeout"},"exe_time":4070}

If I remember correctly, these Xiaomi temp/humidity and window/door sensors never worked for me without MiCloud.

Reducing the polling interval might help to prevent that, but that only will work if your device actually supports the miot protocol. Otherwise MiCloud is the the only way.

Tried changing it to 15 seconds, same result...

Then it seems your device does not support the miot protocol

Finally figured it out - the Mac mini which was running Homebridge had an old DNS entry in network settings reffering to a raspberry pi with pi-hole which was removed from my network at least a month ago. Weird that it started affecting the connectivity after such a long time.
Homebridge had also timeouts in checking for updates. After removing the obsolete DNS entry, it now works perfectly.
Thank you for the effort.