Skip to content

pydmp

PyDMP - Python library for controlling DMP alarm systems.

Platform-agnostic library for interfacing with DMP (Digital Monitoring Products) alarm panels via TCP/IP.

Example (Async): >>> import asyncio >>> from pydmp import DMPPanel >>> >>> async def main(): ... panel = DMPPanel() ... await panel.connect("192.168.1.100", "00001", "YOUR_KEY") ... areas = await panel.get_areas() ... await areas[0].arm() ... await panel.disconnect() >>> >>> asyncio.run(main())

Example (Sync): >>> from pydmp import DMPPanelSync >>> >>> panel = DMPPanelSync() >>> panel.connect("192.168.1.100", "00001", "YOUR_KEY") >>> areas = panel.get_areas() >>> areas[0].arm_sync() >>> panel.disconnect()

pydmp.panel_sync

High-level synchronous panel controller.

DMPPanelSync Objects

class DMPPanelSync()

High-level synchronous interface to DMP panel.

__init__

def __init__(port: int = DEFAULT_PORT, timeout: float = 10.0)

Initialize sync panel.

Arguments:

  • port - TCP port (default: 2011)
  • timeout - Connection timeout in seconds

is_connected

@property
def is_connected() -> bool

Check if connected to panel.

connect

def connect(host: str, account: str, remote_key: str) -> None

Connect to panel and authenticate.

Arguments:

  • host - Panel IP address or hostname
  • account - 5-digit account number
  • remote_key - Remote key for authentication

disconnect

def disconnect() -> None

Disconnect from panel.

update_status

def update_status() -> None

Update status of all areas and zones from panel.

get_areas

def get_areas() -> list[AreaSync]

Get all areas.

Returns:

List of AreaSync objects

get_area

def get_area(number: int) -> AreaSync

Get specific area by number.

Arguments:

  • number - Area number (1-8)

Returns:

AreaSync object

get_zones

def get_zones() -> list[ZoneSync]

Get all zones.

Returns:

List of ZoneSync objects

get_zone

def get_zone(number: int) -> ZoneSync

Get specific zone by number.

Arguments:

  • number - Zone number (1-999)

Returns:

ZoneSync object

get_outputs

def get_outputs() -> list[OutputSync]

Get all outputs.

Returns:

List of OutputSync objects

get_output

def get_output(number: int) -> OutputSync

Get specific output by number.

Arguments:

  • number - Output number (1-4)

Returns:

OutputSync object

__enter__

def __enter__() -> "DMPPanelSync"

Context manager entry.

__exit__

def __exit__(*args: Any) -> None

Context manager exit.

__repr__

def __repr__() -> str

String representation.

pydmp.exceptions

Exceptions for PyDMP.

DMPError Objects

class DMPError(Exception)

Base exception for DMP errors.

DMPConnectionError Objects

class DMPConnectionError(DMPError)

Connection-related errors.

DMPAuthenticationError Objects

class DMPAuthenticationError(DMPConnectionError)

Authentication failed.

DMPTimeoutError Objects

class DMPTimeoutError(DMPConnectionError)

Operation timed out.

DMPProtocolError Objects

class DMPProtocolError(DMPError)

Protocol-level errors.

DMPInvalidResponseError Objects

class DMPInvalidResponseError(DMPProtocolError)

Invalid or unexpected response from panel.

DMPCommandError Objects

class DMPCommandError(DMPError)

Command execution errors.

DMPCommandNAKError Objects

class DMPCommandNAKError(DMPCommandError)

Command was rejected by panel (NAK response).

DMPInvalidParameterError Objects

class DMPInvalidParameterError(DMPError)

Invalid parameter provided.

DMPAreaError Objects

class DMPAreaError(DMPError)

Area-related errors.

DMPZoneError Objects

class DMPZoneError(DMPError)

Zone-related errors.

DMPOutputError Objects

class DMPOutputError(DMPError)

Output-related errors.

pydmp.user

UserCode Objects

@dataclass
class UserCode()

Decrypted user code record.

code

secret: excluded from repr

pin

secret: excluded from repr

temp_date

