Skip to content

Conversation

@adamjacobmuller
Copy link

TryFi Series 3+ Support

Overview

This branch adds support for new metrics available in the TryFi Series 3+ collar.

New Features Added

Behavior Tracking

The Series 3+ collar includes AI-powered behavior detection. This update adds support for tracking:

  • Barking - Count and duration for daily, weekly, and monthly periods
  • Licking - Count and duration for daily, weekly, and monthly periods
  • Scratching - Count and duration for daily, weekly, and monthly periods
  • Eating - Count and duration for daily, weekly, and monthly periods
  • Drinking - Count and duration for daily, weekly, and monthly periods

Enhanced Device Information

New device properties for Series 3+ collars:

  • Firmware Version - Current firmware version of the collar
  • Hardware Version - Hardware version identifier
  • GPS Accuracy - Enhanced GPS accuracy metrics
  • Signal Strength - Signal strength indicator
  • Signal Type - Type of signal connection

API Changes

New GraphQL Fragment

Added FRAGMENT_BEHAVIOR_DETAILS to query behavior metrics with daily, weekly, and monthly breakdowns.

New Query Method

Added getCurrentPetBehaviorStats() to fetch behavior data from the API.

FiPet Class Updates

  • Added setBehaviorStats() method to parse behavior data
  • Added updateBehaviorStats() method to fetch latest behavior data
  • Added properties for all behavior metrics (e.g., dailyBarkingCount, weeklyLickingDuration, etc.)

FiDevice Class Updates

  • Added properties for enhanced device information
  • Gracefully handles missing fields for older collar models

Backward Compatibility

All changes are backward compatible. Older collar models will:

  • Return 0 for all behavior metrics
  • Return 'Unknown' or None for enhanced device fields
  • Log debug messages when behavior data is not available

Usage Example

from pytryfi import PyTryFi

# Connect to TryFi
pytryfi = PyTryFi(username='your_email', password='your_password')

# Get a pet
pet = pytryfi.pets[0]

# Access new behavior metrics
print(f"Daily barking count: {pet.dailyBarkingCount}")
print(f"Weekly licking duration: {pet.weeklyLickingDuration} seconds")
print(f"Monthly eating count: {pet.monthlyEatingCount}")

# Access enhanced device info
print(f"Firmware version: {pet.device.firmwareVersion}")
print(f"GPS accuracy: {pet.device.gpsAccuracy}")

Testing

Due to the lack of access to a Series 3+ collar, these changes are based on TryFi's documentation and anticipated API structure. Testing with an actual Series 3+ collar is recommended to verify the GraphQL queries and response parsing.

…info

- Add behavior tracking for barking, licking, scratching, eating, and drinking
- Add daily, weekly, and monthly metrics for each behavior type
- Add enhanced device fields: firmware/hardware version, GPS accuracy, signal info
- Add backward compatibility for older collar models
- Update GraphQL fragments and queries for new data
- Initialize behavior metrics to 0 for all pets

Fixes #7
adamjacobmuller pushed a commit to tryfi/hass-tryfi that referenced this pull request Aug 5, 2025
…info

- Update embedded pytryfi with Series 3+ support
- Add behavior sensors for barking, licking, scratching, eating, drinking
- Add daily, weekly, monthly metrics for each behavior
- Add enhanced device sensors: firmware/hardware version, GPS accuracy
- Add PetBehaviorSensor class for behavior data handling
- Update constants with new behavior types
- All changes are backward compatible with older collars

Related to tryfi/pytryfi#7 and tryfi/pytryfi#8
@adamjacobmuller
Copy link
Author

Update: Actual API Investigation Results

After testing with a real Series 3+ collar, I've discovered that the behavior tracking features are not available in the current API. This PR has been updated to implement only the fields that actually exist.

Actually Implemented Features

This PR now adds support for the following real Series 3+ fields:

  1. Battery Voltage - Raw battery voltage in millivolts (property: batteryVoltage)
  2. Temperature - Internal device temperature (property: temperature)
  3. Uptime - Device uptime in seconds (property: uptime)
  4. Hardware Revision - Hardware version identifier (property: hardwareRevision)

Removed Features (Not Available in API)

The following features were removed from this PR as they don't exist in the API:

  • ❌ All behavior tracking (barking, licking, scratching, eating, drinking)
  • ❌ Firmware version (only buildId exists)
  • ❌ GPS accuracy metrics
  • ❌ Enhanced signal strength (only for cellular connections)

Code Changes

  1. const.py: Removed FRAGMENT_BEHAVIOR_DETAILS and behavior queries
  2. fiDevice.py: Added properties for actual available fields
  3. fiPet.py: Removed all behavior tracking methods and properties
  4. query.py: Removed behavior query methods

The implementation is now based on actual API responses rather than speculation.

Note on Temperature

The temperature value appears to be a raw sensor reading rather than Celsius. Further investigation needed to determine the proper conversion formula.

Adam Jacob Muller added 2 commits August 5, 2025 13:21
- Add device fields: batteryVoltage, temperature, uptime, hardwareRevision
- Add device statistics fields: wifiNetworkNames, capabilityFlags, deviceStats, etc.
- Fix handling of pets without devices (returns None gracefully)
- Add proper error handling in query methods
- Remove commented behavior tracking code (not available in API)
- Add logging for device info fields to aid future development
- Enable behavior stats update in updatePets() method
- Add health trends API support for behavior metrics (barking, licking, scratching, eating, drinking)
- Map cleaning_self:DAY to licking behavior
- Support both Series3+ and prod1 hardware revisions
- Clean up all debug logging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants