Skip to main content

Library to interact with the flaps & doors from Sure Petcare.

Project description

surepy

Library & CLI to interact with the Sure Petcare API. surepy lets you monitor and control the Pet Door/Cat Flap Connect 🚪 and the Pet Feeder Connect 🍽 by Sure Petcare.


👋 hey! 🐾 like to run your devices without any connection to Sure Petcare? 📡 check out the amazing work of @plambrechtsen on his pethublocal project to completely reverse engineer their proprietary 802.14.5 / MiWi protocol! 👏 🥇


surepy features:

🔑 get an api token with your account credentials
🚪 lock/unlock a door or flap
🐾 get the location of pets & devices
🐈 get the state and more attributes of pets & devices
🕰️ get historic data & events of pets & devices
📬 get a list of (past) notifications

Getting Started

surepy is available via pypi.org

python3 -m pip install --upgrade surepy
# or
pip install --upgrade surepy

there is also a small cli available

$ surepy --help
Usage: surepy [OPTIONS] COMMAND [ARGS]...

  surepy cli 🐾

  https://github.com/benleb/surepy

Options:
  --version         show surepy version
  -j, --json        enable json api response output
  -t, --token TEXT  api token
  --help            Show this message and exit.

Commands:
  devices       get devices
  locking       lock control
  notification  get notifications
  pets          get pets
  position      set pet position
  report        get pet/household report
  token         get a token

the cli is mainly intended for developing & debugging purposes and probably has bugs - be careful 🐾

Library example

import asyncio

from os import environ
from pprint import pprint
from typing import Dict, List

from surepy import Surepy
from surepy.entities import SurepyEntity
from surepy.entities.devices import SurepyDevice
from surepy.entities.pet import Pet


async def main():

    # # user/password authentication (gets a token in background)
    # surepy = Surepy(email=user, password=password)

    # token authentication (token supplied via SUREPY_TOKEN env var)
    token = environ.get("SUREPY_TOKEN")
    surepy = Surepy(auth_token=token)

    # list with all pets
    pets: List[Pet] = await surepy.get_pets()
    for pet in pets:
        print(f"\n\n{pet.name}: {pet.state} | {pet.location}\n")
        pprint(pet.raw_data())

    print(f"\n\n - - - - - - - - - - - - - - - - - - - -\n\n")

    # all entities as id-indexed dict
    entities: Dict[int, SurepyEntity] = await surepy.get_entities()

    # list with alldevices
    devices: List[SurepyDevice] = await surepy.get_devices()
    for device in devices:
        print(f"{device.name = } | {device.serial = } | {device.battery_level = }")
        print(f"{device.type = } | {device.unique_id = } | {device.id = }")
        print(f"{entities[device.parent_id].full_name = } | {entities[device.parent_id] = }\n")


asyncio.run(main())

Used by

Feel free to add you project!

Acknowledgments

Meta

Ben Lebherz: cat lover 🐾 developer & maintainer - @benleb | @ben_leb

This project is licensed under the MIT License - see the 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

surepy-0.7.0b4.tar.gz (25.3 kB view hashes)

Uploaded Source

Built Distribution

surepy-0.7.0b4-py3-none-any.whl (26.0 kB view hashes)

Uploaded Python 3

Supported by

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