Skip to main content

Petsafe Scoopfree Integration

Project description

PetSafe Scoopfree - Python API

Connect and control a PetSafe Scoopfree device using the PetSafe-Scoopfree API.

BREAKING CHANGE: Version 2.0 uses the new PetSafe API. You will need to request new tokens.

PetSafe will lock your account if you request data more often than once per 5 minutes.

Installation

pip install petsafe-scoopfree

If installing from source code, python setup.py install

Login tokens

You must use tokens to interact with the PetSafe Scoopfree API.
There are two methods to retrieve tokens:

Get tokens using command line

  1. Execute python -m petsafe_scoopfree [email_address] to request an email code.
  2. Check your email for an email code from PetSafe.
  3. Enter your code to generate tokens.

Get tokens using Python

import petsafe_scoopfree as sf


# replace with your email address
client = sf.PetSafeClient(email="email@example.com")
client.request_code()

# check your email for a code
code = input("Enter email code: ")
token = client.request_tokens_from_code(code)

print("email:", client.email)
print("id_token:", client.id_token)
print("refresh_token:", client.refresh_token)
print("access_token:", client.access_token)

Example usage

List devices

import petsafe_scoopfree as sf

client = sf.PetSafeClient(email="email@example.com",
                       id_token="YOUR_ID_TOKEN",
                       refresh_token="YOUR_REFRESH_TOKEN",
                       access_token="YOUR_ACCESS_TOKEN")
devices = sf.devices.get_scoopers(client)

# print all devices
for device in devices:
    print(device)

Rake scooper

import petsafe_scoopfree as sf

client = sf.PetSafeClient(email="email@example.com",
                       id_token="YOUR_ID_TOKEN",
                       refresh_token="YOUR_REFRESH_TOKEN",
                       access_token="YOUR_ACCESS_TOKEN")
devices = sf.devices.get_scoopers(client)

# get the first scooper
scooper = devices[0]
scooper.rake_now()

reset count

import petsafe_scoopfree as sf

client = sf.PetSafeClient(email="email@example.com",
                       id_token="YOUR_ID_TOKEN",
                       refresh_token="YOUR_REFRESH_TOKEN",
                       access_token="YOUR_ACCESS_TOKEN")
devices = sf.devices.get_scoopers(client)

# get the first scooper
scooper = devices[0]
scooper.reset()

reset rake delay to 25 seconds

import petsafe_scoopfree as sf

client = sf.PetSafeClient(email="email@example.com",
                       id_token="YOUR_ID_TOKEN",
                       refresh_token="YOUR_REFRESH_TOKEN",
                       access_token="YOUR_ACCESS_TOKEN")
devices = sf.devices.get_scoopers(client)

# get the first scooper
scooper = devices[0]
scooper.modify_timer(amount=25)

Contributing

All contributions are welcome. Please, feel free to create a pull request!

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

petsafe_scoopfree-0.0.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

petsafe_scoopfree-0.0.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file petsafe_scoopfree-0.0.1.tar.gz.

File metadata

  • Download URL: petsafe_scoopfree-0.0.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for petsafe_scoopfree-0.0.1.tar.gz
Algorithm Hash digest
SHA256 af3621084eb6941de8634562e5c5976c93f29da9a581dd65679ef3b7d2b9e46c
MD5 c69b3851c5872e7364fb43d9622ca29f
BLAKE2b-256 f2bf02f0600747bac19d5dc8cbf561bf8d2c757b471e9335cbe2a92a8144a439

See more details on using hashes here.

File details

Details for the file petsafe_scoopfree-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for petsafe_scoopfree-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 534e7a6b36a64ae70f40f574b8b7d8c61b52a0b2d73978f5c8291defcb138989
MD5 3b4055c586e8466c0fc34ca5ad51310a
BLAKE2b-256 9af9a01fef742adee40f6c93bdf45712371f92a78653cee2df3acb93a7ea1363

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