Documentation

Python Events

Events flow from a PD to a CP. In Python an event is a plain dict. Every event dict carries an event key set to an Event value; the remaining keys depend on that event.

A PD sends an event with PeripheralDevice.notify_event(event); a CP receives the same dict from ControlPanel.get_event(address) or its event handler.

from osdp import Event, CardFormat

pd.notify_event({
    'event': Event.CardRead,
    'reader_no': 1,
    'direction': 1,
    'format': CardFormat.ASCII,
    'data': bytes([9, 1, 9, 2, 6, 3, 1, 7, 7, 0]),
})

The keys below match the C Event Structure.

Card Read — Event.CardRead

A card was presented at a reader.

KeyTypeNotes
reader_nointReader that read the card.
formatCardFormatCard data format.
directionint0 for forward, 1 for reverse.
databytesCard data.
lengthintOnly for Wiegand/Unspecified formats — data length in bits. For other formats the length is taken from len(data).

For raw Wiegand or unspecified formats, data holds the bits packed into bytes and length gives the exact bit count; otherwise omit length.

Key Press — Event.KeyPress

Keypad input.

KeyTypeNotes
reader_nointReader that captured the keys.
databytesKey codes.

Manufacturer Reply — Event.ManufacturerReply

A vendor-specific reply.

KeyTypeNotes
vendor_codeintIEEE-assigned vendor code.
databytesVendor-defined payload.

Status — Event.Status

An (un)solicited status report.

KeyTypeNotes
typeStatusReportTypeReport type.
reportbytesOne status byte per entry.

Notification — Event.Notification

Emitted when the LibFlag.EnableNotification flag is set.

KeyTypeNotes
typeintNotification type.
arg0intType-specific argument.
arg1intType-specific argument.