Custom RGB Light Plugin

Moderator: leecollings

Post Reply
miroslavpetrov
Posts: 33
Joined: Wednesday 03 February 2016 13:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Custom RGB Light Plugin

Post by miroslavpetrov »

Hello everyone!
I bought few RGB Light bulbs that are based on ESP8266. The come with nice firmware which enables them to be controlled with HTTP requests.
I want to make a domoticz plugin for those(python preferably). Can you give me some guidance on how to begin. I was thinking of rewriting the plugin for Yeelight but I cannot find where the plugins are stored in domoticz.
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
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Custom RGB Light Plugin

Post by deennoo »

miroslavpetrov wrote:Hello everyone!
I bought few RGB Light bulbs that are based on ESP8266. The come with nice firmware which enables them to be controlled with HTTP requests.
I want to make a domoticz plugin for those(python preferably). Can you give me some guidance on how to begin. I was thinking of rewriting the plugin for Yeelight but I cannot find where the plugins are stored in domoticz.
YeeLight isn't à plugin, that à part of domoticz (github source code), and it works great for me and other, with some lua script, we can drive every thing (white temp, scène, colorflow)

What is your esp8266 modules ?
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
miroslavpetrov
Posts: 33
Joined: Wednesday 03 February 2016 13:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Custom RGB Light Plugin

Post by miroslavpetrov »

It is Shelly RGB bulb. Its firmware is based on mangoose OS. Here is an example http request:

http://192.168.1.20/color/0?turn=on&red ... 55&white=0

Can you give me some guidance how to begin with writing a LUA script or a python plugin in order to use domoticz's color picker?
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
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Custom RGB Light Plugin

Post by deennoo »

Colorpicker isn't on rgb but hsv, you have to use à translator if you want to use it.

On Lua you Can parse thé json value : https://www.domoticz.com/wiki/Domoticz_ ... fic_device

Another simple solution already used for hyperion plugin, or playbulb one's is to create 4. Dimmer :
Red
Green
Blue
white : if existe on your bulb
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
morilm
Posts: 35
Joined: Friday 27 January 2017 12:57
Target OS: OS X
Domoticz version:
Contact:

Re: Custom RGB Light Plugin

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

Hope it helps
User avatar
ledfreak3d
Posts: 98
Joined: Sunday 01 November 2015 15:30
Target OS: Linux
Domoticz version: 3.8025
Location: Hoorn
Contact:

Re: Custom RGB Light Plugin

Post by ledfreak3d »

why do it the hard way just flash espeasy on it and use the build in support
gives you fading also problem solved
Unleashe the magic smoke ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest