RGB Ledstrip with LUA

Moderator: leecollings

Post Reply
bartmolk
Posts: 7
Joined: Monday 14 May 2018 10:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

RGB Ledstrip with LUA

Post by bartmolk »

Hello everyone,

I am trying to create the RGB function / colorpicker to control the ledstrips which are running through a LUA script but for some reason it turns
all the colors on and doesn't let me select a color.

I've tried all options RGB and RGBW, and RGBWW but nothing seems to work correctly. The script I am using is the following script:

Code: Select all

local lights = {
  ['muurbart'] = {ip = '192.168.188.242', red = '15', grn = '13', blu = '12', rgb = true}
}

function setlight (ip, pin, dvalue)
    os.execute("curl 'http://" .. ip.. "/control?cmd=PWM,".. pin .."," .. tostring(dvalue) .. ",1028'")
end

commandArray = {}

for deviceName,deviceValue in pairs(devicechanged) do
    if (lights[deviceName]) then
        if (deviceValue == 'Off') then
            dvalue = 0
        elseif (deviceValue == 'On') then
            dvalue = 1024
        else
            inputValue = tonumber(otherdevices_svalues[deviceName])
            
            curve = 1.5848931924611
            normalizedCurVal  =  (inputValue - 1.0) / 99.0
            rangedValue =  (math.pow(normalizedCurVal, curve) * 1023.0) + 1.0
            
            dvalue = math.ceil(rangedValue)
        end
    
        if (lights[deviceName]['rgb']) then
            setlight(lights[deviceName]["ip"], lights[deviceName]["red"], dvalue)
            setlight(lights[deviceName]["ip"], lights[deviceName]["grn"], dvalue)
            setlight(lights[deviceName]["ip"], lights[deviceName]["blu"], dvalue)
        else
            setlight(lights[deviceName]["ip"], lights[deviceName]["pin"], dvalue)
        end
    end
end
return commandArray
Thanks in advance!
bartmolk
Posts: 7
Joined: Monday 14 May 2018 10:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: RGB Ledstrip with LUA ESP8266 / H801

Post by bartmolk »

No one that can tell me how I can get my RGB ledstrips to work with my ESP8266 / H801?
twoenter
Posts: 76
Joined: Sunday 17 February 2019 15:01
Target OS: NAS (Synology & others)
Domoticz version: 4.10
Contact:

Re: RGB Ledstrip with LUA

Post by twoenter »

What do you see in log when you print:

Code: Select all

http://" .. ip.. "/control?cmd=PWM,".. pin .."," .. tostring(dvalue) .. ",1028'"
maybe there is a malformed part in the url. What do you see when you go to the url in your browser?


The URL looks like standard ESPeasy PWM command. I dont know the H801 device but this is how I control my RGB/RGBW ledstrips:

https://www.twoenter.nl/blog/arduino-es ... -domoticz/

Written in dutch but you can translate with google.
Check my Domoticz tutorials, ESP8266 and Synology blog at https://www.twoenter.nl/blog
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest