, tak tohle funguje...
Kód: Pre zobrazenie URL sa musíte prihlásiťcommandArray = {}
DomDevice = 'Scény obývák';
if devicechanged[DomDevice]=='Off' then -- turn off
runcommandoff = "sudo echo -ne '{\"id\":1,\"method\":\"set_power\", \"params\":[\"off\", \"smooth\", 500]}\\r\\n' | opt/bin/ncat -w1 192.168.0.124 55443";
os.execute(runcommandoff);
print(runcommandoff)
elseif devicechanged[DomDevice]=='On' then -- turn off
runcommandon = "sudo echo -ne '{\"id\":1,\"method\":\"set_power\", \"params\":[\"on\", \"smooth\", 500]}\\r\\n' | opt/bin/ncat -w1 192.168.0.124 55443";
os.execute(runcommandon);
print(runcommandon)
elseif devicechanged[DomDevice]=='Bright 25%' then -- turn to 25% bright
runcommand25 = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"bright\", 25, 500]}\\r\\n' | opt/bin/ncat -w1 192.168.0.124 55443";
os.execute(runcommand25);
print(runcommand25)
elseif devicechanged[DomDevice]=='Bright 50%' then -- turn to 50% bright
runcommand50 = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"bright\", 50, 500]}\\r\\n' | opt/bin/ncat -w1 192.168.0.124 55443";
os.execute(runcommand50);
print(runcommand50)
elseif devicechanged[DomDevice]=='Bright 75%' then -- turn to 75% bright
runcommand75 = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"bright\", 75, 500]}\\r\\n' | opt/bin/ncat -w1 192.168.0.124 55443";
os.execute(runcommand75);
print(runcommand75)
elseif devicechanged[DomDevice]=='Sunrise' then -- turn to sunrise mode from 0 to 100% on 15 minutes
runcommandsunrise = " sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"cf\",2,1,\"50,2,4000,1,900000,2,4000,100\"]}\\r\\n' | opt/bin/ncat -w1 192.168.0.124 55443";
os.execute(runcommandsunrise);
print(runcommandsunrise)
elseif devicechanged[DomDevice]=='Sunset' then -- turn to sunset mode from 100% to 0 on 15 minutes and turn off bulb
runcommandsunset = " sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"cf\",2,2,\"50,2,4000,75,900000,2,4000,1\"]}\\r\\n' | opt/bin/ncat -w1 192.168.0.124 55443";
os.execute(runcommandsunset);
print(runcommandsunset)
elseif devicechanged[DomDevice]=='4-7-8' then -- turn to 4-7-8 mode
runcommand478 = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"cf_\",24,2,\"4000,2,4000,30,7000,2,4000,10,8000,2,4000,1\"]}\\r\\n' | opt/bin/ncat -w1 192.168.0.124 55443";
os.execute(runcommand478);
print(runcommand478)
elseif devicechanged[DomDevice]=='Baby' then -- turn to Baby Mode
runcommandbaby = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"bright\", 1, 500]}\\r\\n' | opt/bin/ncat -w1 192.168.0.124 55443";
os.execute(runcommandbaby);
print(runcommandbaby)
end
return commandArray