I’m startng with my first Homey App. I want to build an app for my device that has a backlight. The backlight can be set with an available API to: on/off, brightness and color.
If I followed the developer introduction from Emile and I understand that I can use use the class ‘light’ to set on/off and dim values. But how about the color? How do you define that the color UI is also displayed in the App screen?
First try
in driver.compose.json:
{
"name": { "en": "Backlight" },
"images": {
"small": "/drivers/my_driver/assets/images/small.png",
"large": "/drivers/my_driver/assets/images/large.png"
},
"class": "light",
"capabilities": ["onoff", "dim"],
"capabilitiesOptions": {
"dim": { "preventInsights": true }
}
}
And when I register the capabilities:
this.registerCapabilityListener('onoff', async (value) => {
this.log('Backlight On/Off', value);
});
this.registerCapabilityListener('dim', async (value) => {
this.log('Helderheid: ', value);
});
this.registerCapabilityListener('light_hue', async (value) => {
this.log('Licht Hue: ', value);
});
It worked only for onoff and dim values.
Second try
Then I found that I can add the capabilities to the device in the onInit() in device.js
In device.js:
const lightCapabilities = [
"onoff",
"dim",
"light_hue",
"light_temperature",
"light_saturation",
"light_mode",
];
this.registerMultipleCapabilityListener(
lightCapabilities,
async ({
onoff,
dim,
light_hue,
light_temperature,
light_saturation,
light_mode
}) => {
// handle the changed capabilities here all at once
await DeviceApi.setOnOffAndDimAndColorAsync();
}
);
With in driver.compose.json:
{
"name": {
"en": "Backlight"
},
"class": "light",
"capabilities": [
"onoff",
"dim",
"light_hue",
"light_temperature",
"light_saturation",
"light_mode"
],
Removed the app and installed it again now the color UI is available. (-:
But on every capabilitie change I get now:

Where is this ‘device by id’ available or where must it be set?