-
Notifications
You must be signed in to change notification settings - Fork 4
Update checks and battery efficiency coverage #148
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
Conversation
* Sync temp snapshot onto main * Fix CI analysis findings * Configure CodeFactor exclusions * Fix SonarCloud bugs and hotspots * Fix duplicate display in pricing overlay * Reduce CodeFactor findings * Fix CodeFactor issues * Address remaining CodeFactor issues * Fix remaining CodeFactor warnings * Add battery forecast helper modules * Move battery forecast HA sensor to module * Extract mode guard logic * Refactor charging plan helpers * Extract mode recommendation logic * Remove unused charging helper methods * Drop unused charging wrapper methods * Remove unused night target helper * Remove unused balancing helper block * Remove legacy forecast orchestrator * Remove unused timeline simulator * Remove unused forecast service * Remove unused forecast bridge and utils * Remove unused legacy files * Remove legacy battery forecast shim * Extract detail tab aggregation helpers * Extract unified cost tile helpers * Extract extended timeline builders * Extract plan storage helpers * Extract pricing and state helpers * Extract scenario analysis helpers * Extract interval grouping helpers * Split lifecycle and update helpers * Extract forecast sensor helpers * Extract forecast sensor setup * Split detail tab builders * Split hybrid strategy helpers * Split charging plan helpers * Split extended timeline summaries * Split unified cost tile helpers * Split plan storage helpers * Split spot price sensor modules * Remove legacy balancing module * Move balancing under battery_forecast * Move balancing helpers into package * Move plan storage into storage package * Move presentation helpers into package * Move battery forecast sensors into package * refactor(battery_forecast): group data and planning modules * refactor: split shield, config flow, and sensor runtime * Refactor modules and fix fixed pricing * Add local hassfest runner * Refactor forecast helpers and expand tests * Add coverage tests for timeline, shield, and sensors * test: expand planning and presentation coverage * test: expand coverage for helpers and storage * test: expand coverage for sensors, shield, and cost tile * test: expand shield core coverage * test: cover async_setup_entry cloud path * test: cover coordinator init branches * test: cover config distribution, options flow, api, profiles * test: cover config flow summary and yaml import * test: extend pricing flow and api balancing coverage * test: add wizard path and api error cases * test: cover solar forecast async_added_to_hass * test: close solar forecast async tasks * test: fix coordinator/shield setup and add services coverage * test: expand balancing manager coverage * test: cover shield queue, coordinator, setup entry * test: cover forecast update flow * test: cover precompute, detail blocks, ha sensor * test: cover init cleanup and mode tracker * test: cover balancing core and solar forecast sensor * test: cover shield validation paths * test: extend async_setup_entry coverage * test: cover coordinator spot price paths * test: cover config wizard steps and ha rest api views * test: add data source sensor coverage * test: expand coverage for stats, adaptive, data source, OTE * Improve coverage for coordinator, sensors, and analytics * Stub opentelemetry in tests * Reach 100% coverage for planner and storage * Expand coverage for planning and presentation * Increase coverage for history, CHMU, pricing, and OTE * Expand coverage for grid, recommended, and battery health sensors * Add test coverage for efficiency, OTE, recommended, and pricing * Improve test coverage for init and pricing sensors * Increase coordinator and data source coverage * Add tests to reach full coverage for core, API, sensors, services * Add coverage tests for adaptive profiles, notifications, config, and data sensor * Add HA REST API coverage tests * Add computed and statistics sensor coverage tests * Add analytics sensor coverage tests * Add pricing helper coverage tests * Add input helper coverage tests * Add solar forecast sensor coverage tests * Add coverage tests for shield, forecast, and config helpers * Add additional coverage tests for steps and sensors * Add coverage tests for config steps boiler and pricing migration * Add coverage tests for steps, sensors, unified cost helpers, and shield * Add battery forecast coverage tests * Expand coverage and stabilize tests * Add local checks and lock hashed requirements * Expand unit test coverage for sensors and helpers * Improve coverage for adaptive, shield, statistics, and solar sensors * Fix test isolation for box id resolution * Expand tests for config, telemetry, and physics helpers * Cover additional physics branches * Allow tracking config schema under custom_components * Achieve full unit test coverage * Add config module files * Improve planner guards and BE stability * Expand config flow runtime coverage * Fix balancing setup test for battery prediction flag * Add E2E test suite * Add solcast provider support and update security checks * Increase unit test coverage to 100% * Update coverage, sonar tooling, and tests * Finish coverage and remove duplicate blocks * Refactor solar wizard and forecast logic * Refine charging plan APIs and clean unused params * Refactor CHMU filtering helpers * Refactor setup helpers and logging * Fix setup helper return and balancing logging * Enable and implement E2E smoke tests * Refactor setup helpers and include E2E tests * Refactor detail tab block helpers * Refactor computed sensor helpers * Refactor data source helpers * Refactor analytics and statistics sensors * Refactor shield queue, dispatch, and timeline helpers * Refactor shield core, config steps, history, and pricing * Refactor balancing config, tariff validation, and summary helpers * Refactor detail tab, state attribute, and cost tile helpers * Fix tariff hour overlap validation * Refactor setup, coordinator, services, and sensors * Refactor OTE init helper * Refactor config flow option mapping * Refactor shield entity state matching * Refactor spot price fallback checks * Refactor computed sensor energy accumulation * Refactor statistics sensor restore helpers * Refactor HTML notification parsing * Refactor init helpers for Sonar cleanup * Fix device cleanup keep rules * Raise coverage to 100% and fix async warning * Fix async helper flagged by Sonar * Refactor service helpers and extend tests * Normalize logging in core modules * Refactor init and services smells * Fix coverage gaps and stabilize planners * Refactor sensors, queue, and API helpers * Refactor core planning and sensor helpers * Fix coverage gaps after refactor * Refactor sonar fixes * Fix refactor regressions and restore tests * Finalize coverage and isolate Sonar/E2E compose * Exclude FE tests from Sonar to silence baseline warning * Re-enable FE analysis in Sonar * Stabilize FE E2E and coverage checks * Stabilize E2E forecast updates and cookie handling * Add data-source fallback E2E and FE refresh test * Remove SonarQube artifacts from repo * Remove SonarQube files from repo * Fix CI deps, tighten API auth, and address review comments * Align dev deps with Python 3.12 CI * Regenerate dev requirements for Linux CI * Fix recommended sensor callbacks and coverage
* Fix dashboard API auth and static module path * Fix manifest version for hassfest
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.
Pull request overview
This PR extracts battery efficiency monitoring and expands forecast planning infrastructure by refactoring legacy battery forecast code into modular, testable components.
Changes:
- Extracted battery efficiency sensor with monthly tracking and recorder-based history fallback
- Refactored forecast planning modules (auto-switch, mode guard, charging plans, scenario analysis)
- Added unified cost tile presentation helpers for UI data aggregation
- Introduced physics simulation layer with typed configuration
Reviewed changes
Copilot reviewed 67 out of 514 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| custom_components/oig_cloud/battery_forecast/sensors/efficiency_sensor.py | Battery efficiency sensor implementation with monthly metrics tracking |
| custom_components/oig_cloud/battery_forecast/presentation/unified_cost_tile_helpers.py | Cost analysis and variance helpers for UI presentation |
| custom_components/oig_cloud/battery_forecast/presentation/unified_cost_tile.py | Unified cost tile builder with error handling |
| custom_components/oig_cloud/battery_forecast/presentation/state_attributes.py | Attribute builders for sensor state with hash-based change detection |
| custom_components/oig_cloud/battery_forecast/presentation/precompute.py | UI data precomputation with storage caching |
| custom_components/oig_cloud/battery_forecast/planning/scenario_analysis.py | Mode scenario simulation and baseline cost calculations |
| custom_components/oig_cloud/battery_forecast/planning/mode_recommendations.py | Mode recommendation generation from optimized timeline |
| custom_components/oig_cloud/battery_forecast/planning/mode_guard.py | Mode stability enforcement with minimum duration guards |
| custom_components/oig_cloud/battery_forecast/planning/forecast_update.py | Main forecast update routine with adaptive load handling |
| custom_components/oig_cloud/battery_forecast/planning/charging_plan.py | Economic and smart charging plan algorithms |
| custom_components/oig_cloud/battery_forecast/planning/auto_switch.py | Automatic mode switching scheduler with watchdog |
| custom_components/oig_cloud/battery_forecast/physics/interval_simulator.py | Physics simulator for battery interval calculations |
| custom_components/oig_cloud/battery_forecast/data/solar_forecast.py | Solar forecast data extraction helpers |
| custom_components/oig_cloud/battery_forecast/data/pricing.py | Spot/export price calculation with fees |
| custom_components/oig_cloud/battery_forecast/config.py | Typed configuration dataclasses for simulation |
| .vscode/settings.json | VSCode Python analysis and formatting configuration |
| .safety-project.ini | Safety scanner project configuration |
|
|
||
| import logging | ||
| from datetime import datetime, timedelta | ||
| from typing import Any, Dict, Optional, TYPE_CHECKING |
Copilot
AI
Jan 14, 2026
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.
Missing return type annotation in the imports. While this is an import statement, the coding guideline requires all function signatures to use types. Ensure all functions in this file have typed parameters and return values.
| return text | ||
|
|
||
|
|
||
| async def build_today_cost_data(sensor: Any) -> Dict[str, Any]: # noqa: C901 |
Copilot
AI
Jan 14, 2026
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.
The sensor parameter uses Any type instead of a specific type. According to the coding guidelines, all parameters should have proper type annotations. Consider creating a Protocol or interface for the sensor parameter.
| ) | ||
|
|
||
|
|
||
| async def async_update(sensor: Any) -> None: # noqa: C901 |
Copilot
AI
Jan 14, 2026
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.
The sensor parameter uses Any type. All function parameters should have specific type annotations per the coding guidelines.
|
| def _get_ssl_context() -> ssl.SSLContext: | ||
| global _SSL_CONTEXT | ||
| if _SSL_CONTEXT is None: | ||
| _SSL_CONTEXT = ssl.create_default_context(cafile=certifi.where()) |
Check failure
Code scanning / SonarCloud
Weak SSL/TLS protocols should not be used High
| if (!fs.existsSync(file)) { | ||
| return JSON.parse(fs.readFileSync(path.join(FIXTURES_DIR, `${DEFAULT_MODE}.json`), 'utf8')); | ||
| } | ||
| return JSON.parse(fs.readFileSync(file, 'utf8')); |
Check failure
Code scanning / SonarCloud
I/O function calls should not be vulnerable to path injection attacks High test




Summary\n- tighten local security checks and add a Safety policy for dev-only vulns\n- update battery efficiency/OTE handling and expand related tests\n- refresh dependencies and FE test tooling\n- add a minimal pylint config for fatal-only checks\n\n## Testing\n- scripts/run_local_checks.sh\n- npm audit --registry=https://registry.npmjs.org/\n- .venv/bin/pylint custom_components/oig_cloud\n- sonar-scanner (local)