Script to automatically increase the brightness level

Hello, if you’re interested, I can provide you with a script that turns on a bulb at 0 lux and gradually increases the intensity to 100% every 5 seconds. You can freely adjust the duration between each increment. Personally, I use this script in the morning with a flow: when the time is 7 AM, the script runs, allowing for a gentle wake-up. I use an Ikea bulb where you can choose the color temperature, whether it’s warm or cool. :grinning:

// ID de l'ampoule
const ampouleId = "1f674fe-a9e4-4cbb-891-969a9b123d2";  // Please insert the ID of your bulb here.

async function allumerAmpoule() {
    try {
        // Récupérer la référence de l'ampoule en utilisant son ID
        const ampouleChambre = await Homey.devices.getDevice({ id: ampouleId });

        // Affiche l'objet ampouleChambre dans la console

        // Vérifier si l'ampoule a été trouvée
        if (ampouleChambre) {
            // Vérifier si la capacité 'onoff' est prise en charge
            if (ampouleChambre.capabilities && ampouleChambre.capabilities.includes('onoff')) {
                // Allumer l'ampoule avec un niveau de lux à 0%
                ampouleChambre.setCapabilityValue('dim', 0);
                ampouleChambre.setCapabilityValue('onoff', true);
                let lux = 0.01;
                while (lux <= 1.01) {
                    await wait(500); // Attendre 0.5 seconde
                    ampouleChambre.setCapabilityValue('dim', lux);
                    console.log(`Niveau de lux actuel : ${Math.round(lux * 100)}%`);
                    lux += 0.01;
            } else {
                console.error(`L'ampoule de la chambre ne supporte pas la capacité 'onoff'.`);
        } else {
            console.error(`Ampoule de la chambre introuvable avec l'ID : ${ampouleId}`);
    } catch (error) {
        console.error(`Une erreur s'est produite lors de la récupération de l'ampoule : ${error}`);

// Appeler la fonction asynchrone

Hi @dudu_95, thx for sharing this. It’s always nice to look into other persons homeyscript ideas and code to get some inspiration.

Did you know the same can be done with the chronograph app using a transition? Advantage is that the transition will continue after homey restart. Then you are sure you will wake up, even if the homey restarted just after 7 am :wink::sleeping:

No, I didn’t know. I will try it. Thank you.