Page 1 of 1

Cant get 'and' statement and colour to work

Posted: Wednesday 18 November 2015 20:34
by void
Hi,

With the great help of jbreed I've created the following LUA scripts:

Working

Turning off the alarm (security panel disarm) when either one of both phones is connected to wireless and send confirmation to Telegram via bash script:

Code: Select all

commandArray = {}

if (devicechanged['Phone1'] == 'On') or (devicechanged['Phone2'] == 'On') then
        print('<b style="color:Blue"> Trusted phone connected to wireless, disabling alarm.</b>')
        commandArray['SecPanel'] = 'Disarm'
        os.execute("bash /home/pi/scripts/alarmoff.sh")
end
return commandArray
NOT working
Arming the security panel when nobody is home and send an Telegram message to me to confirm via bash script:

Code: Select all

[/commandArray = {}

if (devicechanged['Phone1'] == 'Off') and (otherdevice['Phone2'] == 'Off') then
        print('<b style="color:Blue"> No trusted phones connected to wireless, enabling alarm and turning off light s.</b>')
        commandArray['SecPanel'] = 'Arm Away'
        commandArray['Group:AllLights'] = 'Off'
        os.execute("bash /home/pi/scripts/alarmon.sh")
end
return commandArray
For some reason the 'otherdevice' is being parsed as nil:
Error: EventSystem: /home/pi/domoticz/scripts/lua/script_device_Arm.lua:3: attempt to index global 'otherdevice' (a nil value)

When I keep it 'devicechanged' at both phones, no reaction/trigger is being met and the script wont fire.

Secondly, but I care less about it, the b style tags dont work, text just appears black in the log instead of blue.
The tags are not parsed but put in the log, literaly.

What am I doing wrong here?

Re: Cant get 'and' statement and colour to work

Posted: Wednesday 18 November 2015 20:48
by jvdz
That should be otherdevices(). ;)

This should test when one of the phones changed, whether they both are gone and switch on the alarm.

Code: Select all

commandArray = {}

if (devicechanged['Phone1'] == 'Off') or (devicechanged['Phone2'] == 'Off') then
   if (otherdevices['Phone1'] == 'Off') and (otherdevices['Phone2'] == 'Off') then
        print('<b style="color:Blue"> No trusted phones connected to wireless, enabling alarm and turning off light s.</b>')
        commandArray['SecPanel'] = 'Arm Away'
        commandArray['Group:AllLights'] = 'Off'
        os.execute("bash /home/pi/scripts/alarmon.sh")
   end
end
return commandArray
Jos

Re: Cant get 'and' statement and colour to work

Posted: Wednesday 18 November 2015 20:54
by void
Jup that worked! Thanks a lot!

Do you happen to know the colour issue as well, while we're at it :)