running Domoticz on my Synology for quite some time now. I'm using Jumbotroll his compiled package.
I wanted to try a lua script found here https://gathering.tweakers.net/forum/li ... 9#47264699, but i can't manage to get it working.
I recreated this with my own switches etc, and enabled a variable integer with value 0 named "Schemer_licht_aan". I also have the switches 'IemandThuis', 'State - IsDonker' and 'Vakantietimer' available. They are on/off switches..
Code: Select all
local presence_switch = 'IemandThuis'
local isdark_switch = 'State - IsDonker'
local Vakantie_timer = 'Vakantietimer'
vSchemer_licht_aan = tonumber(uservariables['Schemer_licht_aan'])
function sleep(n)
os.execute("sleep " .. tonumber(n))
end
commandArray = {}
if devicechanged[isdark_switch] then
if (otherdevices[isdark_switch] == 'Off' and otherdevices['Zon op-onder'] == 'Off' and vSchemer_licht_aan >= 1) then
commandArray['Group:Huiskamer']='Off'
commandArray['Group:Huiskamer']='Off' AFTER 15
commandArray['Vakantietimer']= 'Off'
commandArray['Variable:Schemer_licht_aan'] = tostring(0)
print('<font color="blue">LICHT - Het is licht geworden - Alle lampen uit!!</font>')
elseif (otherdevices[presence_switch] == 'On' and otherdevices['Vakantie'] == 'Off' and otherdevices[isdark_switch] == 'On' and vSchemer_licht_aan == 0) then
commandArray['Vakantietimer']= 'On'
commandArray['Group:Huiskamer']='On'
commandArray['Group:Huiskamer']='On AFTER 10'
commandArray['Variable:Schemer_licht_aan'] = tostring(1)
print('<font color="blue">THUIS - Het is donker en er is iemand Thuis - Lichten gaan aan!!</font>')
elseif (otherdevices[presence_switch] == 'Off' and otherdevices['Vakantie'] == 'Off' and otherdevices[isdark_switch] == 'On' and vSchemer_licht_aan == 0) then
commandArray['Vakantietimer']= 'On'
commandArray['Scene:Sfeertje']= 'On'
commandArray['Scene:Sfeertje']= 'On' AFTER 10
commandArray['TV kijken']='On'
commandArray['Variable:Schemer_licht_aan'] = tostring(2)
print('<font color="blue">NIET-THUIS - Er is niemand Thuis - Het is donker - Sfeerlicht gaat aan!!</font>')
elseif (otherdevices['Vakantie'] == 'On' and otherdevices[isdark_switch] == 'On' and vSchemer_licht_aan == 0) then
commandArray['Vakantietimer']= 'On'
commandArray['Scene:Sfeertje']= 'On'
commandArray['Scene:Sfeertje']= 'On' AFTER 10
commandArray['TV kijken']='On'
commandArray['Slaapkamer bedlamp']='On'
commandArray['Slaapkamer bedlamp']='On' AFTER 10
commandArray['Variable:Schemer_licht_aan'] = tostring(2)
print('<font color="blue">VAKANTIEMODE - Er is niemand Thuis - Het is donker - Licht beneden & boven gaan aan -- TV gaat aan!!</font>')
end
end
if devicechanged[presence_switch] then
if (otherdevices[presence_switch] == 'Off' and otherdevices['Vakantie'] == 'Off' and otherdevices[isdark_switch] == 'On' and vSchemer_licht_aan == 1) then
commandArray['Vakantietimer']= 'On'
commandArray['Scene:Sfeertje']= 'On'
commandArray['PowerOff']='On'
commandArray['Variable:Schemer_licht_aan'] = tostring(2)
print('<font color="blue">WEGGAAN - De laatste persoon heeft heeft het huis verlaten- Het is donker - Sfeerlicht gaat aan !!</font>')
elseif (otherdevices[presence_switch] == 'On' and otherdevices['Vakantie'] == 'Off' and otherdevices[isdark_switch] == 'On' and vSchemer_licht_aan == 2) then
commandArray['Vakantietimer']= 'On'
commandArray['Group:Huiskamer']='On'
commandArray['Group:Huiskamer']='On' AFTER 10
commandArray['Variable:Schemer_licht_aan'] = tostring(1)
print('<font color="blue">THUISKOMEN - Het is donker en er komt iemand thuis - Lichten gaan aan!!</font>')
end
end
if devicechanged[Vakantie_timer] then
if (otherdevices['Vakantietimer'] == 'Off' and otherdevices['Vakantie'] == 'On' and otherdevices[isdark_switch] == 'On' and vSchemer_licht_aan == 2) then
commandArray['Group:Huiskamer']='Off'
commandArray['Group:Huiskamer']='Off' AFTER 15
commandArray['PowerOff']='On'
commandArray['Slaapkamer bedlamp']='Off'
commandArray['Slaapkamer bedlamp']='Off' AFTER 10
commandArray['Variable:Schemer_licht_aan'] = tostring(1)
print('<font color="blue">VAKANTIEMODE - Er is niemand Thuis - Slaapstand actief - Alle lichten gaan uit!!</font>')
end
end
return commandArray
Code: Select all
2016-06-27 20:52:01.862 Error: EventSystem: in script_device_verlichting: [string "local presence_switch = 'IemandThuis' ..."]:17: syntax error near '15'
I can't seem to fix this problem. When I change the local switches for the real name switches the error seems so change to
Code: Select all
2016-06-27 20:58:32.243 Error: EventSystem: in script_device_test2: [string "vSchemer_licht_aan = tonumber(uservariables['..."]:12: syntax error near '15'
Thanks in advance