First of all, thanks a lot to Kevin and Scott for your prompt responses in the past, really helped me, I have almost setup the system I wanted with AD2PI and Vista 10SE. Currently I am using WEBIOPI with AlarmDecoder libraries. In the main script, I am trying to open the SerialDevice, setup some events/event handlers like on_arm etc and expose some WEBIOPI macros in the same script to remotely arm/disarm the system. Event handlers are just sending out the notifications via email. What is happening is, I am able to read from the panel via on_message before I arm/disarm the panel via send method. Once I use send, no more events are getting called. As if reading, writing and then reading from the panel, some issue going on, which I am trying to diagnose. Question for you guys is, is the setup correct? Anything wrong with the approach? Here is the short snippet of code:
- Code: Select all
import webiopi
from alarmdecoder import AlarmDecoder
from alarmdecoder.devices import SerialDevice
# Configuration values
ARM_STAY = <STAY_CODE>
ARM_AWAY = <AWAY_CODE>
DISARM = <DISARM_CODE>
SERIAL_DEVICE = '/dev/ttyAMA0'
BAUDRATE='115200'
SUBJECT = "Home Security Alarm Notification"
FROM_ADDRESS = "chiragdua1977@gmail.com"
TO_ADDRESS = "chiragdua1977@gmail.com"
SMTP_SERVER = "smtp.gmail.com:587"
SMTP_USERNAME = <USERNAME>
SMTP_PASSWORD = <PASSWORD>
device = AlarmDecoder(SerialDevice(interface=SERIAL_DEVICE))
def setup():
global device
device.on_arm += handle_arm
device.on_disarm += handle_disarm
device.on_power_changed += handle_power_changed
device.on_alarm += handle_alarm
device.on_low_battery += handle_low_battery
device.open(BAUDRATE)
def destroy():
global device
device.close()
@webiopi.macro
def armInStayMode():
global device
device.send(ARM_STAY)
return 'System successfully armed in stay mode.'
@webiopi.macro
def armInAwayMode():
global device
device.send(ARM_AWAY)
return 'System successfully armed in away mode.'
@webiopi.macro
def disarm():
global device
device.send(DISARM)
return 'System successfully disarmed.'
def handle_message(sender, message):
print message
def handle_arm(sender):
content = 'System Armed'
send_notification(content)
---------------------------Rest of the methods--------------------