aholstenson / miio

Control Mi Home devices, such as Mi Robot Vacuums, Mi Air Purifiers, Mi Smart Home Gateway (Aqara) and more
MIT License
1.86k stars 355 forks source link

how to control yeelight device #45

Closed rench closed 7 years ago

rench commented 7 years ago

hello,how can i control yeelight device? is it auto-token? will i config the token myself?

why there is not set_rgb,set_mode.. method etc.

aholstenson commented 7 years ago

Hi. All Yeelights become devices of type light.

In addition some lights can have an undocumented capability called color:rgb which has a setRGB method that takes a color in hex-format or as an object with the properties red, green, blue with values between 0 and 255. The code for the color bulb can be found in the file yeelight.color.js.

This is experimental and will probably change in the next few releases as I haven't had time to add proper support for all Yeelight features yet, for example #30 is an issue about adding support for hue and saturation.

rench commented 7 years ago

Ok. I know that. I don't have any yeelight device,i want to know is these methods in this document ·https://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf· whether could be called in miio project?

if can, can i add method directly. i have a project with mijia,https://github.com/rench/homebridge-smarthome/blob/master/kit/mijia/yeelight.js, i use some method to covert hsv to rgb . i think it work correctly. but some other method can't be invoke like set_mode,set_ct methods in pdf document.

aholstenson commented 7 years ago

The ambition is to support most of that in the end, but everything is not supported yet. And those that are supported may be named differently, an example would be set_ct which is available if a light has the capability color:temperature in which case the method setColorTemperature is available.

And if something is missing you can always call any method on the device directly with call, which is how all the upper-level methods such as setRGB and setPower are implemented anyways. It's possible to do something like this device.call('set_power', [ 'off' ]), but then you are communicating directly with the device and other implemented behaviour for the device might break.

rench commented 7 years ago

Ok, I see. Some lighting equipment does not support the property, if I call the method certainly does not take effect. Because I do not have Yeelight's device, do not know if you can call the advanced method directly.

Since I saw Yeelight's PDF document, I thought that only way through the way that SSDP was called. Do you use miio's command line to set some other properties of Yeelight, such as start_cf, because I do not know if the method of the PDF document is the same method name in the MIIO protocol.