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 #56

Closed GorkaMM closed 3 years ago

GorkaMM commented 5 years ago

Hi @hannseman,

After some months with the plugin working really great I started getting Unknown event type errors that make the plugin report the sensors as unavailable. I didn't make any change or software updates right before those errors started coming up — I paired the sensors with the Mi Home app though.

I have two Temp & humidity sensors set up with the plugin, both with address correctly set, plus one Flower Care I already had when there were no errors and which I am not using with Homebridge. All devices work well and hygrothermographs correctly report data to the plugin for the first few hours after starting Homebridge (logs below) — then mentioned errors begin showing up.

Expected Behavior

Temperature and humidity of both sensors are registered by Homebridge consistently over time.

Current Behavior

Temperature and humidity of both sensors are registered by Homebridge during the first 12-24h after starting it. Then it gets Unknown event type and it stops working.

Steps to Reproduce (for bugs)

I don't know.

Versions

Configuration

"accessories": [
    {
      "accessory": "Hygrotermograph",
      "name": "Hygrotermograph 1",
      "address": "4c:65:a8:da:50:90",
      "fakeGatoEnabled": true,
      "mqtt": {
        "url": "mqtt://localhost",
        "temperatureTopic": "sensor/temperature/1",
        "humidityTopic": "sensor/humidity/1"
      }
    },
    {
      "accessory": "Hygrotermograph",
      "name": "Hygrotermograph 2",
      "address": "4c:65:a8:da:57:0d",
      "fakeGatoEnabled": true,
      "mqtt": {
        "url": "mqtt://localhost",
        "temperatureTopic": "sensor/temperature/2",
        "humidityTopic": "sensor/humidity/2"
      }
    }
]

Homebridge Log / Command Output

0|homebrid | [2019-6-2 00:40:49] [Hygrotermograph 1] Error: Unknown event type: 1037. 5020aa01529050daa8654c0d04001001c701
0|homebrid |     at Parser.parseEventData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:174:15)
0|homebrid |     at Parser.parse (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:56:23)
0|homebrid |     at Scanner.parseServiceData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:161:38)
0|homebrid |     at Scanner.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:90:25)
0|homebrid |     at Noble.emit (events.js:187:15)
0|homebrid |     at Noble.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/noble.js:178:10)
0|homebrid |     at NobleBindings.emit (events.js:182:13)
0|homebrid |     at NobleBindings.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:174:10)
0|homebrid |     at Gap.emit (events.js:182:13)
0|homebrid |     at Gap.onHciLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/gap.js:256:10)
0|homebrid |     at Hci.emit (events.js:182:13)
0|homebrid |     at Hci.processLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:651:10)
0|homebrid |     at Hci.processLeMetaEvent (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:608:10)
0|homebrid |     at Hci.onSocketData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:479:12)
0|homebrid |     at BluetoothHciSocket.emit (events.js:182:13)
0|homebrid | 
0|homebrid | [2019-6-2 12:00:59] [Hygrotermograph 2] [4c:65:a8:da:57:0d] Timed out, last update: 2019-06-02T00:08:00.121Z
0|homebrid | [2019-6-1 19:46:44] [Hygrotermograph 1] Error: Unknown event type: 16. 5020aa01ff9050daa8654c1000040801ae01
0|homebrid |     at Parser.parseEventData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:174:15)
0|homebrid |     at Parser.parse (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:56:23)
0|homebrid |     at Scanner.parseServiceData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:161:38)
0|homebrid |     at Scanner.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:90:25)
0|homebrid |     at Noble.emit (events.js:187:15)
0|homebrid |     at Noble.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/noble.js:178:10)
0|homebrid |     at NobleBindings.emit (events.js:182:13)
0|homebrid |     at NobleBindings.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:174:10)
0|homebrid |     at Gap.emit (events.js:182:13)
0|homebrid |     at Gap.onHciLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/gap.js:256:10)
0|homebrid |     at Hci.emit (events.js:182:13)
0|homebrid |     at Hci.processLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:651:10)
0|homebrid |     at Hci.processLeMetaEvent (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:608:10)
0|homebrid |     at Hci.onSocketData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:479:12)
0|homebrid |     at BluetoothHciSocket.emit (events.js:182:13)
0|homebrid | [2019-6-1 18:46:47] [Hygrotermograph 1] Error: Unknown event type: 516. 5020aa01fa9050daa8654c0402000601
0|homebrid |     at Parser.parseEventData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:174:15)
0|homebrid |     at Parser.parse (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:56:23)
0|homebrid |     at Scanner.parseServiceData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:161:38)
0|homebrid |     at Scanner.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:90:25)
0|homebrid |     at Noble.emit (events.js:187:15)
0|homebrid |     at Noble.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/noble.js:178:10)
0|homebrid |     at NobleBindings.emit (events.js:182:13)
0|homebrid |     at NobleBindings.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:174:10)
0|homebrid |     at Gap.emit (events.js:182:13)
0|homebrid |     at Gap.onHciLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/gap.js:256:10)
0|homebrid |     at Hci.emit (events.js:182:13)
0|homebrid |     at Hci.processLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:651:10)
0|homebrid |     at Hci.processLeMetaEvent (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:608:10)
0|homebrid |     at Hci.onSocketData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:479:12)
0|homebrid |     at BluetoothHciSocket.emit (events.js:182:13)
hannseman commented 5 years ago

