viestursr / homebridge-xiaomi-yeelight

MIT License
4 stars 3 forks source link

Support for Xiaomi Color bulb #1

Open emilianos opened 2 years ago

emilianos commented 2 years ago

Is it possible to add support for Xiaomi/Yeelight color lightbulb? miiocli returns

Model: yeelink.light.color3
Hardware version: mw302
Firmware version: 2.0.6_0035

I have tried every other plugin out there without luck

viestursr commented 2 years ago

@emilianos I think it's possible, however out of the box you might have issues with color adjustment (I'm assuming it's an RGB bulb from the model name?). I only have color temperature adjustment built in for now, as that's the only capability of my Xiaomi branded Yeelight. Just to confirm the need to add this - in your Yeelight app you can't enable LAN Control (or maybe it's called Local Control) for the bulb?

emilianos commented 2 years ago

@viestursr thanks for the quick reply! Yes, it is a color light bulb. I dont think I can enable LAN control no.. There is actually an option to add to home, but it doesnt work right, as soon as I interact with the light its maximum brightness goes to like 60% so I'm only using it to turn on and off the light. Please let me know if there's any other information I can send from the device. thanks!!

viestursr commented 2 years ago

@emilianos Yeah googling that model name seems like it is indeed a Xiaomi branded light, so they did you the service of screwing up LAN control. I will do a small adjustment in a couple of hours, we'll see if that gets your bulb added to Homebridge via this plugin.

BTW, since you're successfully using miiocli, how did you obtain your encryption token for the bulb? Was it one of the methods linked in the readme? Want to know whether to update the readme if it's some different method.

emilianos commented 2 years ago

So I was using method 1 as described here: https://github.com/Maxmudjon/com.xiaomi-miio/blob/master/docs/obtain_token.md#method-3---obtain-mi-home-device-token-for-devices-that-hide-their-tokens-after-setup

(from Mi home account after adding to Mi home app, not Yeelight app)

viestursr commented 2 years ago

@emilianos Try updating to 1.1.3. You should be able to add the device now and control it. Please let me know how it goes, I'm just happy that this can be useful to someone else :)

You won't be able to control the color though, looks like that's a bit more involved process, I'll see if I can get to it when I have more free time, however I can't really test it since I don't have RGB lights myself. Maybe Homebridge UI has the color toggling, it doesn't for the temperature, so not holding my breath.

emilianos commented 2 years ago

@viestursr yep it works! This is awesome! Next step would be to add support for colors even if its hardcoded at first.. Feel free to reach me if you want me to test something on my end.

viestursr commented 2 years ago

@emilianos so since I don't have any xiaomi RGB lights, and with the underlying control library/api being very confusing, you'll have to join in trying to get this to work :) Can you try installing 1.1.5-beta2 -- sudo npm -g i homebridge-xiaomi-yeelight@1.1.5-beta2

Then I need a couple things from you

emilianos commented 2 years ago

@viestursr sure, I'm trying it now..

UPDATE:

I resterded HB again, and tried from Home first, now I see the colors, and logs coming into HB, but I lost the error logs when adjusting brightness from HB (setting to red)..

[2/22/2022, 5:20:36 PM] [homebridge-xiaomi-yeelight] This plugin generated a warning from the characteristic 'Saturation': characteristic value expected valid finite number and received "[object Object]" (object). See https://git.io/JtMGR for more info.

not sure why.. IMG_2F14400D9EA3-1

homebridge.log.txt

viestursr commented 2 years ago

@emilianos Thanks! I see that after the second restart you didn't try to change the color temperature - is that still broken? I see where I definitely went wrong with the color setting. Please try to update to 1.1.5-beta3 and try changing the brightness again - the color should be set as green. As the last time, send the logs over to me, I should be able to deduce which color setting method worked (there are multiple called at the same time).

emilianos commented 2 years ago

@viestursr

I see that after the second restart you didn't try to change the color temperature - is that still broken?

I dont remember now, I think I did, but when using Home app at some point it was not generating logs..

Ok, updated, tested and worked! light went green 👍 attaching log file

homebridge.log.txt