legacy 6-digit field; same as end_date (DDMMYY)

exp_date

legacy 4-char field; often '----' on observed panels

start_date

6 digits DDMMYY; start of access

end_date

6 digits DDMMYY; end of access

flags

3 chars (e.g., 'YNN')

active

First Y/N flag: user active

temporary

Third Y/N flag: temporary user

pydmp.transport_sync

Synchronous wrapper for DMP transport + protocol (bytes + codec).

DMPTransportSync Objects

class DMPTransportSync()

Synchronous wrapper combining DMPTransport and DMPProtocol.

__init__

def __init__(host: str,
             account: str,
             remote_key: str,
             port: int = DEFAULT_PORT,
             timeout: float = 10.0)

Initialize sync transport.

connect

def connect() -> None

Establish connection and authenticate.

disconnect

def disconnect() -> None

Disconnect gracefully.

send_command

def send_command(
    command: str,
    encrypt_user_code: bool = False,
    user_code: str | None = None,
    **kwargs: Any
) -> str | StatusResponse | UserCodesResponse | UserProfilesResponse | OutputsResponse | None

Send a protocol command and return decoded response.

pydmp.panel

High-level async panel controller.

DMPPanel Objects

class DMPPanel()

High-level async interface to DMP panel.

__init__

def __init__(port: int = DEFAULT_PORT, timeout: float = 10.0)

Initialize panel.

Arguments:

  • port - TCP port (default: 2011)
  • timeout - Connection timeout in seconds

is_connected

@property
def is_connected() -> bool

Check if connected to panel.

connect

async def connect(host: str, account: str, remote_key: str) -> None

Connect to panel and authenticate.

Arguments:

  • host - Panel IP address or hostname
  • account - 5-digit account number
  • remote_key - Remote key for authentication

Raises:

  • DMPConnectionError - If connection fails

disconnect

async def disconnect() -> None

Disconnect from panel.

Always releases the active-connection registration and clears state, even when the transport has already dropped, so a later connect() can succeed.

update_status

async def update_status() -> None

Update status of all areas and zones from panel.

Raises:

  • DMPConnectionError - If not connected or update fails

get_areas

async def get_areas() -> list[Area]

Get all areas.

Returns:

List of Area objects

Raises:

  • DMPConnectionError - If not connected

get_area

async def get_area(number: int) -> Area

Get specific area by number.

Arguments:

  • number - Area number (1-8)

Returns:

Area object

Raises:

  • DMPConnectionError - If not connected
  • KeyError - If area not found

get_zones

async def get_zones() -> list[Zone]

Get all zones.

Returns:

List of Zone objects

Raises:

  • DMPConnectionError - If not connected

get_zone

async def get_zone(number: int) -> Zone

Get specific zone by number.

Arguments:

  • number - Zone number (1-999)

Returns:

Zone object

Raises:

  • DMPConnectionError - If not connected
  • KeyError - If zone not found

get_outputs

async def get_outputs() -> list[Output]

Get all outputs.

Note: Outputs are created on-demand; prefer calling update_output_status() first to populate real states from the panel.

Returns:

List of Output objects

get_output

async def get_output(number: int) -> Output

Get specific output by number.

Arguments:

  • number - Output number (1-999)

Returns:

Output object

Raises:

  • KeyError - If output number invalid

update_output_status

async def update_output_status() -> None

Fetch output status from panel (*WQ) and update known outputs.

The panel returns a stream of output entries in frames. We request the initial page for output 001, then continue with '?WQ' a few times to collect subsequent chunks.

Note: Many residential installations only use outputs 1-4.

sensor_reset

async def sensor_reset() -> None

Send sensor reset command to the panel (!E001).

get_user_codes

async def get_user_codes() -> list[UserCode]

Retrieve all user codes from the panel (decrypting entries).

get_user_profiles

async def get_user_profiles() -> list[UserProfile]

Retrieve all user profiles from the panel.

check_code

async def check_code(code: str,
                     *,
                     include_pin: bool = True,
                     refresh_if_missing: bool = True) -> UserCode | None

Check if a user code (or PIN) exists in the panel.

