Custom RGB Light Plugin

Post Reply
miroslavpetrov
Posts: 30
Joined: Wednesday 03 February 2016 14:35
Target OS: Raspberry Pi
Domoticz version:
Contact:

Custom RGB Light Plugin

Post by miroslavpetrov » Saturday 09 September 2017 9:01

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: 938
Joined: Wednesday 10 December 2014 14:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Custom RGB Light Plugin

Post by deennoo » Thursday 21 September 2017 19:20

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 / ESP8266 / MQTT / BLE
http://domo-attitude.fr

miroslavpetrov
Posts: 30
Joined: Wednesday 03 February 2016 14:35
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Custom RGB Light Plugin

Post by miroslavpetrov » Friday 22 September 2017 16:41

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: 938
Joined: Wednesday 10 December 2014 14:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Custom RGB Light Plugin

Post by deennoo » Friday 22 September 2017 18:06

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 / ESP8266 / MQTT / BLE
http://domo-attitude.fr

morilm
Posts: 38
Joined: Friday 27 January 2017 13:57
Target OS: OS X
Domoticz version:
Contact:

Re: Custom RGB Light Plugin

Post by morilm » Tuesday 15 May 2018 19:18

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: 88
Joined: Sunday 01 November 2015 16:30
Target OS: Linux
Domoticz version: 3.8025
Location: Hoorn
Contact:

Re: Custom RGB Light Plugin

Post by ledfreak3d » Thursday 24 May 2018 8:39

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 2 guests