viestursr commented 2 years ago

@emilianos Awesome, one step closer. Will ping you when there's something more to test. Does color temperature adjustment work for you now, btw?

emilianos commented 2 years ago

@viestursr awesome! thanks!! Color temperature does not work:

[2/24/2022, 10:40:41 AM] [XiaomiYeelightSupport] setting power to true
[2/24/2022, 10:40:41 AM] [XiaomiYeelightSupport] setting brightness to 50
[2/24/2022, 10:40:41 AM] [XiaomiYeelightSupport] power set successfully
[2/24/2022, 10:40:41 AM] [XiaomiYeelightSupport] brightness set successfully
[2/24/2022, 10:40:41 AM] [XiaomiYeelightSupport] TEST: trying to set rgb to red -- 1 param as text
[2/24/2022, 10:40:41 AM] [XiaomiYeelightSupport] Error: 
    at Object.reject (/usr/lib/node_modules/homebridge-xiaomi-yeelight/node_modules/miio-yeelight22/lib/network.js:480:13)
    at DeviceInfo.onMessage (/usr/lib/node_modules/homebridge-xiaomi-yeelight/node_modules/miio-yeelight22/lib/network.js:379:8)
    at Socket.<anonymous> (/usr/lib/node_modules/homebridge-xiaomi-yeelight/node_modules/miio-yeelight22/lib/network.js:160:11)
    at Socket.emit (node:events:390:28)
    at UDP.onMessage (node:dgram:939:8) {
  code: -5001
}
[2/24/2022, 10:40:41 AM] [XiaomiYeelightSupport] TEST: trying to set rgb to red -- 1 param as int
[2/24/2022, 10:40:41 AM] [XiaomiYeelightSupport] TEST: trying to set rgb to red -- 3 params
[2/24/2022, 10:40:42 AM] [XiaomiYeelightSupport] setting power to true
[2/24/2022, 10:40:42 AM] [XiaomiYeelightSupport] setting brightness to 81
[2/24/2022, 10:40:42 AM] [XiaomiYeelightSupport] power set successfully
[2/24/2022, 10:40:42 AM] [XiaomiYeelightSupport] brightness set successfully
[2/24/2022, 10:40:42 AM] [XiaomiYeelightSupport] TEST: trying to set rgb to red -- 1 param as text
[2/24/2022, 10:40:42 AM] [XiaomiYeelightSupport] Error: 
    at Object.reject (/usr/lib/node_modules/homebridge-xiaomi-yeelight/node_modules/miio-yeelight22/lib/network.js:480:13)
    at DeviceInfo.onMessage (/usr/lib/node_modules/homebridge-xiaomi-yeelight/node_modules/miio-yeelight22/lib/network.js:379:8)
    at Socket.<anonymous> (/usr/lib/node_modules/homebridge-xiaomi-yeelight/node_modules/miio-yeelight22/lib/network.js:160:11)
    at Socket.emit (node:events:390:28)
    at UDP.onMessage (node:dgram:939:8) {
  code: -5001
}
[2/24/2022, 10:40:43 AM] [XiaomiYeelightSupport] TEST: trying to set rgb to red -- 1 param as int
[2/24/2022, 10:40:43 AM] [XiaomiYeelightSupport] TEST: trying to set rgb to red -- 3 params
[2/24/2022, 10:40:48 AM] [XiaomiYeelightSupport] setting color temp to 384 in kelvin: 2604
[2/24/2022, 10:40:48 AM] [XiaomiYeelightSupport] Error: 
    at Object.reject (/usr/lib/node_modules/homebridge-xiaomi-yeelight/node_modules/miio-yeelight22/lib/network.js:480:13)
    at DeviceInfo.onMessage (/usr/lib/node_modules/homebridge-xiaomi-yeelight/node_modules/miio-yeelight22/lib/network.js:379:8)
    at Socket.<anonymous> (/usr/lib/node_modules/homebridge-xiaomi-yeelight/node_modules/miio-yeelight22/lib/network.js:160:11)
    at Socket.emit (node:events:390:28)
    at UDP.onMessage (node:dgram:939:8) {
  code: -5001
}