homebridge-miot
homebridge-miot copied to clipboard
Support for Yeelight Candela Light (BLE, Bluetooth Low Energy)
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
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...
It would be amazing! I’m waiting for yeelight candela control since 2018
@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.
Let see, maybe at some point i will have a look it...
Thanks so much!
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.
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.
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.
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...
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.
This is the spec which is publicly available... I need actual device communication logs...
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?
I mean sure, you can provide one.
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.
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.
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?
ip can be anything when using micloud, with a local connection you need to specify your bridge ip.
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.
Not homebridge ip, but your xiaomi mi HUB ip where all your devices are connected.
So it isn't possible to control it without a xiaomi hub?
No, without a hub not yet. That would require to implement the whole xiaomi Bluetooth miot protocol...
@merdok why don't you consider generate device class js file automatically when first run and cache it.
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.
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?
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.
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
propertyMonitorto 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.
Glad that you got it working! The delay is because of the property polling, the state only updates periodically by the specified polling interval.
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)
@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.
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.