Hello everybody,
I have in domoticz virtual RGB switch and I don't know how I can read color value from color picker in LUA.
Can you help me ?
Thank you...
Virtual RGB switch
Moderators: leecollings, remb0
-
- Posts: 33
- Joined: Wednesday 03 February 2016 13:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Virtual RGB switch
Same question here. I have smart rgb bulbs that can be controlled with http requests. My idea is to create a dummy rgb switch which values would be used in a script which will translate the values to http requests send to the bulb.
Automation Hardware:
Domoticz on Raspberry Pi 3 with HomeBridge.
Zigbee2MQTT + Xiaomi sensors
Fibaro HomeCenter 2 + Fibaro Dimmer2 & Double Switch2 + Aeon Multisensor 6 + Remotec ZXT-120
Eastron SDM230
Domoticz on Raspberry Pi 3 with HomeBridge.
Zigbee2MQTT + Xiaomi sensors
Fibaro HomeCenter 2 + Fibaro Dimmer2 & Double Switch2 + Aeon Multisensor 6 + Remotec ZXT-120
Eastron SDM230
Re: Virtual RGB switch
I'm working on the same.
/json.htm?type=command¶m=setcolbrightnessvalue&idx=xx&hue=274&brightness=40&iswhite=false
/json.htm?type=command¶m=setcolbrightnessvalue&idx=xx&hue=128&brightness=42&iswhite=false&sat=2
/json.htm?type=command¶m=setcolbrightnessvalue&idx=xx&hex=RRGGBB
seems to be available and working to set the values to the switch, so maybe we can decode the json response from the switch status to get the values from the switch into LUA after choosing the color on the LUA picker on the virtual RGB switch.
/json.htm?type=devices&rid=xx
(xx is the IDX number)
I can't run some test until next week... but if the Json returns the values, then it shouldn't be complicated, even not a perfect solution
regards,
Miguel
/json.htm?type=command¶m=setcolbrightnessvalue&idx=xx&hue=274&brightness=40&iswhite=false
/json.htm?type=command¶m=setcolbrightnessvalue&idx=xx&hue=128&brightness=42&iswhite=false&sat=2
/json.htm?type=command¶m=setcolbrightnessvalue&idx=xx&hex=RRGGBB
seems to be available and working to set the values to the switch, so maybe we can decode the json response from the switch status to get the values from the switch into LUA after choosing the color on the LUA picker on the virtual RGB switch.
/json.htm?type=devices&rid=xx
(xx is the IDX number)
I can't run some test until next week... but if the Json returns the values, then it shouldn't be complicated, even not a perfect solution
regards,
Miguel
Re: Virtual RGB switch
Dear all
There has been changes on domoticz and now the RGB color are being posted into Json, so its possible to query
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
local acolor = " "
ab='curl "http://192.168.1.101:8080/json.htm?type ... '..led_idx..'"'
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)
---------
If you wish to decode the color reply from Json
acolorj=acolor:gsub("}",",}")
aacolor={}
for k,v in acolorj:gmatch('"(.-)":(.-),') do
aacolor[k]=v
print(k,v)
end
So you can get the RGB values in a nice table you can use later on your LUA to call phyton or PHP to set your lights
Hope it helps
There has been changes on domoticz and now the RGB color are being posted into Json, so its possible to query
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
local acolor = " "
ab='curl "http://192.168.1.101:8080/json.htm?type ... '..led_idx..'"'
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)
---------
If you wish to decode the color reply from Json
acolorj=acolor:gsub("}",",}")
aacolor={}
for k,v in acolorj:gmatch('"(.-)":(.-),') do
aacolor[k]=v
print(k,v)
end
So you can get the RGB values in a nice table you can use later on your LUA to call phyton or PHP to set your lights
Hope it helps
Who is online
Users browsing this forum: No registered users and 0 guests