Hi! Thanks for the detailed report. Very weird stuff.

All the advertised data payloads look correct up until the event type, data length and the actual event data: 5020aa01529050daa8654c0d04001001c701 5020aa01ff9050daa8654c1000040801ae01 5020aa01fa9050daa8654c0402000601

They appear to have completly random values. For example 5020aa01fa9050daa8654c0402000601 which has the error Unknown event type: 516 specifies a event length as 0 but it has the hasEvent flag flipped and has following bytes. It makes no sense at all.

And that this error only appears after running for 12-24h is also weird. If this was not the case it would make be believe that they updated the firmware when you connected it to the MiHome app and changed the byte protocol, but since you also see valid data this is probably not the case.

Are you only experiencing this "Unknown event type" error on Hygrotermograph 1 or is it also present on Hygrotermograph 2? In the logs only Hygrotermograph 1 shows that error while Hygrotermograph 2 shows a timeout:

0|homebrid | [2019-6-2 12:00:59] [Hygrotermograph 2] [4c:65:a8:da:57:0d] Timed out, last update: 2019-06-02T00:08:00.121Z

This is usually an indicator that the sensor is not within range of the device running homebridge. Could you try and move the sensors closer to the server and see if you still get the timeouts? You could also try and change the battery on the sensors just to rule out that it's low voltage causing the random data.

GorkaMM commented 5 years ago

Thanks a lot for the help.

Hygrotermograph 2 throws the same kind of errors – I didn’t add it to the logs to make them shorter. Here you can see an extract:

0|homebrid | [2019-6-3 11:57:10] [Hygrotermograph 2] Error: Unknown event type: 1037. 5020aa01000d57daa8654c0d04001701d701
0|homebrid |     at Parser.parseEventData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:174:15)
0|homebrid |     at Parser.parse (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:56:23)
0|homebrid |     at Scanner.parseServiceData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:161:38)
0|homebrid |     at Scanner.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:90:25)
0|homebrid |     at Noble.emit (events.js:187:15)
0|homebrid |     at Noble.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/noble.js:178:10)
0|homebrid |     at NobleBindings.emit (events.js:182:13)
0|homebrid |     at NobleBindings.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:174:10)
0|homebrid |     at Gap.emit (events.js:182:13)
0|homebrid |     at Gap.onHciLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/gap.js:256:10)
0|homebrid |     at Hci.emit (events.js:182:13)
0|homebrid |     at Hci.processLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:651:10)
0|homebrid |     at Hci.processLeMetaEvent (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:608:10)
0|homebrid |     at Hci.onSocketData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:479:12)
0|homebrid |     at BluetoothHciSocket.emit (events.js:182:13)
0|homebrid |

What seems to happen is that after getting these errors the sensors are set as unavailable to HomeKit and that’s why you see the timeouts on the logs.

I will try getting them closer and changing batteries though. In any case, that firmware issue makes sense. What firmware are your sensors running on?

Thank you!

hannseman commented 5 years ago

Just tried to connect one of my sensors to the MiHome App and ran "Check for new firmware". It did say that it was up to date with 1.0.1_0066 but lets see if mine starts misbehaving as well.

hannseman commented 5 years ago

Also, can you see a pattern in the Error: Unknown event type messages?

Are these 3 the only values you can see in the logs after the above mentioned message: 1037 516 16

If you can only find one more value in the logs that would help to identify the four different packages the sensor emit (temperature, humidity, temperature & humidity, and battery).

GorkaMM commented 5 years ago

There's one more! Here you are:

