hannseman / homebridge-mi-hygrothermograph

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

Log : start / stop scanning entry ever second #115

Closed zehrer closed 3 years ago

zehrer commented 3 years ago

I run homebridge in service mode (no DEBUG and no -D) but the homebridge log file run full with about 100 entries per second like this :

[2020-10-11 21:42:45] [Keller] Start scanning. [2020-10-11 21:42:45] [WC] Stopped scanning. [2020-10-11 21:42:45] [Wohnzimmer] Stopped scanning. [2020-10-11 21:42:45] [Keller] Stopped scanning. [2020-10-11 21:42:45] [WC] Stopped scanning. [2020-10-11 21:42:45] [Wohnzimmer] Stopped scanning. [2020-10-11 21:42:45] [Keller] Stopped scanning. [2020-10-11 21:42:45] [WC] Stopped scanning. [2020-10-11 21:42:45] [Wohnzimmer] Stopped scanning. [2020-10-11 21:42:45] [Keller] Stopped scanning. [2020-10-11 21:42:45] [WC] Stopped scanning. [2020-10-11 21:42:45] [Wohnzimmer] Stopped scanning. [2020-10-11 21:42:45] [Keller] Stopped scanning. [2020-10-11 21:42:45] [WC] Stopped scanning.

Expected Behavior

at least not scanning log messages

Steps to Reproduce (for bugs)

I start homebridge in "Insecure" Mode to enable Accessory Control in Homebridge Config UI X

Versions

Configuration

Homebridge Log / Command Output

[2020-10-11 21:48:41] [HB Supervisor] Starting Homebridge with extra flags: -I
[2020-10-11 21:48:41] [HB Supervisor] Started Homebridge v1.1.6 with PID: 2667
[2020-10-11 21:48:43] Loaded config.json with 4 accessories and 2 platforms.
[2020-10-11 21:48:43] ---
[2020-10-11 21:48:44] Loaded plugin: homebridge-avea-bulb@1.1.3
[2020-10-11 21:48:44] Registering accessory 'homebridge-avea-bulb.AveaBulb'
[2020-10-11 21:48:44] ---
[2020-10-11 21:48:44] Loaded plugin: homebridge-config-ui-x@4.28.1
[2020-10-11 21:48:44] Registering platform 'homebridge-config-ui-x.config'
[2020-10-11 21:48:44] ---
[2020-10-11 21:48:44] Loaded plugin: homebridge-mi-hygrothermograph@3.0.1
[2020-10-11 21:48:47] Registering accessory 'homebridge-mi-hygrothermograph.Hygrotermograph'
[2020-10-11 21:48:47] ---
[2020-10-11 21:48:47] Loaded plugin: homebridge-shelly@0.15.5
[2020-10-11 21:48:48] Registering platform 'homebridge-shelly.Shelly'
[2020-10-11 21:48:48] ---
[2020-10-11 21:48:48] Loading 2 platforms...
[2020-10-11 21:48:48] [Config] Initializing config platform...
[2020-10-11 21:48:48] [Config] Running in Service Mode
[2020-10-11 21:48:48] [Shelly] Initializing Shelly platform...
[2020-10-11 21:48:48] Loading 4 accessories...
[2020-10-11 21:48:48] [WC] Initializing Hygrotermograph accessory...
[2020-10-11 21:48:48] [Wohnzimmer] Initializing Hygrotermograph accessory...
[2020-10-11 21:48:48] [Keller] Initializing Hygrotermograph accessory...
[2020-10-11 21:48:48] [Tischlampe] Initializing AveaBulb accessory...
hannseman commented 3 years ago

Weird! Can you try setting forceDiscovering: false? Do you run any other bluetooth related plugins?

hannseman commented 3 years ago

I just released a new version where the log entries you see won't show up as long as you don't run homebridge with the debug-flag. But there's most likely some issue with your setup since this plugin is supposed to be scanning continuously but something external is causing it to stop scanning and then it retries when forceDiscovering: true.

zehrer commented 3 years ago

The AveaBlub use Bluetooth as well, may this a problem when several plug-ins use Bluetooth ?

hannseman commented 3 years ago

Yes the bluetooth-library https://github.com/abandonware/noble which both this plugin and https://github.com/kounch/homebridge-avea-bulb use is known to not play very well with multiple instances of it running. This is why I added the option forceDiscovering but it appears like homebridge-avea-bulk have implemented a similar solution so the start / stop is caught in a loop. See: https://github.com/kounch/homebridge-avea-bulb/blob/master/index.js#L96

This plugin depends on continuous scanning since it only reads the BLE advertisement data and never connects to the device. It looks like homebridge-avea-bulb only use scanning to find the device and then connect to it. One idea might be to try and place homebridge-avea-bulb before this plugin in your homebridge configuration.

You can also try and set forceDiscovering: true and forceDiscoveringDelay to something higher than the default of 2500, maybe try 10000.