Decouple and optimize GE Cloud historical data fetching #2717
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Removes tight coupling between
fetch.py
and GE Cloud historical data fetching by implementing proper separation of concerns and adding intelligent incremental fetching.Key Changes
🔧 Architectural Decoupling
fetch.py
no longer directly callsdownload_ge_data()
GECloudDirect component → populates sensors → fetch.py reads sensors
⚡ Intelligent Incremental Fetching
Fetch Logic Details
Technical Implementation
last_historical_fetch_time
andhistorical_data_last_timestamp
last_fetch
anddata_points
attributes for visibilityFiles Modified
apps/predbat/fetch.py
: Removedge_cloud_data
conditional, always uses sensor approachapps/predbat/gecloud.py
: Addedfetch_and_publish_historical_data()
with incremental logicBenefits
✅ Proper separation of concerns
✅ 87% reduction in API calls under normal operation
✅ Better error handling and logging
✅ Maintains backward compatibility
✅ Rate limit protection
✅ Gap recovery for service restarts
This PR requires testing before merge:
🧪 Basic functionality testing:
fetch.py
reads sensor data correctly (noge_cloud_data
config needed)⏱️ Incremental fetch testing:
🔄 Restart/recovery testing:
📊 Performance validation:
last_fetch
anddata_points
🔗 Integration testing:
Test with real GE Cloud credentials in a development environment before production deployment.
Rollback Plan
If issues arise, the previous behavior can be restored by:
ge_cloud_data: true
to their config to restore old direct coupling behavior (though this is deprecated)