fix: change vehicle_eta to return datetime object or None - #501
Conversation
📝 WalkthroughWalkthroughTime handling updated: Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code graph analysis (1)tests/test_main.py (1)
🔇 Additional comments (6)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Pylint (4.0.4)setup.pytests/test_main.pyThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @openevsehttp/__main__.py:
- Around line 1311-1316: In vehicle_eta, the current truthy check on value will
treat a time_to_full_charge of 0 as False and return 0 instead of a datetime;
change the condition to an explicit is not None check on
self._status.get("time_to_full_charge") so that when value == 0 you compute and
return datetime.now(timezone.utc) + timedelta(seconds=value), and only return
None when the key/value is actually missing or None.
🧹 Nitpick comments (1)
requirements_test.txt (1)
11-11: Consider pinning the freezegun version for reproducibility.Since freezegun is used in tests (
from freezegun import freeze_timein test_main.py), pinning its version ensures consistent test behavior across environments. Latest stable version is 1.5.5.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
openevsehttp/__main__.pyrequirements_test.txttests/fixtures/v4_json/status.jsontests/test_main.py
🧰 Additional context used
🧬 Code graph analysis (1)
tests/test_main.py (2)
tests/test_main_edge_cases.py (1)
charger(16-17)openevsehttp/__main__.py (2)
update(185-208)vehicle_eta(1311-1316)
🔇 Additional comments (5)
tests/fixtures/v4_json/status.json (1)
51-51: LGTM! Field rename aligns with the API change.The field name change from
vehicle_etatotime_to_full_chargecorrectly reflects the updated property implementation, which now reads this field and computes an absolute datetime.openevsehttp/__main__.py (2)
6-6: LGTM! Import change improves specificity.The updated import statement is more specific and aligns well with the usage in the file.
1147-1147: LGTM! Type annotation is consistent with the import change.The simplified type annotation
datetime | Noneis cleaner and consistent with the updated import statement.tests/test_main.py (2)
11-12: LGTM! Necessary imports for updated test.The datetime components and freezegun imports support the new test implementation that verifies datetime calculations.
1270-1290: LGTM! Test implementation correctly validates the datetime behavior.The test updates properly:
- Use time freezing for deterministic datetime assertions
- Compute the expected datetime based on frozen time plus the expected seconds
- Handle both scenarios (value present and None)
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @openevsehttp/__main__.py:
- Around line 1146-1149: The OpenEVSE.time property is annotated as returning
datetime | None but actually returns the raw string from
self._status.get("time", None); update the property to annotate return type as
str | None and adjust the docstring to "Get the RTC time as ISO-8601 string."
(alternatively, if you prefer returning a datetime, change the implementation in
OpenEVSE.time to parse the ISO-8601 string from self._status.get("time") into a
datetime with proper UTC/Z handling and return that, ensuring None is
preserved).
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
openevsehttp/__main__.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: coverage
🔇 Additional comments (1)
openevsehttp/__main__.py (1)
6-6: Import change is fine (timezone-aware UTC math).
Usingtimezone.utcwithdatetime.now()is the right direction for an absolute ETA.
Summary by CodeRabbit
Breaking Changes
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.