merdok / homebridge-miot

Homebridge plugin for devices supporting the Xiaomi miot protocol
MIT License
399 stars 64 forks source link

Support for Yeelight Candela Light (BLE, Bluetooth Low Energy) #202

Open kikiwora opened 2 years ago

kikiwora commented 2 years ago

Good evening!

As for now, I have only one device that is not connected to HomeKit via this or any other plugin, and that is Yeelight Candela.

This lamp can be controlled via Bluetooth using the Yeelight app, and I know that Homebridge supports Bluetooth devices, since I did successfully connect Hygrothermograph via BLE using Homebridge Mi Hygrothermograph plugin.

But for this lamp, no supported plugin has been found for Homebridge, however, the plugin for Homey Pro exists.

I wonder if someone possibly could implement support for this device in the scope of Homebridge MIOT plugin. It would be awesome. I'm sure that there're lots of people who bought this lamp and would like to use it via HomeKit

merdok commented 2 years ago

I know that some bluetooth devices also support the miot protocol, so in theory it should be possible. On the other hand i have absolutely no experience with bluetooth so it would require a lot of investigation for me, and i would also need a miot capable bluetooth device. The point is, i am not sure if investing time in that makes sense, since most of the bluetooth devices are battery based where frequent polling would just kill the battery so special handling would be needed...

Vannixxo commented 2 years ago

It would be amazing! I’m waiting for yeelight candela control since 2018

kikiwora commented 2 years ago

@merdok I understand your concern, in any case, it's up to you to decide.

But I must say that these devices can be connected to Xiaomi Bluetooth Gateway, for obvious reasons, to poll climate data, so the battery life should not be an issue. I may be wrong here, but isn't the BLE protocol made specifically to save power and thus replaces polling with the broadcast?

Candela light, for example, in my case is always connected via USB, since I use it as a daily night lamp or ambiance lamp when watching movies, and compared to the BLE energy consumption, the LED consumption is significantly higher, so even with frequent polling, the difference should be negligible.

And you always may place a warning, so users will know that connecting such devices will reduce their longevity a bit, so that will be a choice to make.

merdok commented 2 years ago

Let see, maybe at some point i will have a look it...

Vannixxo commented 2 years ago

Thanks so much!

Jonan1252 commented 2 years ago

I have a couple of lemesh.light.wy0c02 BLE Mesh Light running on the Xiaomi IoT Module-MHCB07P. These are very popular in china and no supported plugin has been found for Homebridge. Hope to see it available.

merdok commented 2 years ago

Well this is currently not my priority due to my goal to improve and stabilize the current wifi devices as much as possible so it might take a while till i can have a look at that (and because of the lack of such bluetooth devices). I mean if someone has knowledge about that and wants to help implementing such functionality, then it would be great if they could implement the protocol class for managing the connection to the bluetooth devices which would definitely help here.

uswong commented 2 years ago

There are increasing number of Xiaomi smart devices using Bluetooth. I have 4 units of Xiaomi Smart Power Trip 2 (5 outlet), model qmi.plug.psv3. They connects to Xiaomi Gateway 3 with Bluetooth Mesh. Although Xiaomi Gateway 3 is dubbed as Homekit compatible but devices connected to Bluetooth Mesh do not appear on HomeKit. I also have two units of Xiaomi wall switch ZNKG02HL work only with Bluetooth Mesh.

It would be really wonderful if this plugin could be expanded to manage the connection to the Bluetooth devices.

merdok commented 2 years ago

Still missing such a device to even have a look what the device is sending and if it would be possible to map that to the miot protocol...

uswong commented 2 years ago

Below is the Json file of qmi.plug.psv3:

