Git Product home page Git Product logo

surepy's Introduction

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.


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())

Naming confusion for surepetcarebeta users ๐Ÿพ ๐Ÿคช ๐Ÿคฆ

Sorry for the bad naming and resulting confusion and chaos ๐Ÿ™„ To "fix" this, I renamed surepetcarebeta to sureha.

Name Repo Type Description Need Help?
surepy ๐Ÿพ github.com/benleb/surepy Python Library Library to interact with the API of Sure Petcare. Also provides Classes for the various Sure Petcare Devicess. Use this if you write an own python tool/app and want to interact with the Sure Petcare API Issues
surepetcare HA Favicon github.com/home-assistant/core Home Assistant Integration Official Home Assistant Integration for the Sure Petcare Devices like Doors, Flaps, Feeders, ... Issues, HA Forum
sureha surepetcarebeta benleb/surepetcare github.com/benleb/sureha Home Assistant Integration Home Assistant Integration developed in my own repo without reviews from the HA Team. This can be installed via HACS and is something like a preview integration for advanced users. Usually this provides more (experimental) features and faster fixes but lacks the code quality (reviews) and such from HA Issues
pethublocal github.com/plambrechtsen/pethublocal Home Assistant Integration Home Assistant Integration developed by @plambrechtsen which works completely independent from Sure Petcare. Check outs his repo for more information! Issues, HA Forum

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.