- Devices: Mi Yeelight Lamps, Philiphs Bulb, Philiphs Eye Care lamp
- Model identifiers:
yeelink.light.lamp1
,yeelink.light.mono1
,yeelink.light.color1
,yeelink.light.strip1
,philips.light.sread1
,philips.light.bulb
Lights are turned into devices of type light and by default support power switching and dimming. Depending on the model the light might support color and fading.
if(device.matches('type:light')) {
/*
* This device is a light.
*/
}
// Get if the light is on
device.power()
.then(isOn => console.log('Light on:', isOn))
.catch(...);
// Using async/await
console.log('Light on:', await device.power());
// Switch the light on
device.setPower(true)
.then(...)
.catch(...)
// Switch on via async/await
await device.power(true);
// Read the current brightness
device.brightness()
.then(b => console.log('Brightness:', b))
.catch(...);
// Using async/await
console.log('Brightness:', await device.brightness());
// Set the brightness
device.setBrightness(50)
.then(...)
.catch(...);
// Using async/await
await device.setBrightness(50);
// Increase the brightness by 20%
await device.increaseBrightness(20);
// Decrease the brightness by 20%
await device.decreaseBrightness(20);
if(device.matches('cap:colorable')) {
// Light supports setting color
}
if(device.matches('cap:colorable', 'cap:color:full')) {
// Light supports setting full range of colors
}
if(device.matches('cap:colorable', 'cap:color:temperature')) {
// Light supports color temperatures
}
Power - cap:power
and cap:switchable-power
device.power()
- get if the light is turned ondevice.power(boolean)
- switch the light on or offdevice.setPower(boolean)
- switch the light on or offdevice.on('powerChanged', isOn => ...)
- listen for power changes
Brightness - cap:brightness
and cap:dimmable
device.brightness()
- get the brightness of the lightdevice.brightness(percentage, duration)
- set the brightness of the lightdevice.setBrightness(percentage, duration)
- set the brightness of the lightdevice.increaseBrightness(percentage, duration)
- increase the brightness of the lightdevice.decreaseBrightness(percentage, duration)
- decrease the brightness of the lightdevice.on('brightnessChanged', bri => ...)
- listen for changes in brightness
Color - cap:colorable
device.color()
- get the current color of the lightdevice.color(color, duration)
- update the color of the light, color can be hex-values, Kelvin-values, see capability docs for detailsdevice.on('colorChanged', color => ...)
- listen for changes to color
Fading - cap:fading
Supported by Yeelights. Indicates that the duration
parameter works.
The Eye Care lamp provides a child device to control the ambient light. This ambient light implements power switching and dimming:
const ambientLight = light.child('ambient');
const isOn = await ambientLight.power();