Page 1 of 1

DzVents getColor() seems not to reflect Philip Hue ?

Posted: Sunday 18 October 2020 21:38
by Domoberry
Hi Forum,

As part of a script to flash a Philips Hue lamp, I would like to retrieve the current lamp parameters, do the flashing and then return the lamp to whatever settings it had before. To retrieve and set the lamp parameters, DzVents getColor() and setColor() seem fit. However, I noted that it seems to me that getColor() does not retrieve the actual settings of the Philips Hue lamp, but rather the settings latest provided via Domoticz. E.g. if I for example change the color in the Philips Hue app, this is not seen in the table provided by getColor(). So, I got it wrong somewhere, yet don't know where. I used these lines to identify where I got stuck:

Code: Select all

local lamp2FlashIdx = 84  -- Fill in the the idx of the Philips Hue lamp to use

return 
{
    on = 
    {
        timer = 
        {
            'every minute', -- causes the script to be called every minute
        }, 
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,    
        marker = 'getColor() test',
    },
    
    execute = function(dz, timer)

        lamp2Flash = dz.devices(lamp2FlashIdx)
    
        dz.log('script active ' .. timer.trigger .. " for " .. lamp2Flash.name, dz.LOG_DEBUG)


        lampBefore = lamp2Flash.getColor() -- get the current lamp settings
        dz.log("Function getColor() returns a variable type: " .. type(lampBefore), dz.LOG_DEBUG)
        dz.log("data in  the table includes: " 
            .. " lampBefore.r: " .. lampBefore.r
            .. " lampBefore.g: " .. lampBefore.g
            .. " lampBefore.b: " .. lampBefore.b
            .. " lampBefore.brightness: " .. lampBefore.brightness
            .. " lampBefore.cw: " .. lampBefore.cw
            .. " lampBefore.ww: " .. lampBefore.ww
            .. " lampBefore.m: " .. lampBefore.m
            .. " lampBefore.t: " .. lampBefore.t
            , dz.LOG_DEBUG)

    end -- execute
} -- return
Any suggestion would be appreciated.
(what I want to achieve: if the power consumption according to P1 Smart Meter becomes critically high due to EV charging at 11kW and other home appliances, briefly flash a Philips Hue lamp and thereafter return the lamp to its original color {yes, I should get a 'smarter' EVSE, but that is the next step :-) } )

Re: DzVents getColor() seems not to reflect Philip Hue ?

Posted: Sunday 18 October 2020 21:57
by waaren
Domoberry wrote: Sunday 18 October 2020 21:38 Any suggestion would be appreciated.
(what I want to achieve: if the power consumption according to P1 Smart Meter becomes critically high due to EV charging at 11kW and other home appliances, briefly flash a Philips Hue lamp and thereafter return the lamp to its original color {yes, I should get a 'smarter' EVSE, but that is the next step :-) } )
Kind of a known problem. The colorTable of the device in domoticz is updated after the event. You could use the approach described here as a workaround .

Re: DzVents getColor() seems not to reflect Philip Hue ?  [Solved]

Posted: Sunday 18 October 2020 22:46
by Domoberry
Hi waaren, Thanks for the reply, will read the thread you suggested! Seems like directly calling the Domoticz api to query the device.