0|homebrid | [2019-6-3 14:24:41] [Hygrotermograph 1] Error: Unknown event type: 518. 5020aa01aa9050daa8654c060200bb01
0|homebrid |     at Parser.parseEventData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:174:15)
0|homebrid |     at Parser.parse (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:56:23)
0|homebrid |     at Scanner.parseServiceData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:161:38)
0|homebrid |     at Scanner.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:90:25)
0|homebrid |     at Noble.emit (events.js:187:15)
0|homebrid |     at Noble.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/noble.js:178:10)
0|homebrid |     at NobleBindings.emit (events.js:182:13)
0|homebrid |     at NobleBindings.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:174:10)
0|homebrid |     at Gap.emit (events.js:182:13)
0|homebrid |     at Gap.onHciLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/gap.js:256:10)
0|homebrid |     at Hci.emit (events.js:182:13)
0|homebrid |     at Hci.processLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:651:10)
0|homebrid |     at Hci.processLeMetaEvent (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:608:10)
0|homebrid |     at Hci.onSocketData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:479:12)
0|homebrid |     at BluetoothHciSocket.emit (events.js:182:13)

It's weird it works for the first few hours though…

loktissimo commented 5 years ago

Same here. 1037 is a most often event.

hannseman commented 5 years ago

@loktissimo are you seeing the same behavior where it works for a while and then becomes unreachable?

loktissimo commented 5 years ago

Absolutely, I get: Same kind of error message, then Timed out, last update DATE/TIME

hannseman commented 5 years ago

@loktissimo thanks. Could you also provide some logs which could help to track down the cause of this error. By looking at the data that @GorkaMM provided it looks like the bytes that's supposed to describe the event type and event length are corrupted but the actual event data is good:

Data returned as event type 16 in the logs: 5020aa01ff9050daa8654c 1000 04 0801 ae01 Data returned as event type 1037: 5020aa01529050daa8654c 0d04 00 1001 c701

Both are actually the event returning temperature and humidity. The bytes 1000 and 0d04 are supposed to describe the event type and is supposed to be 0d10 for this event. The following byte is the event length, here 04 and 00, it is supposed to be 04 for this event and then the actual event data follows where the first bytes 0801 and 1001 represent temperature (26.4, 27.2) and the last bytes ae01 and c701 represent humidity (43.0, 45.5).

As reference here is a correct humidity & temperature data: 5020aa01b064aed0a8654c 0d10 04 d900 6001

Not really sure why the event type bytes and event length byte suddenly changed for you guys, and to seemingly random values (the usual event types follow a pattern of 4100, 4102, 4109 when parsed to integers).

@GorkaMM The reason why the time out error is seen is probably because the plugin don't get any valid packages since these errors occur and thinks that the sensor is not in reachable and thus times out after a while. The default timeout is 15 minutes.

@loktissimo did the sensor work as expected before you started seeing this error and did you upgrade or change anything before you started seeing this? Have you tried to change the battery?

loktissimo commented 5 years ago

Most recent logs from my system: [6/10/2019, 7:03:21 PM] [Hygrotermograph] Error: Unknown event type: 16. 5020aa01a26ca9d9a8654c100004f700ed01 at Parser.parseEventData (/usr/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:174:15) at Parser.parse (/usr/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:56:23) at Scanner.parseServiceData (/usr/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:161:38) at Scanner.onDiscover (/usr/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:90:25) at Noble.emit (events.js:189:13) at Noble.onDiscover (/usr/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/noble.js:178:10) at NobleBindings.emit (events.js:189:13) at NobleBindings.onDiscover (/usr/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:174:10) at Gap.emit (events.js:189:13) at Gap.onHciLeAdvertisingReport (/usr/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/gap.js:256:10)

[6/10/2019, 9:07:03 PM] [Hygrotermograph] [4C:65:A8:D9:A9:6C] Timed out, last update: 2019-06-10T16:40:40.388Z [6/10/2019, 9:07:03 PM] [Hygrotermograph] [4C:65:A8:D9:A9:6C] Timed out, last update: 2019-06-10T16:40:40.388Z [6/10/2019, 9:07:03 PM] [Hygrotermograph] [4C:65:A8:D9:A9:6C] Timed out, last update: 2019-06-10T16:40:40.388Z

did the sensor work as expected before you started seeing this error and did you upgrade or change anything before you started seeing this? Have you tried to change the battery?

