sbabcock23 / pytryfi

Apache License 2.0
31 stars 10 forks source link

pytryfi - Python Interface for TryFi

This python interface enables you to gather information about your dogs whereabouts, your user details and any bases you may have.

NOTE: Since this interacts with undocumented APIs, this may change without notice.

Installation

To install this package, use pip

python -m pip install "pytryfi"

Usage

TryFi uses Graphql for its APIs. Essentially, you will use your username (email address) and password to retrieve a unique username specific for API calls which in turn will be used for the duration to retrieve data.

Login Script with Debugging Support

# Export env variables
export fi_user=user@user.com
export fi_pass=secretpassword

# When running in Dev container, uncomment & use the args in the `launch.json` file for vscode or set manually in your workspace terminal
export fi_user=user@user.com
export fi_pass=secretpassword

# run script in terminal
python login.py

# Alternatively run script in debugger and set breakpoints as needed (recommended to set one on line 31 of login.py for an example)
hit F5 to start the debugger

Manual Example

#this will create the object and gather all the necessary data
tryfi = PyTryFi(username, password)
print(tryfi)

#this will perform a complete refresh of all Pets and data points
tryfi.updatePets()

#this will perform a complete refresh of all Bases and data points
tryfi.updateBases()

#this will perform an update on both Pets and Bases and their associated data points
tryfi.update()

#this will update the last reported location of a bet
tryfi.pets[0].updatePetLocation(tryfi.session)

#this will update the stats of the pet
tryfi.pets[0].updateStats(tryfi.session)

#this will update rest (nap/sleep) stats of the pet
tryfi.pets[0].updateRestStats(tryfi.session)

#update the device/collar details for the given pet
tryfi.pets[0].updateDeviceDetails(tryfi.session)

#update the all details for a given pet
tryfi.pets[0].updateAllDetails(tryfi.session)

#this will set the light color of the collar
tryfi.pets[0].setLedColorCode(tryfi.session, 2)

#this will turn on the LED light on the color
tryfi.pets[0].turnOnOffLed(tryfi.session,True)
#or turn it off
tryfi.pets[0].turnOnOffLed(tryfi.session,False)

#this will turn on the lost dog mode
tryfi.pets[0].setLostDogMode(tryfi.session,True)
#or turn it off
tryfi.pets[0].setLostDogMode(tryfi.session,False)

#this will get the lost dog mode status/state currently in the object
tryfi.pets[0].isLost

#this will query sleep stats for given pet
tryfi.pets[0].dailySleep
tryfi.pets[0].weeklySleep
tryfi.pets[0].monthlySleep

#this will query nap stats for given pet
tryfi.pets[0].dailyNap
tryfi.pets[0].weeklyNap
tryfi.pets[0].monthlyNap

To Do

Links:

Version History

0.0.21

0.0.20

0.0.19

0.0.18

0.0.17

0.0.16

0.0.15

0.0.14

0.0.13

0.0.12

0.0.11

0.0.10

0.0.9

0.0.8

0.0.7

0.0.6

0.0.5

0.0.4

0.0.3

The following updates/enhancements were made:

0.0.2

Initial version of the TryFi interface that gathered basic information about the pets, collars and bases.