This script is triggered when the value of the virtual switch is changed.
Is it also possible to read the rgb value with a similar lua script?
- Spoiler: show
Moderator: leecollings
It is possible to read these RGB values but not very straightforward. I only know how to do this in dzVents like here.bitjeverkeerd wrote: ↑Wednesday 15 August 2018 13:48 I use the lua script below to read out the on/off state and brightness value of a virtual rgb switch from Domoticz (and to control hardware).
This script is triggered when the value of the virtual switch is changed.
Is it also possible to read the rgb value with a similar lua script?
Code: Select all
commandArray = {}
DomoticzDevice = 'RGB' -- Naam van script en van schakelaar in Domoticz!!!
if devicechanged[DomoticzDevice] then
if (otherdevices[DomoticzDevice]=='Off') then
text = "Dimmer = Off"
elseif (otherdevices[DomoticzDevice]=='On') then
text = "Dimmer = On"
else
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
local acolor = " "
ab='curl "http://192.168.51.111:8080/json.htm?type=devices&rid=12"' -- IP domoticz & IDX device
local jsondata = assert(io.popen(ab))
local jsondevices = jsondata:read('*all')
jsondata:close()
local jsonCPM = json:decode(jsondevices)
local acolor=jsonCPM.result[1].Color
print (acolor)
acolorj=acolor:gsub("}",",}")
for k,v in acolorj:gmatch('"(.-)":(.-),') do
--print(k,v)
if (k == 'b') then
rgbBlueValue = v
elseif (k == 'r') then
rgbRedValue = v
elseif (k == 'g') then
rgbGreenValue = v
end
end
DimLevel = (otherdevices_svalues[DomoticzDevice])
text = "Dimmer = " .. (DimLevel) .. " Rood = " .. (rgbRedValue) .. " Groen = " .. (rgbGreenValue) .. " Blauw = " .. (rgbBlueValue) .. ""
end
print (text)
end
return commandArray
Users browsing this forum: No registered users and 1 guest