{"type":"urn:miot-spec-v2:device:outlet:0000A002:qmi-psv3:1:0000C816","description":"Single Control Outlet","services":[{"iid":1,"type":"urn:miot-spec-v2:service:device-information:00007801:qmi-psv3:1:0000C816","description":"","properties":[{"iid":1,"type":"urn:miot-spec-v2:property:manufacturer:00000001:qmi-psv3:1:0000C816","description":"Device Manufacturer","format":"string","access":["read"]},{"iid":2,"type":"urn:miot-spec-v2:property:model:00000002:qmi-psv3:1:0000C816","description":"Device Model","format":"string","access":["read"]},{"iid":3,"type":"urn:miot-spec-v2:property:serial-number:00000003:qmi-psv3:1:0000C816","description":"Device Serial Number","format":"string","access":["read"]},{"iid":4,"type":"urn:miot-spec-v2:property:firmware-revision:00000005:qmi-psv3:1:0000C816","description":"Current Firmware Version","format":"string","access":["read"]}]},{"iid":2,"type":"urn:miot-spec-v2:service:switch:0000780C:qmi-psv3:1:0000C816","description":"Switch","properties":[{"iid":1,"type":"urn:miot-spec-v2:property:on:00000006:qmi-psv3:1:0000C816","description":"Switch Status","format":"bool","access":["read","write","notify"]},{"iid":2,"type":"urn:miot-spec-v2:property:mode:00000008:qmi-psv3:1","description":"Mode","format":"int8","access":["read","write","notify"],"value-range":[0,1,1]},{"iid":3,"type":"urn:miot-spec-v2:property:temperature:00000020:qmi-psv3:1","description":"Temperature","format":"float","access":["read","notify"],"unit":"celsius","value-range":[-30,125,0.1]},{"iid":4,"type":"urn:miot-spec-v2:property:working-time:00000079:qmi-psv3:1","description":"Working Time","format":"uint32","access":["read","notify"],"unit":"minutes","value-range":[0,1440,1]}],"actions":[{"iid":1,"type":"urn:miot-spec-v2:action:toggle:00002811:qmi-psv3:1","description":"Toggle","in":[],"out":[]}]},{"iid":3,"type":"urn:miot-spec-v2:service:power-consumption:0000780E:qmi-psv3:1","description":"Power Consumption","properties":[{"iid":1,"type":"urn:miot-spec-v2:property:power-consumption:0000002F:qmi-psv3:1","description":"Power Consumption","format":"float","access":["read","notify"],"value-range":[0,20000000,0.01]},{"iid":2,"type":"urn:miot-spec-v2:property:electric-power:00000066:qmi-psv3:1","description":"Electric Power","format":"float","access":["read","notify"],"unit":"watt","value-range":[0,10000,0.0001]},{"iid":3,"type":"urn:miot-spec-v2:property:voltage:00000031:qmi-psv3:1","description":"Voltage","format":"uint32","access":["read","notify"],"value-range":[0,500000,1]},{"iid":4,"type":"urn:miot-spec-v2:property:electric-current:00000030:qmi-psv3:1","description":"Electric Current","format":"uint32","access":["read","notify"],"value-range":[0,100000,1]}]},{"iid":4,"type":"urn:qmi-spec:service:relay-count-down:00007801:qmi-psv3:1","description":"relay-count-down","properties":[{"iid":1,"type":"urn:qmi-spec:property:count-down-time:00000001:qmi-psv3:1","description":"count-down-time","format":"int32","access":["read","notify","write"],"unit":"seconds","value-range":[1,86400,1]},{"iid":2,"type":"urn:qmi-spec:property:remain-time:00000002:qmi-psv3:1","description":"remain-time","format":"int32","access":["read","notify"],"unit":"seconds","value-range":[0,86400,1]},{"iid":3,"type":"urn:qmi-spec:property:enable-count-down:00000003:qmi-psv3:1","description":"enable-count-down","format":"bool","access":["read","notify","write"]}]},{"iid":5,"type":"urn:qmi-spec:service:relay-loop-task:00007802:qmi-psv3:1","description":"relay-loop-task","properties":[{"iid":1,"type":"urn:qmi-spec:property:open-time:00000001:qmi-psv3:1","description":"open-time","format":"int32","access":["read","notify","write"],"unit":"seconds","value-range":[0,86400,1]},{"iid":2,"type":"urn:qmi-spec:property:close-time:00000002:qmi-psv3:1","description":"close-time","format":"int32","access":["read","notify","write"],"unit":"seconds","value-range":[0,86400,1]},{"iid":3,"type":"urn:qmi-spec:property:enable:00000003:qmi-psv3:1","description":"enable","format":"bool","access":["read","notify","write"]}]},{"iid":6,"type":"urn:qmi-spec:service:system:00007803:qmi-psv3:1","description":"system","properties":[{"iid":1,"type":"urn:qmi-spec:property:enable-led:00000001:qmi-psv3:1","description":"enable-led","format":"bool","access":["read","notify","write"]},{"iid":2,"type":"urn:qmi-spec:property:enable-buzzer:00000002:qmi-psv3:1","description":"enable-buzzer","format":"bool","access":["read","notify","write"]},{"iid":3,"type":"urn:qmi-spec:property:status:00000003:qmi-psv3:1","description":"status","format":"uint8","access":[],"value-list":[{"value":0,"description":"Normal"},{"value":1,"description":"Protected-OverCurrent"},{"value":2,"description":"Protected-OverTemperature"},{"value":4,"description":"Alarm-OverCurrent"},{"value":8,"description":"Alarm-OverTemperature"}]},{"iid":4,"type":"urn:qmi-spec:property:keep-relay:00000004:qmi-psv3:1","description":"keep-relay","format":"bool","access":["read","notify","write"]},{"iid":5,"type":"urn:qmi-spec:property:update-power:00000005:qmi-psv3:1","description":"update-power","format":"bool","access":["read","notify","write"]}],"events":[{"iid":1,"type":"urn:qmi-spec:event:alarm:00005001:qmi-psv3:1","description":"alarm","arguments":[3]}]},{"iid":7,"type":"urn:qmi-spec:service:calibration:00007804:qmi-psv3:1","description":"calibration"},{"iid":8,"type":"urn:qmi-spec:service:test-simulation:00007805:qmi-psv3:1","description":"test-simulation","properties":[{"iid":1,"type":"urn:qmi-spec:property:temperature:00000001:qmi-psv3:1","description":"temperature","format":"int8","access":["read","notify","write"],"unit":"celsius","value-range":[-100,100,1]},{"iid":2,"type":"urn:qmi-spec:property:current:00000002:qmi-psv3:1","description":"current","format":"int8","access":["read","notify","write"],"value-range":[0,100,1]}]}]} ~

Hope this helps.

merdok commented 2 years ago

This is the spec which is publicly available... I need actual device communication logs...

Avamander commented 2 years ago

I'd add the BLE Alarm clocks to the list, the default app can't even automatically update DST through the hub... archaic stuff, a replacement would be lovely.

That aside, a Bluetooth HCI dump of certain actions would help?

merdok commented 2 years ago

I mean sure, you can provide one.

xmmwc commented 2 years ago

I found a way to add BLE devices and control it through mi cloud. use cli print all mi cloud devices list without filter. you can get model name, token and did.but localip is empty. then generate device js file with miot plugin(with require mi cloud checked). and move it to homebridge-miot/lib/modules/***/device/

set device config like this:

{
    "name":  "XXX",
    "ip": "0.0.0.0",
    "token": "<device token>",
    "deviceId": "<device id>",
    "model": "<device model>",
    ....
}

and reload homebridge.

merdok commented 2 years ago

Yeah, I guess the recent changes where I removed the dependency for an ip to be required even when a device is set to a micloud only allows to make it work. Also please note that it is now also possible to control Bluetooth devices which are connected to your bridge.

Jonan1252 commented 2 years ago

I found a way to add BLE devices and control it through mi cloud. use cli print all mi cloud devices list without filter. you can get model name, token and did.but localip is empty. then generate device js file with miot plugin(with require mi cloud checked). and move it to homebridge-miot/lib/modules/***/device/

set device config like this:

