Skip to content

Example to make a color loop effect

Smanar edited this page Jul 28, 2019 · 3 revisions

This feature don't work for all bulbs, for exemple Ikea ones don't support it. You can too create a scenes to use it but in this exemple, I will use a LUA script.

First create a virtual sensor type switch on/off called 'colorloop'

Then use this LUA script

-- Color loop test

commandArray = {}

function SendJson(url,json)
	local curl = "/usr/bin/curl"
	local cmd = curl .. ' -X PUT -d '..json..' '..url
	local vac = os.execute(cmd)
	if vac ~= true then
		print('Send JSON Error')
	end
end

--color loop switch
if devicechanged['colorloop'] then
    if devicechanged['colorloop'] == 'On' then
        print('Start colorloop')
        SendJson('http://192.168.X.X/api/YYYYYYYY/lights/50/state','\'{"effect":"colorloop","on":true}\'')
    else
        print('Stop colorloop')
        SendJson('http://192.168.X.X/api/YYYYYYYY/lights/50/state','\'{"effect":"15","on":false}\'')
    end
end

return commandArray

Don't forget, to edit the IP adress, your API key, and the device id (50 in this example).

You can too specify change speed with adding in json : "colorloopspeed":255

Specifies the speed of a colorloop. 1 = very fast, 255 = very slow (default: 15). This parameter only has an effect when it is called together with effect colorloop.