Arguments:

  • code - The code/PIN string to validate
  • include_pin - If True, also match against PIN codes
  • refresh_if_missing - If True, refresh cache on miss and retry once

Returns:

Matching UserCode or None if not found

attach_status_server

def attach_status_server(server: Any) -> None

Attach a DMPStatusServer to auto-refresh user cache on Zu events.

When the server receives a User Codes (Zu) event, the panel will refresh its user cache in the background. Call detach_status_server to remove.

detach_status_server

def detach_status_server(server: Any) -> None

Detach a previously attached DMPStatusServer.

start_keepalive

async def start_keepalive(interval: float = 10.0) -> None

Start periodic keep-alive (!H) while connected.

Arguments:

  • interval - Seconds between keep-alive messages (default: 10)

stop_keepalive

async def stop_keepalive() -> None

Stop periodic keep-alive if running.

arm_areas

async def arm_areas(area_numbers: list[int] | tuple[int, ...],
                    bypass_faulted: bool = False,
                    force_arm: bool = False,
                    instant: bool | None = None) -> None

Arm one or more areas in a single command.

Concatenates two-digit area numbers per DMP format and sends !C{areas},{bypass}{force}.

disarm_areas

async def disarm_areas(area_numbers: list[int] | tuple[int, ...]) -> None

Disarm one or more areas in a single command: !O{areas}.

__aenter__

async def __aenter__() -> "DMPPanel"

Async context manager entry.

__aexit__

async def __aexit__(*args: Any) -> None

Async context manager exit.

__repr__

def __repr__() -> str

String representation.

pydmp.cli

Command-line interface for PyDMP.

SectionedGroup Objects

class SectionedGroup(click.Group)

Click Group that renders commands in named sections for --help.

load_config

def load_config(config_path: Path) -> dict[str, Any]

Load configuration from YAML file.

Arguments:

  • config_path - Path to config file

Returns:

Configuration dictionary

cli

@click.group(
    cls=SectionedGroup,
    context_settings={"help_option_names": ["-h", "--help"]},
    sections=[
        ("Panel Control", ["arm", "disarm", "sensor-reset"]),
        (
            "Status & Query",
            [
                "get-areas", "get-zones", "get-outputs", "get-users",
                "get-profiles", "check-code"
            ],
        ),
        ("Zones", ["set-zone-bypass", "set-zone-restore"]),
        ("Outputs", ["set-output"]),
        ("Realtime", ["listen"]),
    ],
)
@click.version_option(__version__, "-v", "--version")
@click.option(
    "--config",
    "-c",
    # Do not require the file to exist so commands like 'listen'
    # can run without a config present (tests/CI environments).
    type=click.Path(path_type=Path),
    default="config.yaml",
    help="Configuration file path",
)
@click.option("--quiet", "-q", is_flag=True, help="Reduce output (WARNING)")
@click.option("--debug",
              "-d",
              is_flag=True,
              help="Enable debug logging (overrides other flags)")
@click.pass_context
def cli(ctx: click.Context, config: Path, quiet: bool, debug: bool) -> None

PyDMP - Control DMP alarm panels from command line.

arm_cmd

@cli.command("arm", context_settings={"help_option_names": ["-h", "--help"]})
@click.argument("areas", type=str)
@click.option("--bypass-faulted",
              "-b",
              is_flag=True,
              help="Bypass faulted zones")
@click.option("--force-arm", "-f", is_flag=True, help="Force arm bad zones")
@click.option("-i",
              "--instant/--no-instant",
              default=None,
              help="Remove entry/exit delays")
@click.option("--json",
              "-j",
              "as_json",
              is_flag=True,
              help="Output JSON instead of text")
@click.pass_context
def arm_cmd(ctx: click.Context, areas: str, bypass_faulted: bool,
            force_arm: bool, instant: bool | None, as_json: bool) -> None

Arm one or more areas, e.g. "1,2,3".

disarm

@cli.command(context_settings={"help_option_names": ["-h", "--help"]})
@click.argument("area", type=int)
@click.option("--json",
              "-j",
              "as_json",
              is_flag=True,
              help="Output JSON instead of text")
