Skip to main content

PetSafe Smart Feed - Python API

Connect and control a PetSafe Smart Feed device using the PetSafe-SmartFeed 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-smartfeed

If installing from source code, python setup.py install

Login tokens

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

Get tokens using command line

  1. Execute python -m petsafe_smartfeed [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_smartfeed 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 feeders

import petsafe_smartfeed as sf

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

# print all feeders
for feeder in feeders:
    print(feeder)

Feed 1/8 cup at normal speed

import petsafe_smartfeed as sf

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

# get the first feeder
feeder = feeders[0]
feeder.feed(amount=1, slow_feed=False)

Get current battery level (0 - 100)

import petsafe_smartfeed as sf

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

# get the first feeder
feeder = feeders[0]
print(feeder.battery_level)

Get current food level

import petsafe_smartfeed as sf

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

# get the first feeder
feeder = feeders[0]
status = feeder.food_low_status

if status == 0:
    print("Feeder has food.")
elif status == 1:
    print("Feeder is low on food.")
elif status == 2:
    print("Feeder is out of food.")

Contributing

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

Metadata

Release files for petsafe-smartfeed 2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for petsafe-smartfeed 2.3
File Size Uploaded
petsafe_smartfeed-2.3.tar.gz 8.1 kB Details

Release files / petsafe_smartfeed-2.3.tar.gz

Download URL petsafe_smartfeed-2.3.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1fc5bcbb6fbde7eab5c31a5267dd387ed7779202bd84e637ea9e3c76395786e1
BLAKE2b-256 checksum
How to use checksums
94d01ad63f515544f25b48d3908e165f9fc4d9e84b68c258439fe2b6cd6d859c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.10

Release history Release notifications | RSS feed

This release

2.3 This release

1 release file

2.2

1 release file

2.0

1 release file

1.3

2 release files

1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page