Virtual RGB switch

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
lukbe
Posts: 16
Joined: Saturday 06 May 2017 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Contact:

Virtual RGB switch

Post by lukbe »

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...
miroslavpetrov
Posts: 33
Joined: Wednesday 03 February 2016 13:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Virtual RGB switch

Post by miroslavpetrov »

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
morilm
Posts: 35
Joined: Friday 27 January 2017 12:57
Target OS: OS X
Domoticz version:
Contact:

Re: Virtual RGB switch

Post by morilm »

I'm working on the same.

/json.htm?type=command&param=setcolbrightnessvalue&idx=xx&hue=274&brightness=40&iswhite=false
/json.htm?type=command&param=setcolbrightnessvalue&idx=xx&hue=128&brightness=42&iswhite=false&sat=2
/json.htm?type=command&param=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
morilm
Posts: 35
Joined: Friday 27 January 2017 12:57
Target OS: OS X
Domoticz version:
Contact:

Re: Virtual RGB switch

Post by morilm »

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

Who is online

Users browsing this forum: No registered users and 0 guests