@click.pass_context
def disarm(ctx: click.Context, area: int, as_json: bool) -> None

Disarm area.

set_zone_bypass

@cli.command("set-zone-bypass",
             context_settings={"help_option_names": ["-h", "--help"]})
@click.argument("zone", type=int)
@click.option("--json",
              "-j",
              "as_json",
              is_flag=True,
              help="Output JSON instead of text")
@click.pass_context
def set_zone_bypass(ctx: click.Context, zone: int, as_json: bool) -> None

Bypass a zone.

set_zone_restore

@cli.command("set-zone-restore",
             context_settings={"help_option_names": ["-h", "--help"]})
@click.argument("zone", type=int)
@click.option("--json",
              "-j",
              "as_json",
              is_flag=True,
              help="Output JSON instead of text")
@click.pass_context
def set_zone_restore(ctx: click.Context, zone: int, as_json: bool) -> None

Restore (un-bypass) a zone.

set_output

@cli.command("set-output",
             context_settings={"help_option_names": ["-h", "--help"]})
@click.argument("output", type=int)
@click.argument("action", type=click.Choice(["on", "off", "pulse", "toggle"]))
@click.option("--json",
              "-j",
              "as_json",
              is_flag=True,
              help="Output JSON instead of text")
@click.pass_context
def set_output(ctx: click.Context, output: int, action: str,
               as_json: bool) -> None

Control an output.

list_users

@cli.command("get-users",
             context_settings={"help_option_names": ["-h", "--help"]})
@click.option("--json",
              "-j",
              "as_json",
              is_flag=True,
              help="Output JSON instead of text")
@click.pass_context
def list_users(ctx: click.Context, as_json: bool) -> None

List panel user codes (decrypted).

list_profiles

@cli.command("get-profiles",
             context_settings={"help_option_names": ["-h", "--help"]})
@click.option("--json",
              "-j",
              "as_json",
              is_flag=True,
              help="Output JSON instead of text")
@click.pass_context
def list_profiles(ctx: click.Context, as_json: bool) -> None

List user profiles.

list_outputs

@cli.command("get-outputs",
             context_settings={"help_option_names": ["-h", "--help"]})
@click.option("--json",
              "-j",
              "as_json",
              is_flag=True,
              help="Output JSON instead of text")
@click.pass_context
def list_outputs(ctx: click.Context, as_json: bool) -> None

List outputs (1-4) and last-known state.

sensor_reset

@cli.command("sensor-reset",
             context_settings={"help_option_names": ["-h", "--help"]})
@click.option("--json",
              "-j",
              "as_json",
              is_flag=True,
              help="Output JSON instead of text")
@click.pass_context
def sensor_reset(ctx: click.Context, as_json: bool) -> None

Send sensor reset (!E001).

check_code_cmd

@cli.command("check-code",
             context_settings={"help_option_names": ["-h", "--help"]})
@click.option(
    "--code",
    type=str,
    prompt=True,
    hide_input=True,
    help="User code or PIN to check (prompted securely if not provided)",
)
@click.option(
    "-p",
    "--include-pin/--no-include-pin",
    default=True,
    show_default=True,
    help="Match PIN as well as code",
)
@click.option("--json",
              "-j",
              "as_json",
              is_flag=True,
              help="Output JSON instead of text")
@click.pass_context
def check_code_cmd(ctx: click.Context, code: str, include_pin: bool,
                   as_json: bool) -> None

Check if a code or PIN exists in the panel.

listen

@cli.command("listen",
             context_settings={"help_option_names": ["-h", "--help"]})
@click.option("--host",
              "-H",
              default="127.0.0.1",
              show_default=True,
              help="Listen host")
@click.option("--port",
              "-p",
              default=5001,
              show_default=True,
              type=int,
              help="Listen port")
@click.option("--duration",
              "-t",
              default=0,
              type=int,
              help="Seconds to run (0=until Ctrl+C)")
@click.option("--json",
              "-j",
              "as_json",
              is_flag=True,
              help="Output events as JSON (NDJSON)")
def listen(host: str, port: int, duration: int, as_json: bool) -> None

Run realtime S3 status server and print parsed events.

get_areas_cmd

@cli.command("get-areas",
             context_settings={"help_option_names": ["-h", "--help"]})
@click.option("--json",
              "-j",
              "as_json",
              is_flag=True,
              help="Output JSON instead of text")
@click.pass_context
def get_areas_cmd(ctx: click.Context, as_json: bool) -> None

List areas and their state.

get_zones_cmd

@cli.command("get-zones",
             context_settings={"help_option_names": ["-h", "--help"]})
@click.option("--json",
              "-j",
              "as_json",
              is_flag=True,
              help="Output JSON instead of text")
@click.pass_context
def get_zones_cmd(ctx: click.Context, as_json: bool) -> None

List zones and their state.

output

@cli.command(
    "output",
    context_settings={"help_option_names": ["-h", "--help"]},
    hidden=True,
    deprecated="Use 'set-output' instead.",
)
@click.argument("output", type=int)
@click.argument("action", type=click.Choice(["on", "off", "pulse", "toggle"]))
@click.option("--json",
              "-j",
              "as_json",
              is_flag=True,
              help="Output JSON instead of text")
@click.pass_context
def output(ctx: click.Context, output: int, action: str,
           as_json: bool) -> None

Control an output (deprecated alias for 'set-output').

main

def main() -> None

CLI entry point.

pydmp.const.protocol

Protocol-level constants for the DMP transport and framing.

pydmp.const

Constants for DMP protocol.

pydmp.const.strings

Human‑readable strings for statuses and system messages.

This module centralizes user‑facing strings to make future internationalization (i18n) straightforward. By default, it exposes English strings. A future enhancement could expose per‑locale mappings and a simple selection mechanism.

pydmp.const.commands

DMP protocol commands.

DMPCommand Objects

class DMPCommand(StrEnum)

DMP panel commands.

GET_USER_CODES

Format: ?P=0000 for all, ?P=0001 for user 1

GET_USER_PROFILES

Format: ?U000 for all, ?U001 for profile 1

GET_AREA_STATUS

Format: ?WA01 for area 1, ?WA for continuation

GET_AREA_STATUS_CONT

Continuation (no params)

GET_OUTPUT_STATUS

Format: ?WQ001 for output 1, ?WQ for continuation

GET_OUTPUT_STATUS_CONT

Continuation (no params)

GET_ZONE_STATUS

Format: ?WB**Y001 for initial query

GET_ZONE_STATUS_CONT

Continuation (no params)

pydmp.const.events

DMP event types and codes.

Derived from DMP LT-1959 "SCS‑VR Reference Guide: Panel Messages". This file defines: - Event categories (Zx "Event Definition" field) - Event type codes (tXX "Event Type" field), grouped by category

Note: Some codes (e.g., AD, IN, PR) are reused across categories by the protocol. To avoid ambiguity in Python Enums, category-specific enums are provided below. The legacy DMPEvent enum remains for common codes but is not exhaustive. Prefer category enums for precise handling.

DMPEventType Objects

class DMPEventType(StrEnum)

Event Definition categories (Zx).

REAL_TIME_STATUS

Entré/real-time status

DMPEvent Objects

class DMPEvent(StrEnum)

Common event type codes (legacy/unscoped).

Prefer the category-specific enums below for full coverage and to avoid ambiguity where the same code is reused across categories.

pydmp.const.responses

DMP protocol response prefixes and status text maps.

