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

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

Moderator: leecollings

Post Reply
User avatar
Domoberry
Posts: 126
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

DzVents getColor() seems not to reflect Philip Hue ?

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

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

Post 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 .
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Domoberry
Posts: 126
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

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

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest