FastAPI app that pulls interval usage from Sungrow iSolarCloud (OAuth2), caches AER Consumer Data Right electricity plan data, and compares actual metered usage against every available plan to estimate real annual cost (TOU, tiered feed-in, and flat tariffs). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
26 lines
739 B
Python
26 lines
739 B
Python
from typing import Protocol
|
|
from datetime import datetime
|
|
|
|
from app.isolarcloud.schemas import IntervalDataPoint
|
|
|
|
|
|
class ISolarCloudLike(Protocol):
|
|
def fetch_interval_data(self, since: datetime, until: datetime) -> list[IntervalDataPoint]: ...
|
|
|
|
|
|
def get_isolarcloud_client() -> ISolarCloudLike:
|
|
from app.config import settings
|
|
|
|
if settings.use_mock_isolarcloud:
|
|
from app.isolarcloud.mock_client import MockISolarCloudClient
|
|
|
|
return MockISolarCloudClient()
|
|
|
|
if settings.isolarcloud_auth_mode == "oauth2":
|
|
from app.isolarcloud.oauth_client import ISolarCloudOAuthClient
|
|
|
|
return ISolarCloudOAuthClient()
|
|
|
|
from app.isolarcloud.client import ISolarCloudClient
|
|
|
|
return ISolarCloudClient()
|