Includes: - Command acknowledgments ("+"/"-") - Convenience text mapping for common status characters seen in status replies (mirrors the mapping used by hass-dmp's StatusResponse).

DMPResponse Objects

class DMPResponse(StrEnum)

DMP panel response message prefixes.

pydmp.protocol

DMP protocol encoder and decoder.

AreaStatus Objects

@dataclass
class AreaStatus()

Area status from panel.

state

'A','D','S' (or 'unknown')

ZoneStatus Objects

@dataclass
class ZoneStatus()

Zone status from panel.

state

'N','O','S','X','L','M' (or 'unknown')

StatusResponse Objects

@dataclass
class StatusResponse()

Combined status response from panel.

OutputStatus Objects

@dataclass
class OutputStatus()

Output status from panel (*WQ).

mode

'O','P','S','T','W','a','t'

DMPProtocol Objects

class DMPProtocol()

DMP protocol encoder/decoder.

__init__

def __init__(account_number: str, remote_key: str = "")

Initialize protocol handler.

Arguments:

  • account_number - 5-digit account number (left-padded with spaces or zeros)
  • remote_key - Remote key for authentication

encode_command

def encode_command(command: str, **kwargs: Any) -> bytes

Encode a command for transmission to panel.

Arguments:

  • command - Command template (e.g., "!C{area},{bypass}{force}")
  • **kwargs - Parameters to substitute into command template

Returns:

Encoded command as bytes

Raises:

  • DMPProtocolError - If command cannot be encoded

decode_response

def decode_response(
    response: bytes
) -> str | StatusResponse | UserCodesResponse | UserProfilesResponse | OutputsResponse | None

Decode response from panel.

Arguments:

  • response - Raw bytes from panel

Returns:

  • ACK/NAK string for command acknowledgments
  • StatusResponse for status queries
  • None for empty/auth responses

Raises:

  • DMPInvalidResponseError - If response cannot be decoded

pydmp.area

Area abstraction.

Area Objects

class Area()

Represents a DMP area.

__init__

def __init__(panel: "DMPPanel",
             number: int,
             name: str = "",
             state: str = "unknown")

Initialize area.

Arguments:

  • panel - Parent panel instance
  • number - Area number (1-8)
  • name - Area name
  • state - Current area state

state

@property
def state() -> str

Get current state.

update_state

def update_state(state: str, name: str | None = None) -> None

Update area state from status response.

Arguments:

  • state - New state
  • name - Updated name (optional)

is_armed

@property
def is_armed() -> bool

Check if area is armed (any armed state).

is_disarmed

@property
def is_disarmed() -> bool

Check if area is disarmed.

arm

async def arm(bypass_faulted: bool = False,
              force_arm: bool = False,
              instant: bool | None = None) -> None

Arm area.

Arguments:

  • bypass_faulted - Bypass faulted zones (default: False)
  • force_arm - Force arm bad zones (default: False)
  • instant - Remove entry/exit delays (Y/N). If None, omit third flag.

Raises:

  • DMPAreaError - If arm fails

disarm

async def disarm() -> None

Disarm area.

Note: User code validation is typically done at the application level, not sent to the panel in the protocol.

Raises:

  • DMPAreaError - If disarm fails

get_state

async def get_state() -> str

Get current state from panel.

Returns:

Current area state

__repr__

def __repr__() -> str

String representation.

to_dict

def to_dict() -> dict[str, Any]

Return a JSON-serializable representation of the area.

AreaSync Objects

class AreaSync()

Synchronous wrapper for Area.

__init__

def __init__(area: Area, panel_sync: "DMPPanelSync")

Initialize sync area.

Arguments:

  • area - Async Area instance
  • panel_sync - Sync panel instance

number

@property
def number() -> int

Get area number.

name

@property
def name() -> str

Get area name.

state

@property
def state() -> str

Get current state.

is_armed

@property
def is_armed() -> bool

Check if area is armed.

is_disarmed

@property
def is_disarmed() -> bool

Check if area is disarmed.

arm_sync

def arm_sync(bypass_faulted: bool = False, force_arm: bool = False) -> None

Arm area (sync).

disarm_sync

def disarm_sync() -> None

Disarm area (sync).

get_state_sync

def get_state_sync() -> str

Get current state from panel (sync).

__repr__

def __repr__() -> str

String representation.

pydmp.transport

Async TCP transport to DMP panel (raw bytes I/O only).

DMPTransport Objects

class DMPTransport()

Async TCP transport to DMP panel.

This class is responsible only for socket lifecycle, rate limiting, and sending/receiving raw bytes. No protocol encoding/decoding occurs here.

connect

async def connect() -> None

Establish TCP connection.

disconnect

async def disconnect() -> None

Close TCP connection.

send_and_receive

async def send_and_receive(data: bytes) -> bytes

Send raw bytes and return accumulated response bytes.

pydmp.output

Output abstraction.

Output Objects

class Output()

Represents a DMP output.

__init__

def __init__(panel: "DMPPanel",
             number: int,
             name: str = "",
             state: str = "unknown")

Initialize output.

Arguments:

  • panel - Parent panel instance
  • number - Output number (1-4)
  • name - Output name
  • state - Current output state

state

@property
def state() -> str

Get current state.

update_state

def update_state(state: str, name: str | None = None) -> None

Update output state.

Arguments:

  • state - New state
  • name - Updated name (optional)

is_on

@property
def is_on() -> bool

Check if output is on.

is_off

@property
def is_off() -> bool

Check if output is off.

formatted_number

@property
def formatted_number() -> str

Get zero-padded 3-digit output number.

set_mode

async def set_mode(mode: str) -> None

Set output mode.

Arguments:

  • mode - Output mode ('O'=Off, 'P'=Pulse, 'S'=Steady, 'M'=Momentary)

Raises:

  • DMPOutputError - If command fails

turn_on

async def turn_on() -> None

Turn output on (steady mode).

Raises:

  • DMPOutputError - If command fails

turn_off

async def turn_off() -> None

Turn output off.

Raises:

  • DMPOutputError - If command fails

pulse

async def pulse() -> None

Pulse output (momentary activation).

Raises:

  • DMPOutputError - If command fails

toggle

async def toggle() -> None

Toggle output state.

Raises:

  • DMPOutputError - If command fails

__repr__

def __repr__() -> str

String representation.

to_dict

def to_dict() -> dict[str, Any]

Return a JSON-serializable representation of the output.

OutputSync Objects

class OutputSync()

Synchronous wrapper for Output.

__init__

def __init__(output: Output, panel_sync: "DMPPanelSync")

Initialize sync output.

Arguments:

  • output - Async Output instance
  • panel_sync - Sync panel instance

number

@property
def number() -> int

Get output number.

name

@property
def name() -> str

Get output name.

state

@property
def state() -> str

Get current state.

is_on

@property
def is_on() -> bool

Check if output is on.

is_off

@property
def is_off() -> bool

Check if output is off.

turn_on_sync

def turn_on_sync() -> None

Turn output on (sync).

turn_off_sync

def turn_off_sync() -> None

Turn output off (sync).

pulse_sync

def pulse_sync() -> None

Pulse output (sync).

toggle_sync

def toggle_sync() -> None

Toggle output (sync).

__repr__

def __repr__() -> str

String representation.

pydmp.crypto

LFSR-based encryption for DMP user codes.

DMP uses a Linear Feedback Shift Register (LFSR) algorithm for encrypting user codes in certain commands. The algorithm is symmetric (encrypt = decrypt).

DMPCrypto Objects

class DMPCrypto()

LFSR encryption for DMP user codes.

__init__

def __init__(account_number: int, remote_key: str = "")

Initialize crypto with account number and optional remote key.

Arguments:

  • account_number - 5-digit account number (1-99999)
  • remote_key - Remote key for authentication (not used for Entree connections)

encrypt_string

def encrypt_string(string_to_encrypt: str) -> str

Encrypt a string using LFSR algorithm.

The control string determines which positions are encrypted: - '-': Skip (no encryption) - '2': Encrypt 2-char hex value - '3': Encrypt 3-digit decimal value

Arguments:

  • string_to_encrypt - String to encrypt (typically user code + data)

Returns:

Encrypted string

decrypt_string

def decrypt_string(string_to_decrypt: str) -> str

Decrypt a string using LFSR algorithm.

Since LFSR XOR is symmetric, decryption is identical to encryption.

Arguments:

  • string_to_decrypt - String to decrypt

Returns:

Decrypted string

encrypt_user_code

def encrypt_user_code(user_code: str) -> str

Encrypt a user code for use in disarm commands.

Arguments:

  • user_code - 4-6 digit user code

Returns:

Encrypted user code

pydmp.zone

Zone abstraction.

Zone Objects

class Zone()

Represents a DMP zone.

__init__

def __init__(panel: "DMPPanel",
             number: int,
             name: str = "",
             state: str = "unknown")

Initialize zone.

Arguments:

  • panel - Parent panel instance
  • number - Zone number (1-999)
  • name - Zone name
  • state - Current zone state

state

@property
def state() -> str

Get current state.

update_state

def update_state(state: str, name: str | None = None) -> None

Update zone state from status response.

Arguments:

  • state - New state
  • name - Updated name (optional)

is_open

@property
def is_open() -> bool

Check if zone is open/tripped.

is_normal

@property
def is_normal() -> bool

Check if zone is normal (closed).

is_bypassed

@property
def is_bypassed() -> bool

Check if zone is bypassed.

has_fault

@property
def has_fault() -> bool

Check if zone has a fault.

formatted_number

@property
def formatted_number() -> str

Get zero-padded 3-digit zone number.

bypass

async def bypass() -> None

Bypass this zone.

Raises:

  • DMPZoneError - If bypass fails

restore

async def restore() -> None

Restore (un-bypass) this zone.

Raises:

  • DMPZoneError - If restore fails

get_state

async def get_state() -> str

Get current state from panel.

Returns:

Current zone state

__repr__

def __repr__() -> str

String representation.

to_dict

def to_dict() -> dict[str, Any]

Return a JSON-serializable representation of the zone.

ZoneSync Objects

class ZoneSync()

Synchronous wrapper for Zone.

__init__

def __init__(zone: Zone, panel_sync: "DMPPanelSync")

Initialize sync zone.

Arguments:

  • zone - Async Zone instance
  • panel_sync - Sync panel instance

number

@property
def number() -> int

Get zone number.

name

@property
def name() -> str

Get zone name.

state

@property
def state() -> str

Get current state.

is_open

@property
def is_open() -> bool

Check if zone is open.

is_normal

@property
def is_normal() -> bool

Check if zone is normal.

is_bypassed

@property
def is_bypassed() -> bool

Check if zone is bypassed.

has_fault

@property
def has_fault() -> bool

Check if zone has fault.

formatted_number

@property
def formatted_number() -> str

Get formatted number.

bypass_sync

def bypass_sync() -> None

Bypass zone (sync).

restore_sync

def restore_sync() -> None

Restore zone (sync).

get_state_sync

def get_state_sync() -> str

Get current state from panel (sync).

__repr__

def __repr__() -> str

String representation.

pydmp.status_parser

Helper to convert Serial 3 (S3) messages into structured, typed events.

This module maps a low-level S3Message (from status_server) to enums and fields from pydmp.const, making it easier to act on realtime events.

ParsedEvent Objects

@dataclass
class ParsedEvent()

Structured representation of a realtime SCS‑VR Z-message.

Fields may be None if not applicable for the message category.

code_enum

one of the DMP*Event enums above, when applicable

parse_s3_message

def parse_s3_message(msg: S3Message) -> ParsedEvent

Convert a Serial 3 (S3) message to a structured ParsedEvent with enums.

This function does not mutate any panel state; it only interprets the incoming message. Use it inside your DMPStatusServer callbacks.

pydmp.profile

UserProfile Objects

@dataclass
class UserProfile()

User profile record (not encrypted).

pydmp.status_server

Async Serial 3 (S3) realtime status server for DMP panels.

This server listens for Serial 3 (Z-frames) pushed by the panel and invokes registered callbacks with parsed messages.

Notes:

  • Configure your DMP panel to connect to this machine/port for realtime S3 status (Z-frames). Only one connection is expected.
  • The server sends an ACK per message: STX + [5-byte account] + 0x06 + CR.

S3Message Objects

@dataclass
class S3Message()

Parsed Serial 3 Z-frame.

definition

e.g., 'Za', 'Zq', 'Zc'

type_code

e.g., 'BU', 'OP', 'ON', etc.

fields

raw fields split on '\'

raw

full raw line (ASCII)

DMPStatusServer Objects

class DMPStatusServer()

Async TCP server for DMP Serial 3 realtime status (Z-frames).