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.
pip install petsafe-smartfeed
If installing from source code,
python setup.py install
You must use tokens to interact with the PetSafe Smart-Feed API.
There are two methods to retrieve tokens:
- Execute
python -m petsafe_smartfeed [email_address]
to request an email code. - Check your email for an email code from PetSafe.
- Enter your code to generate tokens.
import petsafe_smartfeed as sf
# replace with your email address
client = sf.PetSafeClient(email="[email protected]")
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)
import petsafe_smartfeed as sf
client = sf.PetSafeClient(email="[email protected]",
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)
import petsafe_smartfeed as sf
client = sf.PetSafeClient(email="[email protected]",
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)
import petsafe_smartfeed as sf
client = sf.PetSafeClient(email="[email protected]",
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)
import petsafe_smartfeed as sf
client = sf.PetSafeClient(email="[email protected]",
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.")
All contributions are welcome. Please, feel free to create a pull request!