Skip to content

Show the running commit instead of just the release tag for dev deploys - #4653

Draft
chalfontchubby wants to merge 2 commits into
mainfrom
feature/dash-versions
Draft

Show the running commit instead of just the release tag for dev deploys#4653
chalfontchubby wants to merge 2 commits into
mainfrom
feature/dash-versions

Conversation

@chalfontchubby

Copy link
Copy Markdown
Collaborator

Summary

  • coverage/deploy and hass.py now write a git_version.txt marker (source commit, -dirty if the tree has local changes) alongside the deployed .py files, so a dev checkout or the standalone-against-live-HA workflow can be told apart from an actual tagged release.
  • Predbat reads that marker at startup into THIS_VERSION_DISPLAY, shown wherever the version is surfaced for humans (web UI header/menu, the Dashboard page, the predbat.status entity's version attribute, the generated Lovelace dashboard card, and the github.py startup log line). The real THIS_VERSION tag is left untouched everywhere it drives actual logic - the GitHub release-tag match, the HA update entity's installed_version/release_url (changing that would falsely show "update available" forever), the Prometheus version label, and the manual version-select comparison.
  • download.py's predbat_update_move() clears the marker after a real update lands, so a stale dev-commit marker doesn't linger once official release files are installed.
  • Also fixes record_status(), found while testing this on a live deploy: the status entity's last_updated attribute was written via str(datetime.now()) - a naive, sub-second-precision string in a shape str2time() can't parse - so the web dashboard's "Last Updated" field rendered raw microseconds. It's now written via TIME_FORMAT (matching how last_started is already written) using self.now_utc_real - the true wall-clock time, not the PREDICT_STEP-grid-snapped self.now_utc - and parsed/rounded to whole seconds for display in web.py.

Test plan

  • ./run_all --test github, ./run_all --test download, ./run_all --quick, and ./run_all -k web all pass
  • pre-commit (ruff, black, cspell) passes on all touched files
  • Manually verified read_deploy_git_version/clear_deploy_git_version round-trip and the hass.py marker-writer resolves correctly through the symlinked .py files coverage/standalone_ha sets up
  • Verified live on a real deploy: Dashboard/status page now show v8.50.0 (<commit>[-dirty]), and Last Updated shows a clean wall-clock second-precision timestamp after record_status() next fires

🤖 Generated with Claude Code

Comment thread apps/predbat/download.py
cmd += "mv -f {} {} && ".format(os.path.join(this_path, file + "." + tag), os.path.join(this_path, file))
cmd += "echo 'Update complete'"
os.system(cmd)
clear_deploy_git_version(this_path)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might want to be before the os.system(cmd) as touching the files triggers a restart

@chalfontchubby
chalfontchubby marked this pull request as draft August 22, 2026 21:55
…e running version is rather than a tag

Also fix record_status() writing the status entity's last_updated attribute
via str(datetime.now()) - a naive, sub-second-precision string in a format
str2time() can't parse - so the web dashboard's Last Updated field rendered
raw microseconds instead of a clean timestamp. Now written via TIME_FORMAT
like last_started already is, and parsed/rounded to whole seconds for
display in web.py.

Uses self.now_utc_real rather than self.now_utc: the latter is deliberately
snapped to the PREDICT_STEP grid for the simulation (see update_time()), so
using it here made Last Updated show a rounded, past minute instead of the
actual time record_status() ran. now_utc_real is the same true wall-clock
source last_started already uses (self.started_time = self.now_utc_real).

Also fixes is_running(): it reads the same last_updated attribute, and its
naive datetime.now() comparison broke once the attribute became tz-aware
("can't subtract offset-naive and offset-aware datetimes"), which was
showing as Unhealthy on the web dashboard. Now compares against
datetime.now(timezone.utc).

Reorders predbat_update_move() per review: clear_deploy_git_version() now
runs before the mv, so the marker is gone before any new process (including
one started by a hot-reload the mv itself triggers) could read it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants