Page 1 of 1

when should smart system take control over greenhouse?

Posted: Wednesday 30 September 2020 14:17
by abdolhamednik
hello everyone ;)

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 commandArray

i 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?

Re: when should smart system take control over greenhouse?

Posted: Wednesday 30 September 2020 15:17
by waaren
abdolhamednik wrote: Wednesday 30 September 2020 14:17 Error: EventSystem: commandArray in script xxx should only return ['string']='actionstring' or [integer]={['string']='actionstring'}
which i dont understand. can u plz help?
The error message tries to tell you that actionstring MUST be a string and you feed it a number.
Try this.

Code: Select all

commandArray = {}
Smart = tonumber(uservariables['Smart'])
---------------------------------------
if devicechanged['Bagno'] == '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'] = tostring(Smart)

return commandArray

Re: when should smart system take control over greenhouse?

Posted: Thursday 01 October 2020 21:27
by abdolhamednik
what a bad mistake
sorry :cry: