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