when should smart system take control over greenhouse? Topic is solved

Moderator: leecollings

Post Reply
User avatar
abdolhamednik
Posts: 39
Joined: Sunday 27 September 2020 7:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Contact:

when should smart system take control over greenhouse?

Post 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?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: when should smart system take control over greenhouse?

Post 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
abdolhamednik
Posts: 39
Joined: Sunday 27 September 2020 7:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Contact:

Re: when should smart system take control over greenhouse?

Post by abdolhamednik »

what a bad mistake
sorry :cry:
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest