alarmdecoder Package

alarmdecoder Module

devices Module

Contains different types of devices belonging to the Alarm Decoder (AD2) family.

class alarmdecoder.devices.Device[source]

Bases: object

Generic parent device to all Alarm Decoder (AD2) products.

on_open

Called when the device has been opened

on_close

Called when the device has been closed

on_read

Called when a line has been read from the device

on_write

Called when data has been written to the device

id[source]

Retrieve the device ID.

Returns:The identification string for the device.
is_reader_alive()[source]

Indicates whether or not the reader thread is alive.

Returns:Whether or not the reader thread is alive.
stop_reader()[source]

Stops the reader thread.

close()[source]

Closes the device.

class ReadThread(device)[source]

Bases: threading.Thread

Reader thread which processes messages from the device.

READ_TIMEOUT = 10

Timeout for the reader thread.

stop()[source]

Stops the running thread.

run()[source]

The actual read process.

class alarmdecoder.devices.USBDevice(interface=0)[source]

Bases: alarmdecoder.devices.Device

AD2USB device exposed with PyFTDI’s interface.

FTDI_VENDOR_ID = 1027

Vendor ID used to recognize AD2USB devices.

FTDI_PRODUCT_ID = 24577

Product ID used to recognize AD2USB devices.

BAUDRATE = 115200

Default baudrate for AD2USB devices.

classmethod find_all(vid=1027, pid=24577)[source]

Returns all FTDI devices matching our vendor and product IDs.

Returns:list of devices
Raises :CommError
classmethod devices()[source]

Returns a cached list of AD2USB devices located on the system.

Returns:cached list of devices found.
classmethod find(device=None)[source]

Factory method that returns the requested USBDevice device, or the first device.

Parameters:device (tuple) – Tuple describing the USB device to open, as returned by find_all().
Returns:USBDevice object utilizing the specified device.
Raises :NoDeviceError
classmethod start_detection(on_attached=None, on_detached=None)[source]

Starts the device detection thread.

Parameters:
  • on_attached (function) – function to be called when a device is attached.
  • on_detached (function) – function to be called when a device is detached.
classmethod stop_detection()[source]

Stops the device detection thread.

serial_number[source]

Retrieves the serial number of the device.

Returns:The serial number of the device.
description[source]

Retrieves the description of the device.

Returns:The description of the device.
interface[source]

Retrieves the interface used to connect to the device.

Returns:the interface used to connect to the device.
open(baudrate=115200, no_reader_thread=False)[source]

Opens the device.

Parameters:
  • baudrate (int) – The baudrate to use.
  • no_reader_thread (bool) – Whether or not to automatically start the reader thread.
Raises :

NoDeviceError

close()[source]

Closes the device.

write(data)[source]

Writes data to the device.

Parameters:data (str) – Data to write
Raises :CommError
read()[source]

Reads a single character from the device.

Returns:The character read from the device.
Raises :CommError
read_line(timeout=0.0, purge_buffer=False)[source]

Reads a line from the device.

Parameters:
  • timeout (float) – Read timeout
  • purge_buffer (bool) – Indicates whether to purge the buffer prior to reading.
Returns:

The line that was read.

Raises :

CommError, TimeoutError

class DetectThread(on_attached=None, on_detached=None)[source]

Bases: threading.Thread

Thread that handles detection of added/removed devices.

on_attached

Called when an AD2USB device has been detected.

on_detached

Called when an AD2USB device has been removed.

stop()[source]

Stops the thread.

run()[source]

The actual detection process.

class alarmdecoder.devices.SerialDevice(interface=None)[source]

Bases: alarmdecoder.devices.Device

AD2USB or AD2SERIAL device exposed with the pyserial interface.

BAUDRATE = 19200

Default baudrate for Serial devices.

static find_all(pattern=None)[source]

Returns all serial ports present.

Parameters:pattern (str) – Pattern to search for when retrieving serial ports.
Returns:list of devices
Raises :CommError
interface[source]

Retrieves the interface used to connect to the device.

Returns:the interface used to connect to the device.
open(baudrate=19200, no_reader_thread=False)[source]

Opens the device.

Parameters:
  • baudrate (int) – The baudrate to use with the device.
  • no_reader_thread (bool) – Whether or not to automatically start the reader thread.
Raises :

NoDeviceError

close()[source]

Closes the device.

write(data)[source]

Writes data to the device.

Parameters:data (str) – The data to write.
Raises :CommError
read()[source]

Reads a single character from the device.

Returns:The character read from the device.
Raises :CommError
read_line(timeout=0.0, purge_buffer=False)[source]

Reads a line from the device.

Parameters:
  • timeout (float) – The read timeout.
  • purge_buffer (bool) – Indicates whether to purge the buffer prior to reading.
Returns:

The line read.

Raises :

CommError, TimeoutError

class alarmdecoder.devices.SocketDevice(interface=('localhost', 10000))[source]

Bases: alarmdecoder.devices.Device

Device that supports communication with an Alarm Decoder (AD2) that is exposed via ser2sock or another Serial to IP interface.

interface[source]

Retrieves the interface used to connect to the device.

Returns:the interface used to connect to the device.
ssl[source]

Retrieves whether or not the device is using SSL.

Returns:Whether or not the device is using SSL.
ssl_certificate[source]

Retrieves the SSL client certificate path used for authentication.

Returns:The certificate path
ssl_key[source]

Retrieves the SSL client certificate key used for authentication.

Returns:The key path
ssl_ca[source]

Retrieves the SSL Certificate Authority certificate used for authentication.

Returns:The CA path
open(baudrate=None, no_reader_thread=False)[source]

Opens the device.

Parameters:
  • baudrate (int) – The baudrate to use
  • no_reader_thread (bool) – Whether or not to automatically open the reader thread.
Raises :

NoDeviceError, CommError

close()[source]

Closes the device.

write(data)[source]

Writes data to the device.

Parameters:data (str) – The data to write.
Returns:The number of bytes sent.
Raises :CommError
read()[source]

Reads a single character from the device.

Returns:The character read from the device.
Raises :CommError
read_line(timeout=0.0, purge_buffer=False)[source]

Reads a line from the device.

Parameters:
  • timeout (float) – The read timeout.
  • purge_buffer (bool) – Indicates whether to purge the buffer prior to reading.
Returns:

The line read from the device.

Raises :

CommError, TimeoutError

util Module

Provides utility classes for the Alarm Decoder (AD2) devices.

exception alarmdecoder.util.NoDeviceError[source]

Bases: exceptions.Exception

No devices found.

exception alarmdecoder.util.CommError[source]

Bases: exceptions.Exception

There was an error communicating with the device.

exception alarmdecoder.util.TimeoutError[source]

Bases: exceptions.Exception

There was a timeout while trying to communicate with the device.

exception alarmdecoder.util.InvalidMessageError[source]

Bases: exceptions.Exception

The format of the panel message was invalid.

class alarmdecoder.util.Firmware[source]

Bases: object

Represents firmware for the Alarm Decoder devices.

STAGE_START = 0
STAGE_WAITING = 1
STAGE_BOOT = 2
STAGE_LOAD = 3
STAGE_UPLOADING = 4
STAGE_DONE = 5
static upload(dev, filename, progress_callback=None)[source]

Uploads firmware to an Alarm Decoder device.

Parameters:
  • filename (str) – The firmware filename
  • progress_callback (function) – Callback function used to report progress.
Raises :

NoDeviceError, TimeoutError

zonetracking Module

Provides zone tracking functionality for the Alarm Decoder (AD2) device family.

class alarmdecoder.zonetracking.Zone(zone=0, name='', status=0)[source]

Bases: object

Representation of a panel zone.

CLEAR = 0

Status indicating that the zone is cleared.

FAULT = 1

Status indicating that the zone is faulted.

CHECK = 2

Status indicating that there is a wiring issue with the zone.

STATUS = {0: 'CLEAR', 1: 'FAULT', 2: 'CHECK'}
class alarmdecoder.zonetracking.Zonetracker[source]

Bases: object

Handles tracking of zone and their statuses.

on_fault

Called when the device detects a zone fault.

on_restore

Called when the device detects that a fault is restored.

EXPIRE = 30

Zone expiration timeout.

update(message)[source]

Update zone statuses based on the current message.

Parameters:message (Message or ExpanderMessage) – Message to use to update the zone tracking.

panels Module

Representations of Panels and their templates.

messages Module

Message representations received from the panel through the Alarm Decoder (AD2) devices.

class alarmdecoder.messages.BaseMessage[source]

Bases: object

Base class for messages.

raw = None

The raw message text

class alarmdecoder.messages.Message(data=None)[source]

Bases: alarmdecoder.messages.BaseMessage

Represents a message from the alarm panel.

ready = False

Indicates whether or not the panel is in a ready state

armed_away = False

Indicates whether or not the panel is armed away

armed_home = False

Indicates whether or not the panel is armed home

backlight_on = False

Indicates whether or not the keypad backlight is on

programming_mode = False

Indicates whether or not we’re in programming mode

beeps = -1

Number of beeps associated with a message

zone_bypassed = False

Indicates whether or not a zone is bypassed

ac_power = False

Indicates whether or not the panel is on AC power

chime_on = False

Indicates whether or not the chime is enabled

alarm_event_occurred = False

Indicates whether or not an alarm event has occurred

alarm_sounding = False

Indicates whether or not an alarm is sounding

battery_low = False

Indicates whether or not there is a low battery

entry_delay_off = False

Indicates whether or not the entry delay is enabled

fire_alarm = False

Indicates whether or not a fire alarm is sounding

check_zone = False

Indicates whether or not there are zones that require attention.

perimeter_only = False

Indicates whether or not the perimeter is armed

numeric_code = None

The numeric code associated with the message

text = None

The human-readable text to be displayed on the panel LCD

cursor_location = -1

Current cursor location on the keypad

mask = None

Address mask this message is intended for

bitfield = None

The bitfield associated with this message

panel_data = None

The panel data field associated with this message

class alarmdecoder.messages.ExpanderMessage(data=None)[source]

Bases: alarmdecoder.messages.BaseMessage

Represents a message from a zone or relay expansion module.

ZONE = 0

Flag indicating that the expander message relates to a Zone Expander.

RELAY = 1

Flag indicating that the expander message relates to a Relay Expander.

type = None

Expander message type: ExpanderMessage.ZONE or ExpanderMessage.RELAY

address = -1

Address of expander

channel = -1

Channel on the expander

value = -1

Value associated with the message

class alarmdecoder.messages.RFMessage(data=None)[source]

Bases: alarmdecoder.messages.BaseMessage

Represents a message from an RF receiver.

x = 3
serial_number = None

Serial number of the RF device

value = -1

Value associated with this message

battery = False

Battery low indication

supervision = False

Supervision required indication

loop = [False, False, False, False]

Loop indicators

class alarmdecoder.messages.LRRMessage(data=None)[source]

Bases: alarmdecoder.messages.BaseMessage

Represent a message from a Long Range Radio.

event_data = None

Data associated with the LRR message. Usually user ID or zone.

partition = -1

The partition that this message applies to

event_type = None

The type of the event that occurred

Table Of Contents

Previous topic

Welcome to alarmdecoder’s documentation!

Next topic

event Package

This Page