{
    "name":  "XXX",
    "ip": "0.0.0.0",
    "token": "<device token>",
    "deviceId": "<device id>",
    "model": "<device model>",
    ....
}

and reload homebridge.

May i know what did you use as the ip?

merdok commented 2 years ago

ip can be anything when using micloud, with a local connection you need to specify your bridge ip.

Jonan1252 commented 2 years ago

ip can be anything when using micloud, with a local connection you need to specify your bridge ip.

i got it working with micloud, however i am not able to control the BLE lights on a local connection with the homebridge ip.

merdok commented 2 years ago

Not homebridge ip, but your xiaomi mi HUB ip where all your devices are connected.

Vannixxo commented 2 years ago

So it isn't possible to control it without a xiaomi hub?

merdok commented 2 years ago

No, without a hub not yet. That would require to implement the whole xiaomi Bluetooth miot protocol...

xmmwc commented 2 years ago

@merdok why don't you consider generate device class js file automatically when first run and cache it.

merdok commented 2 years ago

It is being already done. But for it to work the plugin needs the model information, so for Bluetooth mesh devices you need to manually specify the correct model in the config.json.

pedromcortereal commented 1 year ago

I found a way to add BLE devices and control it through mi cloud. use cli print all mi cloud devices list without filter. you can get model name, token and did.but localip is empty. then generate device js file with miot plugin(with require mi cloud checked). and move it to homebridge-miot/lib/modules/***/device/

set device config like this:

{
    "name":  "XXX",
    "ip": "0.0.0.0",
    "token": "<device token>",
    "deviceId": "<device id>",
    "model": "<device model>",
    ....
}

and reload homebridge.

hello

I followed your steps to add the Xiaomi Door and Windows Sensor 2 (isa.magnet.dw2hl) but I can only see the battery level of the sensor on homebridge, the other properties do not show up. Check the homebrigde log below.

[12/15/2022, 7:42:29 PM] [miot] [Door sensor] Initializing device services [12/15/2022, 7:42:29 PM] [miot] [Door sensor] Device services: [ "magnet-sensor", "battery" ] [12/15/2022, 7:42:29 PM] [miot] [Door sensor] Initializing device properties [12/15/2022, 7:42:29 PM] [miot] [Door sensor] Device properties: [ "magnet-sensor:illumination", "magnet-sensor:contact-state", "battery:battery-level" ] [12/15/2022, 7:42:29 PM] [miot] [Door sensor] Initializing device actions [12/15/2022, 7:42:29 PM] [miot] [Door sensor] Device not supported! Using a generic device with limited properties! Consider requesting device support! [12/15/2022, 7:42:29 PM] [miot] [Door sensor] Initializing accessory! [12/15/2022, 7:42:29 PM] [miot] [Door sensor] Accessory successfully initialized! [12/15/2022, 7:42:29 PM] [miot] [Door sensor] Registering 1 accessories! [12/15/2022, 7:42:29 PM] [miot] [Door sensor] Everything looks good! Initiating property polling! [12/15/2022, 7:42:29 PM] [miot] [Door sensor] Log in to MiCloud! [12/15/2022, 7:42:30 PM] [miot] [Door sensor] Successfully connected to MiCloud! Setting up miot device from MiCloud connection! [12/15/2022, 7:42:30 PM] [miot] [Door sensor] Connected to device: isa.magnet.dw2hl [12/15/2022, 7:42:30 PM] [miot] [Door sensor] Doing initial property fetch. [12/15/2022, 7:42:30 PM] [miot] [Door sensor] Starting property polling.

can you help me with this?

merdok commented 1 year ago

That is already good news that you got it to work! Unfortunately as you noticed, contact sensors are not supported yet but that should not be a big issue for me to add them. I will try to add them in the next update. For now you could use the propertyMonitor to get a trigger when the sensor is triggered.

pedromcortereal commented 1 year ago

That is already good news that you got it to work! Unfortunately as you noticed, contact sensors are not supported yet but that should not be a big issue for me to add them. I will try to add them in the next update. For now you could use the propertyMonitor to get a trigger when the sensor is triggered.

Thanks for the tip @merdok ! Setting the propertyMonitor I was able o get a trigger when the contact sensor is triggered. It has a 5 to 10 sec delay between when i close/open the door and the property state alters on homebridge. I guess that this delay is due to the reading's being done through Mi Cloud and not locally through the Xiaomi Smart Home Hub. Correct?

It's being interpreted by homebridge as a light sensor, and the states changes for 0 to 1 LUX according to the door is opened or closed.

merdok commented 1 year ago

Glad that you got it working! The delay is because of the property polling, the state only updates periodically by the specified polling interval.

pedromcortereal commented 1 year ago

Thanks again!! I reduced the interval to 1 sec and it's working almost instantaneously!

Is there any way I can change how Homebridge "views" the device, and change it from a light sensor to a door sensor (ex.: change the icon, the units and device type)

merdok commented 1 year ago

@pedromcortereal You have to observe if 1 sec will not cause any issues for you. The view of the device will be different as soon as i release the next update.

ahmadnazirafiq commented 1 year ago

Hi, i’ve been reading this thread and I can’t figure out how to add Xiaomi Door and Windows Sensor 2 (isa.magnet.dw2hl). Not a tech-savvy, but I do have this sensor connected to BLE hubs.

merdok commented 1 year ago

@ahmadnazirafiq you can check in this discussion as somebody else was asking that a couple of days ago: https://github.com/merdok/homebridge-miot/discussions/442

ahmadnazirafiq commented 1 year ago

Thank you! Managed to finally exposed three BLE-based contact sensors to HomeKit for the first time!

ahmadnazirafiq commented 1 year ago

That is already good news that you got it to work! Unfortunately as you noticed, contact sensors are not supported yet but that should not be a big issue for me to add them. I will try to add them in the next update. For now you could use the propertyMonitor to get a trigger when the sensor is triggered.

Thanks for the tip @merdok ! Setting the propertyMonitor I was able o get a trigger when the contact sensor is triggered. It has a 5 to 10 sec delay between when i close/open the door and the property state alters on homebridge. I guess that this delay is due to the reading's being done through Mi Cloud and not locally through the Xiaomi Smart Home Hub. Correct?

It's being interpreted by homebridge as a light sensor, and the states changes for 0 to 1 LUX according to the door is opened or closed.

What did you put in the propertyMonitor for it to distinguish open/closed condition, @pedromcortereal? I just realized it didn't react at all when I open/close the contact sensor.

denisgabriel5 commented 1 year ago

Hi @merdok! Do you think you could help us a little bit regarding how to set the property monitor and how to change the view in Hombridge? It is currently seen as a light sensor (I guess). Thanks!

Edit: I tried all kind of combinations, but none of them got it to work. I will post my configuration and some screenshots from my Home app.

{
            "devices": [
                {
                    "name": "Door Sensor",
                    "ip": "censored",
                    "token": "censored",
                    "deviceId": "blt.4.1d07onrhkgg02",
                    "model": "isa.magnet.dw2hl",
                    "pollingInterval": 5,
                    "deepDebugLog": false,
                    "customAccessory": false,
                    "onlyMainService": true,
                    "buzzerControl": false,
                    "ledControl": false,
                    "childLockControl": false,
                    "modeControl": false,
                    "suppressAutoServiceCreation": [
                        "temperature",
                        "relativeHumidity",
                        "illumination"
                    ],
                    "propertyMonitor": [
                        {
                            "property": "magnet-sensor:contact-state",
                            "name": "Door Sensor"
                        },
                        {
                            "property": "battery:battery-level",
                            "valueOperator": "less"
                        },
                        {
                            "property": "magnet-sensor:illumination",
                            "valueOperator": "equal"
                        }
                    ]
                }
            ],
            "platform": "miot"
        }

IMG_2149 IMG_2150 IMG_2148

merdok commented 1 year ago

You are missing the value which you expect. Setting a valueOperator to less or equal does not make sense as you did not specify what value should be taken to compare too. Also if the Door Sensor is a numeric value then you have to specify what value is the triggered state.

