Skip to main content

Asynchronous Python library for PetKit's API

Project description

PetKitAIO

Asynchronous Python library for PetKit's API.

This is PetKit's undocumented API. With that said, future changes made by PetKit may break this library. All API calls are made to PetKit's USA servers.

Currently Supported Devices:

Important

If you don't have a water fountain on your PetKit account: Create a new PetKit account and share your devices from your original account to it. This will allow you to use your main account on the mobile app, and the secondary account with this library. Otherwise, your main account will get logged out of the mobile app when using this library. This is a limitation of how PetKit handles authorization.

If you do have a water fountain: Unfortunately, there is no way of sharing a water fountain with a secondary account. As a result, you will need to use your main PetKit account to pull in water fountain data. When doing so, your main account will get signed out of any mobile app it is currently signed in on. This is a limitation of how PetKit handles authorization. If you only want to pull in data for non-water fountain devices, see "If you don't have a water fountain on your PetKit account" above.

This package depends on aiohttp and requires Python 3.7 or greater.

Usage

Creating Client

import asyncio
from petkitaio import PetKitClient
from aiohttp import ClientSession

async def main():
    async with ClientSession() as session:

        # Create a client using PetKit account email and password
        client = PetKitClient('email', 'password', session)


        ###################################################################################
        Examples within the examples section utilize the PetKitClient instance created above
        ###################################################################################



loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Examples

Retrieving all PetKit devices on account

# See model.py for details regarding Data Classes created

devices = await client.get_petkit_data()

Manual Feeding

# See model.py for details regarding "Feeder" class


# Reusing retrieved devices from above. Note: A valid amount (in grams) will depend on the capabilities of the feeder.
await client.manual_feeding(feeder=devices.feeders[feederid], amount=10)

Change Feeder Setting

# See constants.py FeederSetting class for available settings
# Additional import needed:
from petkitaio.constants import FeederSetting


# Enabling child lock on a D4 feeder. Note: Mini Feeders use a different setting.
# Reusing retrieved devices from above.
await client.update_feeder_settings(feeder=devices.feeders[feederid], setting=FeederSetting.CHILDLOCK, value=1)

Reset Feeder Desiccant

# Reusing retrieved devices from above.
await client.reset_feeder_desiccant(feeder=devices.feeders[feederid])

Control Water Fountain via BLE Relay

# A valid relay (set up through the PetKit app) is required in order to send commands to the Eversweet 3 Pro
# See constants.py W5Command class for available commands
# Additional import needed:
from petkitaio.constants import W5Command

# Set Water Fountain to Smart Mode. Reusing retrieved devices from above.
await client.control_water_fountain(water_fountain=devices.water_fountains[water_fountain_id], command=W5Command.SMART)

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

petkitaio-0.1.0.tar.gz (11.1 kB view details)

Uploaded Source

File details

Details for the file petkitaio-0.1.0.tar.gz.

File metadata

  • Download URL: petkitaio-0.1.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.5

File hashes

Hashes for petkitaio-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c1348dce0f8521f0968c5c74b8fb8018d359a242dda61df571fb9c8161c476bb
MD5 2c8993038c925bf63895cfa0f1d1bcdf
BLAKE2b-256 b931d87111fdfa1aef9e99a05eb5300b960596804c21a15ea0bbca869b581304

See more details on using hashes here.

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