Page 1 of 1

setColor() bug?

Posted: Thursday 13 February 2020 18:46
by EddyG
It seems that this command does NOT honor the silent() function.

Code: Select all

dz.devices("Lamp XXX").setColor(0,0,0,100,255,255,2,160).silent()
The function works OK, except for the silent() function.
This is the total code.
I have 2 lamps (XXX and YYY) and a switch "Bedlampen"
That switch is controlled by hand or by a PIR
The total acts OK, but this script is executed multiple times.

Code: Select all

return {

    active = true,
--  active = false,
    on = {
        devices = { "Bedlampen", "Lamp XXX", "Lamp YYY" }
    },

    execute = function(dz, mySwitch)
        if mySwitch.name == "Lamp XXX" or mySwitch.name == "Lamp YYY" then
            XXX = dz.devices("Lamp XXX").state
            YYY = dz.devices("Lamp YYY").state
            if (XXX == 'On' or YYY == 'On') then
                dz.devices("Bedlampen").switchOn().checkFirst().silent()
            elseif (XXX == 'Off' and YYY == 'Off') then
                dz.devices("Bedlampen").switchOff().checkFirst().silent()
            end
        elseif mySwitch.name == "Bedlampen" then
            if (mySwitch.state == 'On') then
                if dz.devices("Lamp XXX").state == 'Off' then
                    dz.devices("Lamp XXX").setColor(0,0,0,100,255,255,2,160).silent()
                end
                if dz.devices("Lamp YYY").state == 'Off' then
                    dz.devices("Lamp YYY").setColor(0,0,0,100,255,255,2,160).silent()
                end
            else
                dz.devices("Lamp XXX").switchOff().checkFirst().silent()
                dz.devices("Lamp YYY").switchOff().checkFirst().silent()
            end
        end
    end
}
P.S. Due to the Buster change I am still on stable release.

Re: setColor() bug?

Posted: Thursday 13 February 2020 19:04
by EddyG
After some more debugging, I found out that Zigbee2mqtt is sending more then 1 confirmation back to domoticz via the plugin.
So likely NO bug on dzVents part.

Re: setColor() bug?

Posted: Thursday 13 February 2020 19:12
by waaren
EddyG wrote: Thursday 13 February 2020 18:46 It seems that this command does NOT honor the silent() function.

Code: Select all

dz.devices("Lamp XXX").setColor(0,0,0,100,255,255,2,160).silent()
As per the availability overview in the wiki: the .silent() method is only available for state changes ( switchOn(), switchOff(), dimTo() open(), etc.. ) , update commands ( updateTemperature(), updateAlertSensor() ) and user variables (set() ).

Re: setColor() bug?

Posted: Thursday 13 February 2020 19:43
by EddyG
Nice, but it works! apparently the setColor also switches ON the device.
I had 2 commands, first setColor and second to switchOn.
In my debugging I found out that setColor alone does also the switchOn.
Maybe you can test that too and update the wiki.
It seems that the other trigger on the scripts comes from multiple updates from zigbee2mqtt via the plugin.

Re: setColor() bug?  [Solved]

Posted: Friday 14 February 2020 14:47
by waaren
EddyG wrote: Thursday 13 February 2020 19:43 Nice, but it works! apparently the setColor also switches ON the device.
setColor is indeed also an implied switchOn() if the 4th parm ( brightness > 0 ). That is true for all device commands that influence the dimlevel / brightness / selectorLevel .

dimlevel 0, switchSelector 0, brightness 0 are implied switchOff(), anything higher are implied switchOn()

That is true for commands via JSON/API, GUI or native dzVents commands.
The silent() method for setColor and the likes is ignored by dzVents / domoticz.

Happy to update the wiki to clarify it for all if you have a text proposal