Change lamp color before switching on

Moderator: leecollings

Post Reply
peterbos
Posts: 93
Joined: Saturday 07 November 2020 21:41
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Change lamp color before switching on

Post by peterbos »

Hi,

I'm a newby to dzvents and have a problem with my Innr RGBW lamp. I made a small test script in which the lamp is activated by a switch. After I switch it on, the lightcolor should be green, after a couple of seconds it should be red. The switch returns automatically to its Off-status and triggers a switchOff(). Problem is that the next time I push the switch the lamp gives a red flash before changing to green. I tried to change the color to green before the lamp switches off - that did not work. I also tried to change the color to black (RGB 000000) as in the code snippet but that didn't work either. Does anyone have a clue?

Peter

Code: Select all

     return {
        on = {
          devices = {
             'Schakelaar - Aqara 1'
          }
        },
        execute = function(domoticz, device)
            local Lamp = domoticz.devices('Lamp - Innr 1')
            if (device.state == 'B1') then
                Lamp.setColorBrightness(25,25,0,0,0,0,3,0)
                Lamp.setColorBrightness(25,0,0,0,0,0,3,0).afterSec(2)
            end
            if (device.state == 'Off') then
                Lamp.setColorBrightness(0,0,0,0,0,0,3,0)
                Lamp.switchOff().afterSec(1)
            end
        end
    }
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest