Browse Source

Better way of doing handling fire events.

pyserial_fix
Scott Petersen 11 years ago
parent
commit
2bafee0ebd
2 changed files with 2 additions and 16 deletions
  1. +1
    -15
      pyad2usb/ad2usb.py
  2. +1
    -1
      pyad2usb/messages.py

+ 1
- 15
pyad2usb/ad2usb.py View File

@@ -484,26 +484,12 @@ class AD2USB(object):
else:
self.on_disarm()

# Battery status toggle. This is kinda ugly.. may be a better way to do it.
if message.battery_low != self._battery_status[0]:
if time.time() > self._battery_status[1] + AD2USB.BATTERY_TIMEOUT:
self._battery_status, self._previous_battery_status = (message.battery_low, time.time()), self._battery_status

self.on_low_battery(self._battery_status)

else:
self._previous_battery_status = self._battery_status

else:
if self._battery_status[0] == self._previous_battery_status[0]:
self._battery_status = (self._battery_status[0], time.time())

if message.battery_low == self._battery_status[0]:
self._battery_status = (self._battery_status[0], time.time())
else:
if message.battery_low == True or time.time() > self._battery_status[1] + AD2USB.BATTERY_TIMEOUT:
self._battery_status = (message.battery_low, time.time())
self.on_fire(self._battery_status)
self.on_low_battery(self._battery_status)

if message.fire_alarm == self._fire_status[0]:
self._fire_status = (self._fire_status[0], time.time())


+ 1
- 1
pyad2usb/messages.py View File

@@ -62,7 +62,7 @@ class Message(object):
self.bitfield, self.numeric_code, self.panel_data, alpha = m.group(1, 2, 3, 4)
self.mask = int(self.panel_data[3:3+8], 16)

self.data = data
self.raw = data
self.ready = not self.bitfield[1:2] == "0"
self.armed_away = not self.bitfield[2:3] == "0"
self.armed_home = not self.bitfield[3:4] == "0"


Loading…
Cancel
Save