hannseman / homebridge-mi-hygrothermograph

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

Error: Unknown event type #85

Closed muscaiu closed 4 years ago

muscaiu commented 4 years ago

I'm using the library to read the Mi sensor on a node js app and this is the whole code. i'm using. It works correctly by logging the temp and humidity, but after 5-10 minutes it crashes. Any idea why?

const { Scanner } = require("homebridge-mi-hygrothermograph/lib/scanner");

const livingId = '4c65a8dd7fc9';
const log = { debug() { }, error() { }, warn() { }, info() { } };
const livingScanner = new Scanner(livingId, { log });

try {
  livingScanner.on("temperatureChange", function (temperature, id) {
    console.log(temperature)
  });

  livingScanner.on("humidityChange", function (humidity, id) {
    console.log(humidity)
  });
} catch{
  livingScanner.on("error", error => console.log(error));
}

Error:

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: Unknown event type: 16. 5020aa0121c97fdda8654c100004df004402
    at Parser.parseEventData (/home/pi/soft/home-automation-api/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:174:15)
    at Parser.parse (/home/pi/soft/home-automation-api/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:56:23)
    at Scanner.parseServiceData (/home/pi/soft/home-automation-api/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:164:38)
    at Scanner.onDiscover (/home/pi/soft/home-automation-api/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:90:25)
    at Noble.emit (events.js:198:13)
    at Noble.onDiscover (/home/pi/soft/home-automation-api/node_modules/@abandonware/noble/lib/noble.js:178:10)
    at NobleBindings.emit (events.js:198:13)
    at NobleBindings.onDiscover (/home/pi/soft/home-automation-api/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:174:10)
    at Gap.emit (events.js:198:13)
    at Gap.onHciLeAdvertisingReport (/home/pi/soft/home-automation-api/node_modules/@abandonware/noble/lib/hci-socket/gap.js:256:10)
Emitted 'error' event at:
    at Scanner.parseServiceData (/home/pi/soft/home-automation-api/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:166:12)
    at Scanner.onDiscover (/home/pi/soft/home-automation-api/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:90:25)
    [... lines matching original stack trace ...]
    at Gap.onHciLeAdvertisingReport (/home/pi/soft/home-automation-api/node_modules/@abandonware/noble/lib/hci-socket/gap.js:256:10)
    at Hci.emit (events.js:198:13)
    at Hci.processLeAdvertisingReport (/home/pi/soft/home-automation-api/node_modules/@abandonware/noble/lib/hci-socket/hci.js:651:10)
hannseman commented 4 years ago

This is a duplicate of https://github.com/hannseman/homebridge-mi-hygrothermograph/issues/56.

My current understanding of this issue is that something changed in the raspberry-pi firmware earlier this year and this broke a lot of bluetooth related stuff. Some people have seen improvement by upgrading to the latest firmware and others have resorted to buying external bluetooth adapters or upgrading to the RPI 4.

muscaiu commented 4 years ago

I was thinking of buying a RPI4 because of the 64 architecture, now you just gave me an extra reason!