Skip to content

Publish batteryBuffered and batteryStart in site state (API/WebSocket/MQTT)#29288

Draft
Copilot wants to merge 6 commits intomasterfrom
copilot/expose-batteryflags-api-mqtt
Draft

Publish batteryBuffered and batteryStart in site state (API/WebSocket/MQTT)#29288
Copilot wants to merge 6 commits intomasterfrom
copilot/expose-batteryflags-api-mqtt

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

External consumers could not reliably determine whether evcc currently allows battery-supported charging without duplicating threshold logic (bufferSoc / bufferStartSoc) outside evcc. This change exposes the existing internal booleans directly in site state.

  • State model updates

    • Added two site keys:
      • batteryBuffered
      • batteryStart
    • Defined in core/keys/site.go.
  • Runtime publication

    • In core/site.go:update(), publish the computed flags from sitePower() on each update cycle.
    • This makes both values available via /api/state, WebSocket events, and MQTT (through existing site key forwarding).
  • Initial publication symmetry

    • In core/site.go:prepare(), publish initial defaults for both flags (false) so retained/initial state is complete before first runtime update.
  • Focused test coverage

    • Added/updated core/site_test.go coverage for:
      • initial publication in prepare()
      • update-path publication in update()
site.publish(keys.BatteryBuffered, batteryBuffered)
site.publish(keys.BatteryStart, batteryStart)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 192.168.1.1
    • Triggering command: /tmp/go-build3560123150/b1496/service.test /tmp/go-build3560123150/b1496/service.test -test.testlogfile=/tmp/go-build3560123150/b1496/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build3560123150/b1416/vet.cfg 0123150/b1236/_p-errorsas .cfg ux-amd64/pkg/tool/linux_amd64/vet -p theus/client_gol-unsafeptr=false t ux-amd64/pkg/too/tmp/go-build3560123150/b1323/vet.cfg -o l7Fm/dUpxlgeN7VYMG16kl7Fm t ux-amd64/pkg/tool/linux_amd64/compile -p github.com/eclip-o t ux-amd64/pkg/too-trimpath (packet block)
  • 224.0.0.251
    • Triggering command: REDACTED, pid is -1 (packet block)
  • api.awattar.at
    • Triggering command: /tmp/go-build3560123150/b1448/tariff.test /tmp/go-build3560123150/b1448/tariff.test -test.testlogfile=/tmp/go-build3560123150/b1448/testlog.txt -test.paniconexit0 -test.timeout=10m0s go1.26.0 -c=4 -nolocalimports -importcfg /tmp/go-build3560123150/b1383/importcfg -pack /home/REDACTED/work/evcc/evcc/messenger/config.go bV1zZTEAN7uQ (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Expose batteryBuffered and batteryStart flags on /api/state and MQTT Publish batteryBuffered and batteryStart in site state (API/WebSocket/MQTT) Apr 20, 2026
Copilot AI requested a review from andig April 20, 2026 20:44
@andig
Copy link
Copy Markdown
Member

andig commented Apr 21, 2026

@copilot Remove tests

@impellerturn
Copy link
Copy Markdown

I checked the PR and the change looks aligned with what I had in my fork (batteryBuffered / batteryStart publication).
Thanks for picking it up!
So far i have nothing to add or comment and would be very happy if this can be merged.
BR impellerturn

@andig
Copy link
Copy Markdown
Member

andig commented Apr 22, 2026

@copilot Remove tests

@impellerturn
Copy link
Copy Markdown

Copilot seems to be reluctant to remove the tests.
Take my PR #29373 to move on.
Thanks impellerturn

@impellerturn
Copy link
Copy Markdown

Now that we removed the tests ofc. the linter complains and blocks the PR.
How shall I proceed?
BR impellerturn

@andig
Copy link
Copy Markdown
Member

andig commented Apr 27, 2026

Linter message says it all:

Error: core/site_test.go:5:2: "time" imported and not used

@impellerturn
Copy link
Copy Markdown

impellerturn commented Apr 27, 2026

Follow-up fix is open:

This keeps the battery flag publication work unchanged while hopefully making the stack mergeable.

@impellerturn
Copy link
Copy Markdown

I the follow up PR ive updated to latest main and let the unnecessary imports be removed.
Please merge that into here and hopefully the checks do pass.

Co-authored-by: Mathias Walter <tolot27@users.noreply.github.com>
Co-authored-by: VallahDieWaldfee <164005630+VallahDieWaldfee@users.noreply.github.com>
Co-authored-by: Michael Geers <michael@geers.tv>
Co-authored-by: Maschga <88616799+Maschga@users.noreply.github.com>
Co-authored-by: andig <cpuidle@gmail.com>
Co-authored-by: Alexandre JARDON <28548335+webalexeu@users.noreply.github.com>
Co-authored-by: DiDu0815 <Dietmar.Dumke@dumke.de>
Co-authored-by: Joni Lehtola <30690083+jonilehtola@users.noreply.github.com>
Co-authored-by: RenatusRo <126881912+RenatusRo@users.noreply.github.com>
Co-authored-by: andig <andi@evcc.io>
Co-authored-by: CiNcH83 <daniel.bechter@gmail.com>
Co-authored-by: docolli <78646938+docolli@users.noreply.github.com>
Co-authored-by: Nazeeh Maxim Kanaaneh <nazih.dev@gmail.com>
Co-authored-by: 0x3d13f <103030707+0x3d13f@users.noreply.github.com>
Co-authored-by: triumfas <triumfas@gmail.com>
Co-authored-by: Michael Heß <GrimmiMeloni@users.noreply.github.com>
Co-authored-by: A. Veseli <adnan.veseli@gmail.com>
Co-authored-by: Wim Haanstra <wim@haanstra.io>
Co-authored-by: Vincent Bakker <mail@bakkerv.nl>
Co-authored-by: Weblate (bot) <hosted@weblate.org>
@impellerturn
Copy link
Copy Markdown

Hi maintainers — small heads-up in case the recent “Run failed at startup” emails on our fork PR looked worrying:

GitHub is still firing a separate workflow on pull_request_target that shows as path BuildFailed (workflow id 4407961, state deleted in the API). Those runs end in startup_failure immediately — unrelated to the normal Default CI, which is what actually validates the change.

No action needed from our side; just mentioning it in case it’s worth cleaning up on the repo when someone has a moment. 🙂

@impellerturn
Copy link
Copy Markdown

impellerturn commented Apr 27, 2026

Merge / conflict update: #29456 merges current master into copilot/expose-batteryflags-api-mqtt (fork branch merge-master-copilot-battery-flags), including resolution of the conflicting files. After #29456 is merged here, this PR should merge cleanly against master again.

Follow-up on #29456: the branch was updated again to address @sourcery-ai review (shared YAML parse + safer force fallback); see inline replies on that PR.

Co-authored-by: Mathias Walter <tolot27@users.noreply.github.com>
Co-authored-by: VallahDieWaldfee <164005630+VallahDieWaldfee@users.noreply.github.com>
Co-authored-by: Michael Geers <michael@geers.tv>
Co-authored-by: Maschga <88616799+Maschga@users.noreply.github.com>
Co-authored-by: andig <cpuidle@gmail.com>
Co-authored-by: Alexandre JARDON <28548335+webalexeu@users.noreply.github.com>
Co-authored-by: DiDu0815 <Dietmar.Dumke@dumke.de>
Co-authored-by: Joni Lehtola <30690083+jonilehtola@users.noreply.github.com>
Co-authored-by: RenatusRo <126881912+RenatusRo@users.noreply.github.com>
Co-authored-by: andig <andi@evcc.io>
Co-authored-by: CiNcH83 <daniel.bechter@gmail.com>
Co-authored-by: docolli <78646938+docolli@users.noreply.github.com>
Co-authored-by: Nazeeh Maxim Kanaaneh <nazih.dev@gmail.com>
Co-authored-by: 0x3d13f <103030707+0x3d13f@users.noreply.github.com>
Co-authored-by: triumfas <triumfas@gmail.com>
Co-authored-by: Michael Heß <GrimmiMeloni@users.noreply.github.com>
Co-authored-by: A. Veseli <adnan.veseli@gmail.com>
Co-authored-by: Wim Haanstra <wim@haanstra.io>
Co-authored-by: Vincent Bakker <mail@bakkerv.nl>
Co-authored-by: Weblate (bot) <hosted@weblate.org>
@impellerturn
Copy link
Copy Markdown

impellerturn commented Apr 27, 2026

Hi maintainers,

master has moved on again, so this PR briefly showed merge conflicts. We opened a small follow-up that only updates the PR head branch (copilot/expose-batteryflags-api-mqtt) with a fresh merge from master and resolves the overlapping config-server files:

#29462 (base: copilot/expose-batteryflags-api-mqtt)

When CI is green there, it would be great if someone could merge #29462 into that branch first — then #29288 should merge cleanly into master again.

@impellerturn
Copy link
Copy Markdown

Hello @andig ,
since you closed #29462 which is the conflict-resolution PR with current master and your repo settings forbid my account pushing to this branch here I need your indication, if you intent to take this feature to master or not.
So: do you want this changes on master?
Otherwise we'll both save time not continuing this discussion.
BR impellerturn

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.

Expose batteryBuffered and batteryStart flags on /api/state and MQTT

3 participants