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
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
- Execute
python -m petsafe [email_address]to request an email code. - Check your email for an email code from PetSafe.
- Enter your code to generate tokens.
Get tokens using Python
import petsafe 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 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_feeders(client)
# print all feeders
for device in devices:
print(device)
Feed 1/8 cup at normal speed
import petsafe 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_feeders(client)
# get the first feeder
feeder = devices[0]
feeder.feed(amount=1, slow_feed=False)
Get current battery level (0 - 100)
import petsafe 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_feeders(client)
# get the first feeder
feeder = devices[0]
print(feeder.battery_level)
Get current food level
import petsafe 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_feeders(client)
# get the first feeder
feeder = devices[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.")
get litterboxes
import petsafe 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_litterboxes(client)
# print all litterboxes
for device in devices:
print(device)
get litterbox activity
import petsafe 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_litterboxes(client)
litterbox = devices[0]
print(litterbox.get_schedule())
rake the litterbox
import petsafe 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_litterboxes(client)
litterbox = devices[0]
litterbox.rake()
modify the litterbox rake timer
import petsafe 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_litterboxes(client)
litterbox = devices[0]
litterbox.modify_timer(15)
reset the litterbox rake count
import petsafe 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_litterboxes(client)
litterbox = devices[0]
litterbox.reset()
Contributing
All contributions are welcome. Please, feel free to create a pull request!
Metadata
Release files for petsafe 2.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| petsafe-2.0.7.tar.gz | 9.2 kB | Without provenance | Details for petsafe-2.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| petsafe-2.0.7-py3-none-any.whl | Python 3 | none | any | Details for petsafe-2.0.7-py3-none-any.whl |
Total release size: 18.2 kB
Release files / petsafe-2.0.7.tar.gz
| Download URL | petsafe-2.0.7.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58cbe0f9fdddae36c5b6618bc1718dea2014011617b23a8fa84f96860f12b012
|
|
BLAKE2b-256 checksum How to use checksums |
7e34934b495e2ef0fc9761876246fb8f352bbee99509681841f9ea5fa6001132
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.11
|
Release files / petsafe-2.0.7-py3-none-any.whl
| Download URL | petsafe-2.0.7-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
51e6b6c63fd7b0aa87c18cdff5db646c49828afb369cb76d105392aea555973e
|
|
BLAKE2b-256 checksum How to use checksums |
3ca54bd86bd4c8b945b8ac6c0f75397d1fe474aafad40d6d78490297ac122d5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.11
|
Security for petsafe 2.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.