Repository navigation
Conversation
Home Assistant solar companion with demo and live modes. Live mode works on the badge (socket client) and in the Badge Simulator canvas (browser fetch client with a browser-clock fallback when CORS hides the Date header). Credentials stay in a git-ignored private file copied to /state. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
sujithq
force-pushed
the
sujithq-solar-buddy
branch
from
November 3, 2026 15:45
4a5f705 to
7b11b96
Compare
sujithq
marked this pull request as ready for review
November 3, 2026 15:50
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Stale nonzero export readings can incorrectly make appliances READY, while Wi-Fi reported as connected without an IP address can prevent reconnect attempts.
2 open issues
What changed in this PR
Adds Solar Buddy, a Universe 2026 badge app that displays Home Assistant power readings and recommends appliances after sustained solar surplus.
Changes:
- Adds animated screens, simulated scenarios, appliance advice, and saved preferences.
- Implements read-only Home Assistant polling through socket and browser HTTP clients.
- Documents live setup, private credentials, simulator requirements, and deployment.
| File | Description |
|---|---|
badge/apps/solar_buddy/ui.py |
Renders dashboard, energy, appliance, and settings screens. |
badge/apps/solar_buddy/solar_buddy_secrets.example.json |
Provides a credential-free connection template. |
badge/apps/solar_buddy/settings.example.json |
Provides configurable thresholds, timing, and appliance loads. |
badge/apps/solar_buddy/README.md |
Documents controls, setup, credentials, and deployment. |
badge/apps/solar_buddy/http_client.py |
Implements bounded, incremental socket HTTP requests. |
badge/apps/solar_buddy/hardware.py |
Adds optional shake detection and case-light feedback. |
badge/apps/solar_buddy/ha_client.py |
Coordinates sensor polling and Wi-Fi recovery. |
badge/apps/solar_buddy/energy.py |
Validates power readings, freshness, and mood transitions. |
badge/apps/solar_buddy/demo.py |
Supplies simulated power and failure scenarios. |
badge/apps/solar_buddy/controller.py |
Manages navigation, operating modes, and application state. |
badge/apps/solar_buddy/config.py |
Loads and validates settings and credentials. |
badge/apps/solar_buddy/clock.py |
Provides wrap-safe timing helpers. |
badge/apps/solar_buddy/character.py |
Draws and animates the solar character. |
badge/apps/solar_buddy/browser_http.py |
Provides asynchronous browser requests for the simulator. |
badge/apps/solar_buddy/advisor.py |
Tracks sustained surplus for appliance recommendations. |
badge/apps/solar_buddy/.gitignore |
Excludes private credentials and local settings from Git. |
badge/apps/solar_buddy/__init__.py |
Connects the app to the badge runtime and lifecycle. |
Review effort: Balanced
Comment on lines
+121
to
+122
| if len(ages) > 2 and min(ages[1], ages[2]) > max_age_s: | ||
| raise ValueError(entities[1] + " and " + entities[2] + ": stale sensor reports") |
| raise ValueError("Configure WIFI_SSID in the badge's existing secrets.py") | ||
|
|
||
| def tick(self, now): | ||
| if self.wlan.isconnected(): |
This branch has not been deployed
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.


What does this PR do?
Adds Solar Buddy, an animated solar companion that reads Home Assistant power sensors (solar, grid import, grid export) and recommends appliances after a stable surplus. It runs in demo mode with simulated data and no network, or in live mode against a Home Assistant instance. Recommendations are read-only.
socketmodule, soha_client.pyselects a new asynchronous browserfetchclient (browser_http.py) whensys.platform == "webassembly". It is read-only, has timeouts, rejects redirects, limits bodies to 16 KiB and is cancellable. When CORS hides the HTTPDateheader it falls back to the browser's UTC clock for the freshness check and prints a one-time notice./state/solar_buddy_secrets.json. The app ships a credential-freesolar_buddy_secrets.example.jsonand a.gitignorefor the realsolar_buddy_secrets.jsonandsettings.json. The README documents how to provide the file locally, on the badge (mpremote fs cp ... :/state/...) and in the canvas, and warns not to deploy the private file intoapps/.Type of change
badge25/) maintenanceBadge app checklist
badge/apps/<name>/with__init__.pyand a 24x24icon.pngREADME.mdstarts with a one-sentence description, followed by usage and any hardware or network requirementsbadge,screen,image, ...) and logical buttons such asBUTTON_SELECTbadge.ticks_delta)assets/, are PNG where possible, and are as small as practical (onlyicon.png)badge/secrets.pystays empty)Verification so far
python .github/scripts/validate_app_readmes.py badge/apps: passed.Screenshots
Live mode in the Badge Simulator (320x240): the Buddy screen showing LIVE with solar, home and grid-import readings.
How to use it
Left/right switch screens; up/down select a scenario (demo) or appliance; Select opens appliance details, or toggles demo/live in Settings (and retries in live mode); Back returns to Buddy; Menu opens Settings; Home returns to the launcher. Shake briefly wakes the face. Live setup is described in the app README under "Home Assistant credentials".
Licensing and intellectual property
Additional notes
/state. When deploying the whole app folder by USB mass storage, make suresolar_buddy_secrets.jsonis not copied intoapps/solar_buddy/.http.cors_allowed_origins.