denisgabriel5 commented 1 year ago
{
                    "name": "Door Sensor",
                    "deviceId": "blt.4.1d07onrhkgg02",
                    "model": "isa.magnet.dw2hl",
                    "pollingInterval": 1,
                    "deepDebugLog": false,
                    "customAccessory": false,
                    "onlyMainService": true,
                    "buzzerControl": false,
                    "ledControl": false,
                    "childLockControl": false,
                    "modeControl": false,
                    "suppressAutoServiceCreation": [
                        "temperature",
                        "relativeHumidity",
                        "illumination"
                    ],
                    "propertyMonitor": [
                        {
                            "property": "magnet-sensor:contact-state",
                            "name": "Door Sensor",
                            "value": "1",
                            "valueOperator": "equal"
                        }
                    ]
                },

Still not working. Tried with value set to 0 as well and still no luck.

merdok commented 1 year ago

The value type is probably not a string, also I see above that the door sensor is a contact sensor so it seems that it is fine, isn’t it?

denisgabriel5 commented 1 year ago

When I use the interface from the Plugin tab, it writes the value between apostrophes. Also, it doesn’t work because it will always say it’s closed (it appears in the Home app, but it doesn’t do anything).

The value type for this property is bool.

merdok commented 1 year ago

Yeah the ui unfortunately has always the type set to strong so you need to edit those values manually in the config. But did you validate that the property actually changes? Like with the miot cli commands?

denisgabriel5 commented 1 year ago

So, I tried with 0, 1, "0", "1", false, true, "false" and "true" and none of them works.

Regarding the CLI I tried the following:

root@denis-server:/var/lib/homebridge $ miot cloud device-info "blt.4.1d07onrhkgg02"
 INFO  Getting info for device with id blt.4.1d07onrhkgg02 from country cn...
 SUCCESS  Got device info from MiCloud
{
  "did": "blt.4.1d07onrhkgg02",
  "token": "censored",
  "longitude": "0.0",
  "latitude": "0.0",
  "name": "Door Sensor",
  "pid": "6",
  "localip": "<censored>",
  "mac": "<censored>",
  "ssid": "",
  "bssid": "",
  "parent_id": "",
  "parent_model": "",
  "show_mode": 1,
  "model": "isa.magnet.dw2hl",
  "adminFlag": 1,
  "shareFlag": 0,
  "permitLevel": 16,
  "isOnline": false,
  "desc": "",
  "extra": {
    "isSetPincode": 0,
    "pincodeType": 0,
    "fw_version": "2.1.0_0059",
    "needVerifyCode": 0,
    "isPasswordEncrypt": 0
  },
  "uid": 6471108181,
  "pd_id": 2443,
  "password": "",
  "p2p_id": "",
  "rssi": 0,
  "family_id": 0,
  "reset_flag": 0
}
root@denis-server:/var/lib/homebridge $ miot test <censored> --token censored
 INFO  Connecting to device at <censored>
Could not connect to device, handshake timeout
 ERROR  Could not connect to the device at <censored>! Make sure the ip and token are correct!
merdok commented 1 year ago

When it is a bool, then value should be either true or false.

miot test is for testing the local connection. You have to send the command to retrieve the property over mi cloud as it seems that you have that set up.

denisgabriel5 commented 1 year ago

You mean like this?

root@denis-server:/var/lib/homebridge $ miot cloud get-props 2.1            
 INFO  Executing get_properties command over MiCloud country cn with params 2.1 - timeout: 10000
(MiCloud) No result in response from MiCloud! Message: data type not valid
 SUCCESS  Response from MiCloud -> null
root@denis-server:/var/lib/homebridge $ miot cloud get-props 2.2
 INFO  Executing get_properties command over MiCloud country cn with params 2.2 - timeout: 10000
(MiCloud) No result in response from MiCloud! Message: data type not valid
 SUCCESS  Response from MiCloud -> null
