I am trying to make a script to control the public lights at the soccerclub. I have an Owl device watching the energy comsuption, and when it exceeds the limit of 15 kW the public lights should turn off.
But after searching the forums and trying lots of possibilities, my scripts will not work. And I cannot figure out why not.
Is the someone out there, who will help me with the script I made so far.
The print-command is execuded good, but the switch 'Multi' will not act.
Code: Select all
--script Veldverlichting aan dan straatverlichting uit
commandArray = {}
c = 15000 --Watt treshold energy usage
s = otherdevices_svalues['Veld/straatverlichting'] -- gets value from owl energy device monitoring veldverlichting
function five() -- function to get only usage from string
local f = (string.sub(s, 1, 5))
return f
end
k = five(f)
if (devicechanged['Veld/straatverlichting'] and tonumber(k) > c) then -- triggers compare two numbers
commandArray['Multi 1'] = 'off' -- switches straatverlichting off
print("straatverlichting uit") -- prints status
end
return commandArray