Cant get 'and' statement and colour to work

Moderator: leecollings

Post Reply
void
Posts: 26
Joined: Wednesday 04 November 2015 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Cant get 'and' statement and colour to work

Post 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?
User avatar
jvdz
Posts: 2332
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

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

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
void
Posts: 26
Joined: Wednesday 04 November 2015 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by void »

Jup that worked! Thanks a lot!

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

Who is online

Users browsing this forum: No registered users and 1 guest