root@denis-server:/var/lib/homebridge $ miot cloud get-props 3.1
 INFO  Executing get_properties command over MiCloud country cn with params 3.1 - timeout: 10000
(MiCloud) No result in response from MiCloud! Message: data type not valid
 SUCCESS  Response from MiCloud -> null
merdok commented 1 year ago

No, it has to be a raw parameter string. Have a look at the robot cleaner docs, there is an example for miot send get_properties but the param string should be similar for the cloud command.

denisgabriel5 commented 1 year ago

By the way, I grabbed this debug log:

[7/20/2023, 12:04:05 PM] [miot] [Door Sensor] Preparing property poll!
[7/20/2023, 12:04:05 PM] [miot] [Door Sensor] Splitting properties into chunks. Number of chunks: 1. Chunk size: 14
[7/20/2023, 12:04:05 PM] [miot] [Door Sensor] Chunks:  [
 [
  "magnet-sensor:illumination",
  "magnet-sensor:contact-state",
  "battery:battery-level"
 ]
]
[7/20/2023, 12:04:05 PM] [miot] [Door Sensor] (MiCloud) Encrypted request https://api.io.mi.com/app/miotspec/prop/get - {"params":[{"did":"blt.4.1d07onrhkgg02","siid":2,"piid":1},{"did":"blt.4.1d07onrhkgg02","siid":2,"piid":2},{"did":"blt.4.1d07onrhkgg02","siid":3,"piid":1}]}
[7/20/2023, 12:04:05 PM] [miot] [Door Sensor] Successfully updated property chunk! RAW: [{"did":"blt.4.1d07onrhkgg02","iid":"0.2.1","siid":2,"piid":1,"code":-704010000,"exe_time":0},{"did":"blt.4.1d07onrhkgg02","iid":"0.2.2","siid":2,"piid":2,"code":-704010000,"exe_time":0},{"did":"blt.4.1d07onrhkgg02","iid":"0.3.1","siid":3,"piid":1,"code":-704010000,"exe_time":0}]
[7/20/2023, 12:04:05 PM] [miot] [Door Sensor] Error while parsing response from device for property magnet-sensor:illumination. Response: {"did":"blt.4.1d07onrhkgg02","iid":"0.2.1","siid":2,"piid":1,"code":-704010000,"exe_time":0}
[7/20/2023, 12:04:05 PM] [miot] [Door Sensor] Error while parsing response from device for property magnet-sensor:contact-state. Response: {"did":"blt.4.1d07onrhkgg02","iid":"0.2.2","siid":2,"piid":2,"code":-704010000,"exe_time":0}
[7/20/2023, 12:04:05 PM] [miot] [Door Sensor] Error while parsing response from device for property battery:battery-level. Response: {"did":"blt.4.1d07onrhkgg02","iid":"0.3.1","siid":3,"piid":1,"code":-704010000,"exe_time":0}
[7/20/2023, 12:04:05 PM] [miot] [Door Sensor] Device properties updated: 
[
  "magnet-sensor:illumination: 0 | (not synced)",
  "magnet-sensor:contact-state: false | (not synced)",
  "battery:battery-level: 0 | (not synced)"
]
merdok commented 1 year ago

Yeah, there is an error during property sync, that would explain why you do not see the sensor update. I do not know what that error code means, it comes from the server, not sure why… maybe the device cannot be reached?

denisgabriel5 commented 1 year ago

I found this and from the translation (Bluetooth device cloud error - 704010000 Unknown, the plug-in is powerless.) of the first reply it seems that my battery is dead (which is weird because in the Mi Home app it works).

merdok commented 1 year ago

I also noticed that in the cloud device info from above the sensor is not online. Instead of a cloud connection you could also try to do a direct connection over the gateway and check if that helps.

denisgabriel5 commented 1 year ago

Any idea how to do that?

merdok commented 1 year ago

The ip and token needs to be from your gateway, the deviceid and model needs to from the device connected to the gateway which you want to control.

denisgabriel5 commented 1 year ago

Tried it. It doesn't work.