Add history subcommand to explore recent SolMate logs#32
Merged
Conversation
Exposes solmate_sdk's get_recent_logs via a new read-only command that fetches PV / injection / battery time-series data from the cloud and prints a structure summary. --raw dumps JSON to stdout, --dump writes it to a file for offline analysis. Intended as a first exploration step toward computing daily averages and trend lines over the last N days — the response schema is not documented, so the summary keeps us honest before building aggregation logic. https://claude.ai/code/session_01XkPiC4MQxgGaybR8ivBXd3
Adds --plot to the history subcommand: renders PV (orange), injection (blue) and battery state (green, scaled to % on the same watts axis) as a single plotext chart. A flexible extractor walks the undocumented response, matches timestamp / pv / inject / battery keys against a candidate list, and falls back to a clear error that points at --raw for inspection. Also adds --from-file so a previously dumped JSON can be re-plotted offline without hitting the cloud. https://claude.ai/code/session_01XkPiC4MQxgGaybR8ivBXd3
- history: plot by default (no --plot flag), default window 7 days,
fills terminal width and 2/3 of height (min 30 lines).
- Dual y-axis: watts (0/200/400/600/800) left, battery % (0..100) right.
- Parser rewritten for the real columnar response schema
(logs[*].{timestamp, pv_power, inject_power, battery_state, ...}).
- --raw dumps numeric arrays, --no-plot prints structure, --from-file
replays a previously dumped JSON.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
historysubcommand (also registered as standalonehistoryentry point) that callsSolMateAPIClient.get_recent_logs(days=N)and prints a compact summary of the response shape (top-level keys, list lengths, sample item types).--rawdumps the full JSON to stdout;--dump FILEwrites it to disk for offline inspection.logic.pyor the optimizer flow — this is an exploration tool. Once we know the response schema, we can add daily averages and trend analysis in a follow-up.Why
The SolMate SDK exposes
get_recent_logs, but the response schema is undocumented. Before building trend/average logic on top, we need to see what the cloud actually returns for PV power, injection, and battery state over time. This command lets us look without committing to a shape.Test plan
uv run solmate history --helpshows the subcommanduv run history --helpshows the standalone entry pointpytestsuite still passes (60 tests,logic.pycoverage 100 %)history --days 3 --dump logs.jsonagainst a real SolMate and inspect the outputhttps://claude.ai/code/session_01XkPiC4MQxgGaybR8ivBXd3