Everything worked just fine on my previous setup. I've made quite a lot of changes: Reinstalled raspbian, upgraded NodeJS to 10, installed Deconz and so on. Unfortunately I didn't noticed when this error began to happen. I didn't change the battery yet.

loktissimo commented 5 years ago

Hi @hannseman. Any news on this issue? Will you be able to make an update?

hannseman commented 5 years ago

@loktissimo not really. Very hard to find the cause of this since I can't reproduce it. Since you describe that it started behaving like this after an upgrade it feels like it's some dependency misbehaving.

I'm also running the latest stretch, NodeJS 10, Deconz and have never seen this error. You could please list the versions of the following packages:

loktissimo commented 5 years ago

Here it is: bluetooth/stable,now 5.43-2+rpt2+deb9u2 all [installed] bluez/stable,now 5.43-2+rpt2+deb9u2 armhf [installed] libbluetooth-dev/stable,now 5.43-2+rpt2+deb9u2 armhf [installed] libudev-dev/stable,now 232-25+deb9u11 armhf [installed]

loktissimo commented 5 years ago

Can the duplicated MACs be an issue?

~# hcitool lescan LE Scan ... 56:6A:AE:91:F7:C1 (unknown) 08:7C:BE:84:18:CF (unknown) 08:7C:BE:84:18:CF MiKettle 64:32:4E:63:28:42 (unknown) 64:32:4E:63:28:42 (unknown) 4C:65:A8:D9:A9:6C (unknown) 4C:65:A8:D9:A9:6C MJ_HT_V1 44:AE:12:F1:D7:10 (unknown) 44:AE:12:F1:D7:10 (unknown) 78:97:2C:36:CE:8D (unknown) 78:97:2C:36:CE:8D (unknown) D7:A2:2B:B2:82:68 (unknown) D7:A2:2B:B2:82:68 MI Band 2 D4:B5:8E:D4:75:75 SMI-X3 56:6A:AE:91:F7:C1 (unknown) A0:6F:AA:3E:3A:03 (unknown) D4:B5:8E:D4:75:75 (unknown) C8:BD:7C:F4:2D:D2 SMI-M1 C8:BD:7C:F4:2D:D2 (unknown)

GorkaMM commented 5 years ago

Can the duplicated MACs be an issue?

~# hcitool lescan LE Scan ... 56:6A:AE:91:F7:C1 (unknown) 08:7C:BE:84:18:CF (unknown) 08:7C:BE:84:18:CF MiKettle 64:32:4E:63:28:42 (unknown) 64:32:4E:63:28:42 (unknown) 4C:65:A8:D9:A9:6C (unknown) 4C:65:A8:D9:A9:6C MJ_HT_V1 44:AE:12:F1:D7:10 (unknown) 44:AE:12:F1:D7:10 (unknown) 78:97:2C:36:CE:8D (unknown) 78:97:2C:36:CE:8D (unknown) D7:A2:2B:B2:82:68 (unknown) D7:A2:2B:B2:82:68 MI Band 2 D4:B5:8E:D4:75:75 SMI-X3 56:6A:AE:91:F7:C1 (unknown) A0:6F:AA:3E:3A:03 (unknown) D4:B5:8E:D4:75:75 (unknown) C8:BD:7C:F4:2D:D2 SMI-M1 C8:BD:7C:F4:2D:D2 (unknown)

I have it duplicate too.

hannseman commented 5 years ago

Sorry for the late reply. Unfortunately the dupe MACs are expected (happens for me as well).

Regarding the system dependencies I have the same versions installed as you @loktissimo.

The next time the plugin starts spitting out these errors in the logs could you open up the MiHome app and check if it can read the values correctly.

hannseman commented 5 years ago

I found this issue regarding bluetooth issues that started appearing in the latest kernel: https://github.com/raspberrypi/firmware/issues/1150

If anyone if you have a bluetooth adapter could you try using that instead of the builtin bluetooth? I'm using a RPI2 with the latest kernel and have no issues. Because RPI2 does not have builtin bluetooth I use an adapter, looks like this https://www.amazon.com/Bluetooth-Receiver-Computers-Compatible-Keyboards/dp/B07P5TMLWF.

GorkaMM commented 5 years ago

I changed batteries to my devices and it still fails so it definitely looks like that kernel issue is causing it. I'll wait a little bit to see how that bug evolves — if it doesn't get fixed soon then I'll buy an adapter and check if that way it works.

Thanks for the help @hannseman!

hannseman commented 5 years ago

