hannseman / homebridge-mi-hygrothermograph

Homebridge plugin for the Xiaomi Mi Bluetooth Temperature and Humidity Sensor
MIT License
266 stars 52 forks source link

Strange plugin behavior #113

Closed danijcom closed 3 years ago

danijcom commented 4 years ago

The plugin makes a lot of chaotic requests and only small amount of them successful.

Expected Behavior

I've set updateInterval to 5 and I've expected that it will be getting info from my sensor one per 5 seconds.

Current Behavior

The plugin constantly makes a large number of requests, and there are quite a few successful ones among them. Humidity information usually appears after 5-10 minutes, and temperature information a few minutes later. They are updated with about the same frequency. There are a lot of requests, but the data from the sensor is rarely updated.

Steps to Reproduce (for bugs)

I installed the plugin completely following the instructions, then got the bindKey, and also changed the updateInterval in the config. However, it(updateInterval value) doesn't seem to work. Also, I enabled debug mode using web-ui.

Versions

Configuration

        {
            "name": "Temperature & Humidity",
            "address": "A4:C1:38:42:B3:5E",
            "bindKey": "8b74362124e14b400fce2b53af41ccca",
            "temperatureName": "Temperature",
            "humidityName": "Humidity",
            "updateInterval": 5,
            "fakeGatoEnabled": false,
            "timeout": 15,
            "forceDiscovering": true,
            "forceDiscoveringDelay": 20,
            "disableBatteryLevel": false,
            "lowBattery": 10,
            "temperatureOffset": 0,
            "humidityOffset": 0,
            "accessory": "Hygrotermograph"
        }

Homebridge Log / Command Output

Most often, I see this:

[7/30/2020, 5:38:52 PM] [Temperature & Humidity] No event
[7/30/2020, 5:38:54 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -35
      serviceData: 30585b05155eb34238c1a408
[7/30/2020, 5:38:54 PM] [Temperature & Humidity] No event
[7/30/2020, 5:38:55 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -34
      serviceData: 30585b05155eb34238c1a408
[7/30/2020, 5:38:55 PM] [Temperature & Humidity] No event
[7/30/2020, 5:38:57 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -48
      serviceData: 30585b05155eb34238c1a408
[7/30/2020, 5:38:57 PM] [Temperature & Humidity] No event
[7/30/2020, 5:38:59 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -31
      serviceData: 30585b05155eb34238c1a408
[7/30/2020, 5:38:59 PM] [Temperature & Humidity] No event
[7/30/2020, 5:39:00 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -39
      serviceData: 30585b05155eb34238c1a408
[7/30/2020, 5:39:00 PM] [Temperature & Humidity] No event
[7/30/2020, 5:39:02 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -34
      serviceData: 30585b05155eb34238c1a408
[7/30/2020, 5:39:02 PM] [Temperature & Humidity] No event
[7/30/2020, 5:39:04 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -31
      serviceData: 30585b05155eb34238c1a408
[7/30/2020, 5:39:04 PM] [Temperature & Humidity] No event
[7/30/2020, 5:39:05 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -34
      serviceData: 30585b05155eb34238c1a408
[7/30/2020, 5:39:05 PM] [Temperature & Humidity] No event

However, sometimes it happens that information about temperature or humidity still appears in the log like this:

[7/30/2020, 5:37:16 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Temperature: 34.1C
[7/30/2020, 5:37:16 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -51
      serviceData: 58585b05145eb34238c1a46a606f8a14000000b81066fc
[7/30/2020, 5:37:16 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Temperature: 34.1C
[7/30/2020, 5:37:16 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -30
      serviceData: 58585b05145eb34238c1a46a606f8a14000000b81066fc
[7/30/2020, 5:37:16 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Temperature: 34.1C
[7/30/2020, 5:37:17 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -34
      serviceData: 58585b05145eb34238c1a46a606f8a14000000b81066fc
[7/30/2020, 5:37:17 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Temperature: 34.1C
[7/30/2020, 5:37:17 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -30
      serviceData: 58585b05145eb34238c1a46a606f8a14000000b81066fc
[7/30/2020, 5:37:17 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Temperature: 34.1C

Or like this:

[7/30/2020, 5:36:17 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Humidity: 35.2%
[7/30/2020, 5:36:18 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -47
      serviceData: 58585b05125eb34238c1a477d12ea677000000dafc8105
[7/30/2020, 5:36:18 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Humidity: 35.2%
[7/30/2020, 5:36:18 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -47
      serviceData: 58585b05125eb34238c1a477d12ea677000000dafc8105
[7/30/2020, 5:36:18 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Humidity: 35.2%
[7/30/2020, 5:36:18 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Discovered peripheral
      Id: a4c13842b35e
      LocalName: LYWSD03MMC
      rssi: -34
      serviceData: 58585b05125eb34238c1a477d12ea677000000dafc8105
[7/30/2020, 5:36:18 PM] [Temperature & Humidity] [a4:c1:38:42:b3:5e] Humidity: 35.2%

But most often I see exactly what is written in the first part of the log (I did not copy the whole thing, but in fact there are thousands of such lines, and they appear very often). And temperature or humidity appears very rarely in the log. Maybe I'm worried in vain, and this is the normal behavior of the plugin, and I need to turn off debug mode and not pay attention to it, but I am worried that the information from the sensor is updated very rarely.

hannseman commented 4 years ago

This plugin makes no requests, it listens for BLE advertising packages emitted by the sensor. It's not possible to control the frequency of these packages. The setting updateInterval that you tried causes the plugin to ignore packages within the specified interval. This was added because someone had the opposite issue of you, the humidity and temperature was updated too frequently which caused issues when combined with certain automatisation flows.

Unfortunately I don't have the LYWSD03MMC sensor that you use so I can't really say if this is expected behaviour. The original sensor update temperature / humidity every second or so.. Your RSSI level looks good so it's probably not a range issue.

I would try to update the firmware of the sensor and/or change battery.

danijcom commented 4 years ago

Yep, the RSSI level is good because the sensor is alongside raspberry. The firmware version was immediately updated to the latest. I will try to replace the battery, but I don’t think it’s the case, it’s new. In any case, it seems to me that this is not a very critical problem, just such information in the log slightly surprised me. Well, it's a little annoying that the information is updated with a long delay ¯_(ツ)_/¯

benoitm76 commented 3 years ago

Hello @danijcom,

This is the normal behavior of the LYWSD03MMC. The sensor sends data update every 10 minutes (may be quicker if temperature or humidity change quickly but i am not sure). Battery level is sent every hour. See: https://community.home-assistant.io/t/xiaomi-passive-ble-monitor-sensor-platform/177352

Other BLE advertising packages contain no data. The sensor only says: "Hey ! I'am here !"

hannseman commented 3 years ago

@benoitm76 thanks for clearing this up!