Skip to main content

Python library for communicating with Power Pet Door devices

Reason this release was yanked:

Not working quite right.

Project description

Power Pet Door Python Library

Buy Me Coffee

Github Release Github Activity License

PyPI Python Versions

A Python library for communicating with Power Pet Door WiFi-enabled pet doors made by High Tech Pet.

Power Pet Door

Disclaimer

This library is NOT authorized, endorsed, or supported by High Tech Pet Products, Inc.

This is an independent, community-developed project. No contributions, financial or otherwise, have been received from High Tech Pet. If you need official support for your Power Pet Door, please contact High Tech Pet directly.

Installation

pip install pypowerpetdoor

Usage

import asyncio
from powerpetdoor import PowerPetDoorClient, COMMAND, CMD_OPEN, CMD_CLOSE

# Create a client
client = PowerPetDoorClient(
    host="192.168.1.100",
    port=3000,
    keepalive=30.0,
    timeout=10.0,
    reconnect=5.0
)

# Add a listener for door status updates
client.add_listener(
    name="my_app",
    door_status_update=lambda status: print(f"Door status: {status}")
)

# Start the client (blocks if running own event loop)
# For integration with existing event loop, pass it to the constructor
client.start()

# Send commands
client.send_message(COMMAND, CMD_OPEN)
client.send_message(COMMAND, CMD_CLOSE)

# Stop when done
client.stop()

Async Usage

For use with an existing asyncio event loop:

import asyncio
from powerpetdoor import PowerPetDoorClient, COMMAND, CMD_GET_SETTINGS, CONFIG

async def main():
    loop = asyncio.get_event_loop()

    client = PowerPetDoorClient(
        host="192.168.1.100",
        port=3000,
        keepalive=30.0,
        timeout=10.0,
        reconnect=5.0,
        loop=loop
    )

    # Connect
    await client.connect()

    # Send a command and wait for response
    settings = await client.send_message(CONFIG, CMD_GET_SETTINGS, notify=True)
    print(f"Settings: {settings}")

    # Disconnect
    client.stop()

asyncio.run(main())

Schedule Utilities

The library includes utilities for working with Power Pet Door schedules:

from powerpetdoor import (
    compress_schedule,
    validate_schedule_entry,
    compute_schedule_diff,
    schedule_template,
)

# Validate a schedule entry
entry = {...}
if validate_schedule_entry(entry):
    print("Entry is valid")

# Compress multiple schedule entries
compressed = compress_schedule(schedule_list)

# Compute differences between schedules
to_delete, to_add = compute_schedule_diff(current, new)

Door Simulator

The library includes a full-featured door simulator for testing clients without real hardware. The simulator speaks the same protocol as the real device and supports all commands.

Quick Start

# Run the interactive simulator
python -m powerpetdoor.simulator

# Run with a test script
python -m powerpetdoor.simulator --script basic_cycle

# Run script and exit (for CI/CD)
python -m powerpetdoor.simulator --script full_test_suite --exit-after-script

Programmatic Usage

import asyncio
from powerpetdoor.simulator import DoorSimulator

async def main():
    simulator = DoorSimulator(host="0.0.0.0", port=3000)
    await simulator.start()

    # Trigger events programmatically
    simulator.trigger_sensor("inside")
    await asyncio.sleep(5)
    await simulator.close_door()

    await simulator.stop()

asyncio.run(main())

For complete documentation including scripting syntax and all available commands, see docs/SIMULATOR.md.

Library Structure

powerpetdoor/
├── client.py          # PowerPetDoorClient - main client class
├── const.py           # Protocol constants and commands
├── schedule.py        # Schedule utilities
├── tz_utils.py        # Timezone utilities
└── simulator/         # Door simulator submodule
    ├── state.py       # Simulator state dataclasses
    ├── protocol.py    # Command handler registry
    ├── server.py      # DoorSimulator server
    ├── cli.py         # Interactive CLI
    ├── scripting.py   # YAML script runner
    └── scripts/       # Built-in test scripts

Related Projects

License

MIT License - see LICENSE file for details.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypowerpetdoor-0.2.0.tar.gz (48.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypowerpetdoor-0.2.0-py3-none-any.whl (46.2 kB view details)

Uploaded Python 3

File details

Details for the file pypowerpetdoor-0.2.0.tar.gz.

File metadata

  • Download URL: pypowerpetdoor-0.2.0.tar.gz
  • Upload date:
  • Size: 48.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pypowerpetdoor-0.2.0.tar.gz
Algorithm Hash digest
SHA256 235ee03ce58cd951e02021d3db3b7050e48ff3f08b6df8c2e5836d193f1088ec
MD5 f8b996fbd697144aa7f5c67c9dfb9bd3
BLAKE2b-256 218dc5f5cc4530628fe1926a6c0ee0b1d3b9ce362eb1aadd2a3b155bfeab65ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for pypowerpetdoor-0.2.0.tar.gz:

Publisher: ci.yml on corporategoth/py-powerpetdoor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pypowerpetdoor-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pypowerpetdoor-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 46.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pypowerpetdoor-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9231d46c6d1952d9307d647b61243712be87b02c8aba394a8278d708fe0ba150
MD5 01eee0e5c3ad10d67d2f5e7b3be22a48
BLAKE2b-256 d580590570f788ed2afa3e5afa14f874c28152bc4d83303ce3f2d1c2a1b14c5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pypowerpetdoor-0.2.0-py3-none-any.whl:

Publisher: ci.yml on corporategoth/py-powerpetdoor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page