I have created LUA scripts for 2 Yeelight Bulbs RGBWW based on the "https://www.domoticz.com/wiki/Yeelight" page.
I used the Adding Scenes script example.
Both Yeelight LUA scripts appear to work however when I look in the Domoticz log page i see a lot of "red" messages:
2018-12-27 20:57:00.169 Error: EventSystem: in Eethoek Lamp: [string "--..."]:30: attempt to index global 'devicechanged' (a nil value)
2018-12-27 20:57:00.173 Error: EventSystem: in Hoek Lamp: [string "--..."]:30: attempt to index global 'devicechanged' (a nil value)
This the code example of "Hoek Lamp" where line 30 is "if devicechanged[DomDevice]=='Off' then -- turn off"
The other "Eethoek Lamp" has the exact same script only other IP with one extra scene added.
Code: Select all
commandArray = {}
DomDevice = 'Hoek Lamp';
IP = '192.168.2.57';
PORT = '55443'
if devicechanged[DomDevice]=='Off' then -- turn off
runcommandoff = "sudo echo -ne '{\"id\":1,\"method\":\"set_power\", \"params\":[\"off\", \"smooth\", 500]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";
os.execute(runcommandoff);
-- print(runcommandoff)
elseif devicechanged[DomDevice]=='Normaal' then -- turn to Normaal mode
runcommandnormaal = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"ct\", 2900, 2]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";
os.execute(runcommandnormaal);
-- print(runcommandnormaal)
elseif devicechanged[DomDevice]=='Groot' then -- turn to Groot mode
runcommandgroot = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"ct\", 3000, 100]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";
os.execute(runcommandgroot);
-- print(runcommandgroot)
end
return commandArray
Greetzzz,
Gerben