Skip to content

Conversation

@adamjacobmuller
Copy link

Summary

  • Adds comprehensive behavior tracking support for Series 3+ TryFi collars
  • Syncs all behavior-related changes from the embedded pytryfi in hass-tryfi
  • Fixes NoneType parsing errors that prevented behavior data from displaying

Changes

New Functionality

  • Added getPetHealthTrends function to query behavior data from TryFi API
  • Added updateBehaviorStats method to FiPet for fetching behavior metrics
  • Added setBehaviorStatsFromTrends method for parsing behavior data
  • Added _parseTimelineSegments method for extracting timeline events
  • Added 30 behavior properties (5 behaviors × 2 metrics × 3 time periods):
    • Barking, Licking, Scratching, Eating, Drinking
    • Count and Duration metrics
    • Daily, Weekly, Monthly time periods
  • Added behaviorTimeline property for behavior event history

Bug Fixes

  • Fixed NoneType error when eventsSummary is None
  • Fixed NoneType error when durationSummary is None
  • Added proper initialization of _name attribute in FiPet constructor
  • Added comprehensive error handling for GraphQL queries and mutations

Testing

  • Added test_behavior.py with comprehensive tests for all behavior functionality
  • Verified all 30 behavior properties work correctly
  • Tested NoneType handling to ensure no crashes
  • Confirmed timeline parsing extracts events properly

Related Issues

This brings feature parity with the embedded pytryfi in the hass-tryfi Home Assistant integration, enabling Series 3+ collar users to access behavior tracking data.

Test Results

✓ FiPet created successfully
✓ All 30 behavior properties exist and default to 0
✓ setBehaviorStatsFromTrends correctly parses event counts and durations
✓ Timeline events are extracted properly
✓ None/null values are handled gracefully without errors
✓ All methods exist and are callable
✓ getPetHealthTrends function is available

- Add getPetHealthTrends function to query behavior data from API
- Add updateBehaviorStats and setBehaviorStatsFromTrends methods to FiPet
- Add _parseTimelineSegments for timeline event extraction
- Add 30 behavior properties (5 behaviors × 2 metrics × 3 time periods)
- Add behaviorTimeline property for event history
- Fix NoneType handling in eventsSummary and durationSummary parsing
- Add comprehensive error handling for GraphQL queries
- Initialize _name to None in FiPet constructor for safer access
- Add test_behavior.py to verify functionality

This brings feature parity with the embedded pytryfi in hass-tryfi for Series 3+ collar behavior tracking.
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