setColor() bug?  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

setColor() bug?

Post 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.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: setColor() bug?

Post 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.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: setColor() bug?

Post 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() ).
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: setColor() bug?

Post 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.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: setColor() bug?  [Solved]

Post 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest