Skip to content

SGC1990/petsafe-smartfeed

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PetSafe Smart Feed - Python API

Connect and control a PetSafe Smart Feed device using the PetSafe-SmartFeed API.

API Throttle Warning

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

Installation

python setup.py install

Login token

You must get a login token to use the PetSafe Smart-Feed API.
There are two methods to retrieve a token:

Get token 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. Execute python -m petsafe_smartfeed [email_address] -t [email_code] to generate a token.

Get token using Python

import petsafe_smartfeed as sf

# replace with your email address
email = '[email protected]'
sf.api.request_code(email)

# check your email for a code
code = input('enter email code (include any dashes): ')
token = sf.api.request_token_from_code(email, code)

print(token)

Example usage

List devices

import petsafe_smartfeed as sf

token = 'YOUR TOKEN HERE'
devices = sf.devices.get_feeders(token)

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

Feed 1/8 cup at normal speed

import petsafe_smartfeed as sf

token = 'YOUR TOKEN HERE'
devices = sf.devices.get_feeders(token)

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

Get current battery level (0 - 100)

import petsafe_smartfeed as sf

token = 'YOUR TOKEN HERE'
devices = sf.devices.get_feeders(token)

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

Get current food level

import petsafe_smartfeed as sf

token = 'YOUR TOKEN HERE'
devices = sf.devices.get_feeders(token)

# 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.')

Contributing

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%