-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable long-term statistics for odometers #289
Enable long-term statistics for odometers #289
Conversation
WalkthroughThe pull request modifies the Changes
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
custom_components/polestar_api/sensor.py (1)
Line range hint
70-96
: Consider separating odometer and trip meter state classes.While using
SensorStateClass.TOTAL_INCREASING
is perfect for the odometer as it truly represents a continuously increasing value, the trip meters might benefit from a different approach:
- Keep the odometer as
TOTAL_INCREASING
for proper long-term statistics- Consider reverting trip meters to
MEASUREMENT
since they can reset- If trip meter statistics are needed, consider implementing separate total distance sensors that track cumulative trip distances over time
This separation would provide more accurate historical data tracking while maintaining the ability to reset trip meters without affecting statistics.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
custom_components/polestar_api/sensor.py
(3 hunks)
🔇 Additional comments (3)
custom_components/polestar_api/sensor.py (3)
70-70
: LGTM! Appropriate state class for odometer readings.The change to
SensorStateClass.TOTAL_INCREASING
is correct as odometer values should only increase over time. This enables proper long-term statistics tracking in Home Assistant.
87-87
: Verify if TOTAL_INCREASING is appropriate for trip meters.According to the PR description, trip meters may decrease when starting a new cycle. Using
SensorStateClass.TOTAL_INCREASING
might lead to incorrect historical data tracking when the trip meter resets.Consider keeping
SensorStateClass.MEASUREMENT
for trip meters since they can reset to zero. Alternatively, please confirm if there's a specific reason for treating trip meters as continuously increasing values.
96-96
: Verify if TOTAL_INCREASING is appropriate for manual trip meters.Similar to the automatic trip meter, the manual trip meter can be reset by the user. Using
SensorStateClass.TOTAL_INCREASING
might not accurately represent the behavior of a resettable trip meter.Consider keeping
SensorStateClass.MEASUREMENT
for manual trip meters since they can be manually reset to zero. Alternatively, please confirm if there's a specific reason for treating trip meters as continuously increasing values.
… Keep `SensorStateClass.TOTAL_INCREASING` for the trip meters as they may reset upon user request or start of new drive cycle.
Use
SensorStateClass.TOTAL_INCREASING
for odometer and trip_meters as they never decrease. The two trip meters can decrease in case of a new cycle.See also https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics
Closes #286
Summary by CodeRabbit