DzVents getColor() seems not to reflect Philip Hue ?
Posted: Sunday 18 October 2020 21:38
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:
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
} )
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(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