You could also try and downgrade the firmware version by running: sudo rpi-update c50c65e52bad69e8fa7d6576d9e2399eade7faf6

hannseman commented 5 years ago

@GorkaMM, @loktissimo have you tried to update to the latest firmware with rpi-update. Did it help?

See https://github.com/raspberrypi/firmware/issues/1150 for more information.

GorkaMM commented 5 years ago

I waited for a stable release and just recently upgraded to 20190718 which corresponds to the kernel version 4.19.58 that supposedly addresses the issue, but I’m still having the same problem... I might just buy a Bluetooth dongle.

redge76 commented 5 years ago

I found this issue because with my MJ_HT_V1 hangs after 24h or 48h. Removing the device battery does restore communication. Using the command "gatttool -b 4C:65:A8:D9:XX:XX --char-read --handle=0x18" to query the battery status is a good way to know if the MJ_HT_V1 is responding to queries. I'm using https://github.com/trsqr/mijia_mqtt and not homebridge but I thought it might help you. maybe the issue is in the device and not in the rpi.

fcichos commented 5 years ago

Hi,

I have just setup a new raspberry 3 since your module was interfering with mi-flora on the other. On the newly created I also have the "Unknown Event Type 2" error.

-- Logs begin at Fri 2019-09-06 22:13:50 CEST, end at Fri 2019-09-06 23:44:37 CEST. -- Sep 06 23:44:23 raspberrypi homebridge[3627]: at NobleBindings.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/ Sep 06 23:44:23 raspberrypi homebridge[3627]: at Gap.emit (events.js:189:13) Sep 06 23:44:23 raspberrypi homebridge[3627]: at Gap.onHciLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/no Sep 06 23:44:23 raspberrypi homebridge[3627]: [9/6/2019, 11:44:23 PM] [Room 2] Error: Unknown event type: 2. 7122aa0157fc79dda8654c0d0200020d10 Sep 06 23:44:23 raspberrypi homebridge[3627]: at Parser.parseEventData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:174:15) Sep 06 23:44:23 raspberrypi homebridge[3627]: at Parser.parse (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:56:23) Sep 06 23:44:23 raspberrypi homebridge[3627]: at Scanner.parseServiceData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:164:38) Sep 06 23:44:23 raspberrypi homebridge[3627]: at Scanner.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:90:25) Sep 06 23:44:23 raspberrypi homebridge[3627]: at Noble.emit (events.js:194:15) Sep 06 23:44:23 raspberrypi homebridge[3627]: at Noble.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/nobl Sep 06 23:44:23 raspberrypi homebridge[3627]: at NobleBindings.emit (events.js:189:13) Sep 06 23:44:23 raspberrypi homebridge[3627]: at NobleBindings.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/ Sep 06 23:44:23 raspberrypi homebridge[3627]: at Gap.emit (events.js:189:13) Sep 06 23:44:23 raspberrypi homebridge[3627]: at Gap.onHciLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/no

GorkaMM commented 4 years ago

I eventually solved it just by upgrading to Raspberry Pi 4 because I couldn't find any other way around.

mrdc commented 4 years ago

The same issue for me on Homebridge@Docker@LibreELEC. Before it worked fine.

ymmtyuhei commented 4 years ago

I have the same error with homebridge on macOS.

[2020-1-5 5:16:32 PM] [Temperature & Humidity] Error: Unknown event type: 4114. 50300a04e39093b64aa37412100100
    at Parser.parseEventData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:174:15)
    at Parser.parse (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:56:23)
    at Scanner.parseServiceData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:164:38)
    at Scanner.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:90:25)
    at Noble.emit (events.js:198:13)
    at Noble.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/noble.js:178:10)
    at NobleMac.emit (events.js:198:13)

Versions

marianharbist commented 4 years ago

Is there any solution for this problem? I am running raspberry pi 4 with installed Raspbian and I've tried to connect new Xiaomi Temperature & Humidity sensor v2 (rectangle with led display) to homebridge but I am still getting this error. Thanks. 81836966_1776830302450458_2364084380655157248_o

kalety commented 4 years ago

Same here, occurs when add the new square T&H from Xiaomi... I deleted it from de config.sys and all runs flawlessly. Thanks

hannseman commented 4 years ago

@marianharbist could you please provide debug logs by running homebridge with its debug-flag: homebridge -D.

marianharbist commented 4 years ago

