merdok / homebridge-miot

Homebridge plugin for devices supporting the Xiaomi miot protocol
MIT License
383 stars 62 forks source link

Support for Xiaomi Window and Door Sensor 2 #406

Closed pedromcortereal closed 1 year ago

pedromcortereal commented 1 year ago

Hello,

First of all thank you and congrats on the plugin!!

Here's my request for the door sensor. Is it possible to add it to the plugin?

Device model isa.magnet.dw2hl

Device name Xiaomi Window and Door Sensor 2

Does the device require a MiCloud connection? Yes/No/Do not know No

Anything special about the device? Does not work with the plugin

merdok commented 1 year ago

Those are zigbee devices connected to your gateway, right? If yes, if you are able to retrieve the deviceid of the device then probably the approach would be the same as Bluetooth devices connected through the gateway. You could try that out.

pedromcortereal commented 1 year ago

Thanks for the reply. I think it is not a zigbee device. It's merely a BLE device. It works with the Mi Smart Home Hub Gateway (lumi.gateway.mgl03). I already retrieved the deviceid and token. Can you guide me through the approach you are proposing? Thanks again

merdok commented 1 year ago

You can have a look at this discussion https://github.com/merdok/homebridge-miot/discussions/348

pedromcortereal commented 1 year ago

I followed the procedure in the discussion you pointed and it seem I can't reach the sensor

homebridge@rpi4:/var/lib/homebridge $ miot send 192.168.1.XXXX --token XXXX get_properties "[{\"did\":\"XXXX\",\"siid\":2,\"piid\":1}]" INFO Connecting to device at 192.168.1.XXXX INFO Device found! Sending command: get_properties [{"did":"XXXX","siid":2,"piid":1}] (Protocol) 192.168.1.XXXX <- Reached maximum number of retries, giving up get_properties - [{"did":"XXXX","siid":2,"piid":1}] ERROR Call to device timed out

I'm using the gateway IP address and token, and the sensors' device id

any suggestions?

merdok commented 1 year ago

Probably something you provided is wrong. You would need to double check if the ip token and deviceid are indeed correct.

pedromcortereal commented 1 year ago

all the info is correct... when i provide the ip and token for the gateway and enter the gateway's deviceid, i get a positive response. but when i enter the magnet sensor's deviceid, i get the error i posted before... the same happens when i try to enter the temperature monitor's deviceid... it seems that none of the child ble devices of the gateway are reachable through their deviceid...

i noted that the deviceid of those ble child deviced have diferente formats than the "standalone" devices that connect via wifi, like the gateway itself, mi lightbulbs, mi space heater, etc... the latter have deviceids composed by 9 numbers, and the ble devices have deviceids like the following example "blt.2.13b07ds6cog83"

i guess that there has to be a way to add the magnet sensor to your plugin... i mean.. there's a homebridge plugin that adds the temperature monitor to homebridge (homebridge-mi-hygrothermograph v3.3.1). and that device is, like the magnet sensor i'm talking about, a ble device....

merdok commented 1 year ago

Those are not the correct deviceid's. The format for the xiaomi ecosystem devices is as far as I know always the same. When you have a look at the linked discussion then you will see that there the ble devices also have the correct deviceid. Maybe you can try and ask the author of that discussion? Unfortunately I myself do not have any...

dimkagithub commented 1 year ago

@pedromcortereal ,

I already retrieved the deviceid and token.

Hi! Could you tell how did you retrieve Xiaomi Window and Door Sensor 2 deviceID?