here is a code for greenhouse smart system to detect sth. there are 2 devices: 1 selector key, auto/man, and 1 phase controller, power3ph, on tableau. when both are open, smart system takes control over greenhouse. the script is a device type one
Smart is at first an integer 1
Code: Select all
commandArray = {}
Smart = tonumber(uservariables['Smart'])
---------------------------------------
if devicechanged['power3ph'] == 'Closed' then
Smart = 0
print("------3phase power fault-----")
commandArray[#commandArray + 1] = { ['alarm' ] = 'On' }
commandArray[#commandArray + 1] = { ['alarm' ] = 'Off AFTER ' .. 5 } --seconds
end
if devicechanged['auto/man'] == 'Closed' then
Smart = 0
print("------tablo manual -----")
end
if devicechanged['auto/man'] == 'Open' then
print("------tablo automatic OK-----")
if otherdevices['power3ph'] == 'Open' then Smart = 1 end
end
if devicechanged['power3ph'] == 'Open' then
print("------3phase power OK-----")
if otherdevices['auto/man'] == 'Open' then Smart = 1 end
end
---------------------------------------
commandArray['Variable:Smart'] = Smart
return commandArrayi have this error log:
Error: EventSystem: commandArray in script xxx should only return ['string']='actionstring' or [integer]={['string']='actionstring'}
which i dont understand. can u plz help?