@hannseman gap advertisement = {"manufacturerData":{"type":"Buffer","data":[76,0,16,5,75,28,79,4,212]},"serviceData":[],"serviceUuids":[],"solicitationServiceUuids":[],"serviceSolicitationUuids":[]} +1ms hci onSocketData: 043e1f0201000072fda238c1a4130201060f1695fe30585b05f572fda238c1a408b5 +45ms hci event type = 4 +0ms hci sub event type = 62 +1ms hci LE meta event type = 2 +0ms hci LE meta event status = 1 +0ms hci LE meta event data = 000072fda238c1a4130201060f1695fe30585b05f572fda238c1a408b5 +0ms hci type = 0 +0ms hci address = a4:c1:38:a2:fd:72 +0ms hci address type = public +0ms hci eir = 0201060f1695fe30585b05f572fda238c1a408 +0ms hci rssi = -75 +0ms gap advertisement = {"localName":"LYWSD03MMC","serviceData":[{"uuid":"fe95","data":{"type":"Buffer","data":[48,88,91,5,245,114,253,162,56,193,164,8]}}],"serviceUuids":[],"solicitationServiceUuids":[],"serviceSolicitationUuids":[]} +46ms hci onSocketData: 043e180201040072fda238c1a40c0b094c5957534430334d4d43b5 +1ms hci event type = 4 +0ms hci sub event type = 62 +0ms hci LE meta event type = 2 +0ms hci LE meta event status = 1 +0ms hci LE meta event data = 040072fda238c1a40c0b094c5957534430334d4d43b5 +0ms hci type = 4 +0ms hci address = a4:c1:38:a2:fd:72 +0ms hci address type = public +0ms hci eir = 0b094c5957534430334d4d43 +1ms hci rssi = -75 +0ms gap advertisement = {"localName":"LYWSD03MMC","serviceData":[{"uuid":"fe95","data":{"type":"Buffer","data":[48,88,91,5,245,114,253,162,56,193,164,8]}}],"serviceUuids":[],"solicitationServiceUuids":[],"serviceSolicitationUuids":[]} +2ms [1/15/2020, 10:54:53 PM] [Temperature & Humidity] [a4:c1:38:a2:fd:72] Discovered peripheral Id: a4c138a2fd72 LocalName: LYWSD03MMC rssi: -75 serviceData: 30585b05f572fda238c1a408 [1/15/2020, 10:54:53 PM] [Temperature & Humidity] Error: Unknown event type null at Scanner.onDiscover (/usr/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:134:28) at Noble.emit (events.js:210:5) at Noble.onDiscover (/usr/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/noble.js:178:10) at NobleBindings.emit (events.js:210:5) at NobleBindings.onDiscover (/usr/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:174:10) at Gap.emit (events.js:210:5) at Gap.onHciLeAdvertisingReport (/usr/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/gap.js:256:10) at Hci.emit (events.js:210:5) at Hci.processLeAdvertisingReport (/usr/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:651:10) at Hci.processLeMetaEvent (/usr/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:608:10) at Hci.onSocketData (/usr/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js:479:12) at BluetoothHciSocket.emit (events.js:210:5)

This showed console

marianharbist commented 4 years ago

Any updates here with new v2 sensor? Still doesnt works

hannseman commented 4 years ago

I just released a new version (3.0.1) with updates to the bluetooth library. Please give it a shot.

Jacobb5179 commented 4 years ago

Hi all, just want to say I am also having a very similar issue with a RPi3B and old style sensor. It seems to fail between 5 and 12 hours of being restarted but I have had it run for a full day before. V3.0.1 hasn't helped unfortunatly :( . I've just started to use a work around where I use crontab to schedule a homebridge restart every 2 hours. If you need any info just let me know!

hannseman commented 3 years ago

Trying to close this issue as it've been a while since I've seen reports about it. Let me know if we should reopen it.

dimovskidamjan commented 3 years ago

I'm getting the same error for event type 4101 on LYWSD03MMC:

[21/07/2021, 13:59:25] [Temperature & Humidity] Error: Unknown event type: 4101. 71201301f643cd31eb497c09051002001d
    at Parser.parseEventData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:224:15)
    at Parser.parse (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:64:23)
    at Scanner.parseServiceData (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:171:52)
    at Scanner.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:92:25)
    at Noble.emit (events.js:315:20)
    at Noble.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/noble.js:213:10)
    at NobleBindings.emit (events.js:315:20)
    at NobleBindings.onDiscover (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:188:10)
    at Gap.emit (events.js:315:20)
    at Gap.onHciLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/gap.js:250:10)