hannseman / homebridge-mi-hygrothermograph

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

Plugin can't read data from LYWSD02MMC #186

Open ndrobac opened 1 year ago

ndrobac commented 1 year ago

It does find the device, the decryption key is added properly, but it gets confused with strange event type number.

Expected Behaviour

Plugin should read the data from device, and decrypt it well, so the info can be properly passed to Homekit.

Current Behaviour

Plugin finds the device, but it can't parse the data properly Accessories show values of 0.

Steps to Reproduce (for bugs)

  1. install the plugin
  2. restart the homebridge
  3. look at the log...

Versions

Homebridge Log / Command Output

[9/14/2022, 6:45:22 PM] [Temperature & Humidity] Error: Unknown event type: 19458. 5858e4163cf674bd38c1a4024c0134
    at Parser.parseEventData (/homebridge/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:224:15)
    at Parser.parse (/homebridge/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:64:23)
    at Scanner.parseServiceData (/homebridge/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:174:52)
    at Scanner.onDiscover (/homebridge/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:95:25)
    at Noble.emit (node:events:527:28)
    at Noble.onDiscover (/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/noble.js:213:10)
    at NobleBindings.emit (node:events:527:28)
    at NobleBindings.onDiscover (/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:188:10)
    at Gap.emit (node:events:527:28)
    at Gap.onHciLeAdvertisingReport (/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/gap.js:250:10)
[9/14/2022, 6:45:18 PM] [Temperature & Humidity] Error: Unsupported state or unable to authenticate data
    at Decipheriv.final (node:internal/crypto/cipher:193:29)
    at Parser.decryptPayload (/homebridge/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:189:14)
    at Parser.parse (/homebridge/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:59:12)
    at Scanner.parseServiceData (/homebridge/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:174:52)
    at Scanner.onDiscover (/homebridge/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:95:25)
    at Noble.emit (node:events:527:28)
    at Noble.onDiscover (/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/noble.js:213:10)
    at NobleBindings.emit (node:events:527:28)
    at NobleBindings.onDiscover (/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:188:10)
    at Gap.emit (node:events:527:28)
[9/14/2022, 6:45:22 PM] [Temperature & Humidity] [a4:c1:**:**:**:**] Discovered peripheral
      Id: a4c1********
      LocalName: undefined
      rssi: -75
      serviceData: 5858e4163cf674bd38c1a411b879fa7204002ff86693

Other notable things

I did try hcitool lescan, and it does list the bluetooth devices via homebridge console, so the bluetooth hardware and hci scanning works. Also tried to run it without entering MAC address, and LE decryption key (finds it, asks for decryption key). Also tried Mijia Thermometer plugin - which gets the first batch of data when initially connects, but then again has same 2 errors like above mentioned.