I have a few Yeelight lamps and a cube. Idea is to execute commands on all lamps simultaniously. At the moment, I have a very small script, which only puts the lamps on and off.
Code: Select all
commandArray = {}
SwitchDevice = 'Xiaomi Cube weiss';
IP1 = '192.168.178.54';
IP2 = '192.168.178.50';
PORT = '55443'
if (devicechanged[SwitchDevice]=='clock_wise') then
runcommandoff1 = "sudo echo -ne '{\"id\":1,\"method\":\"set_power\", \"params\":[\"on\", \"smooth\", 500]}\\r\\n' | nc -w1 "..IP1.." " ..PORT.."";;
runcommandoff2 = "sudo echo -ne '{\"id\":1,\"method\":\"set_power\", \"params\":[\"on\", \"smooth\", 500]}\\r\\n' | nc -w1 "..IP2.." " ..PORT.."";;
os.execute(runcommandoff1);
os.execute(runcommandoff2);
elseif (devicechanged[SwitchDevice]=='anti_clock_wise') then
runcommandoff1 = "sudo echo -ne '{\"id\":1,\"method\":\"set_power\", \"params\":[\"off\", \"smooth\", 500]}\\r\\n' | nc -w1 "..IP1.." " ..PORT.."";;
runcommandoff2 = "sudo echo -ne '{\"id\":1,\"method\":\"set_power\", \"params\":[\"off\", \"smooth\", 500]}\\r\\n' | nc -w1 "..IP2.." " ..PORT.."";;
-- os.execute("runcommandoff1 | runcommandoff2");
os.execute(runcommandoff1);
os.execute(runcommandoff2);
end
return commandArray
I also tried to execute both commands at once
Code: Select all
os.execute("runcommandoff1 | runcommandoff2");