Conversation
_battery_data_as_object is only evaluated once in read_evcc_config_on_startup(). If the integration starts while evcc itself is still starting (add-on update, HA/host restart), the 'battery' object is missing or empty, the flag stays False and all battery sensors look for the removed 'batterySoc' key until the integration is reloaded. evcc stopped publishing batterySoc & co. with 0.301.0 (core/site.go only publishes keys.Battery since then), so use that version as fallback - also when 'battery' is present but still empty. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Hi Claude - I have two questions for you...
|
|
Hi marq24, this is Dennis, the human behind the PR, answering myself now. You're right on both points, and sorry about that. To be transparent: I used Claude Code to track this down, and it opened the PR on my behalf without either of us reading your contribution rules first. That's on me. I've now read the checklist, and I understand if you'd rather close this. On your first point, I agree: a version-based guess is the wrong place to fix it. evcc already exposes a readiness signal: What I actually saw: evcc 0.316.0 as an HA add-on, ha-evcc 2026.9.5. The add-on auto-updated at 12:28, the integration reloaded at 12:29, and all If you'd like me to rework the PR in that direction, I'm happy to do so. Otherwise feel free to close it. Thanks for maintaining the integration :)) |
|
Hi Dennis, thanks for you kind reply - I hope you can understand, that it can be quite challenging for me as human to deal with "fíxes" & "suggested fixes" that IMHO are not coming close to fix anything... So if there is really a I'll be back! |
|
looks like at the end Claude was also not so completely wrong with his suggestion... [even if I still want to keep the version check just as fallback]... I will update the main branch shortly and It would be cool, if you would review the change if it's reasonable for you too |
|
Hi marq24, thanks a lot, I really appreciate that you took the time to look into it yourself. And yes, I can fully understand your point. Getting "fixes" that don't really fix anything must be pretty tiring, especially when you maintain a project like this in your spare time. Checking for startupCompleted and keeping the version check only as a fallback sounds like the right way to me. Once your change is on main, I'll gladly have a look at it and also test it on my own setup. My plan: install the main branch version, temporarily disable the reload automation I set up as a workaround, then restart the evcc add-on a few times while HA is running and check that the battery sensors come up on their own. I'll enable debug logging for the integration during the test, so I can send you the relevant log lines if something doesn't look right. I'll report back here with the results. Thanks again, |
|
changes are in main now |
|
Hi marq24, thanks! I just checked, but I think the push didn't make it to GitHub yet: main is still at d5b68ca from Sep 25 on my end. Could you have a quick look? As soon as it's there, I'll test it and report back. Dennis |
|
sorry my bad - "now" the push is there |
|
Hi marq24, I installed da026d9 on my system and tested it. Works for me, thanks! What I did: restarted the evcc add-on while HA was running and reloaded the integration at the exact moment evcc was answering again but didn't have all data yet. Result: the battery sensors came up right away, pv and grid as well. One thing I noticed in the debug log that might be interesting for you: at that moment evcc already reported startupCompleted: true, but the battery object was still missing: is_evcc_available(): 'http://localhost:7070' is AVAILABLE - evcc startupStatus: True So in my case it was the version fallback (0.301.0) that did the trick. Looking at evcc's cmd/root.go, startupCompleted is set to true right after the devices are created, but before the site loop has published its first values. So keeping the version check as a fallback was definitely the right call. Thanks again for the quick fix! |
|
Mhhhh... when evcc report, that starup is completed... but at the end of the day there are still components that report no data... then IMHO its worth to let the evcc guys know, that the info the status is reporting might not be 100% correct. |
|
I hope it's fine for you, when I close this one? |
Problem
After an evcc restart (e.g. an add-on update) or an HA/host reboot, all battery sensors (
sensor.evcc_battery_soc,battery_power,battery_capacity, …) can stayunknownpermanently, while evcc itself (/api/state→battery.soc) reports correct values. Reloading the integration fixes it — same as reported in #244.Cause
_battery_data_as_objectis only evaluated once inread_evcc_config_on_startup(). When the integration starts while evcc is still starting up, thebatteryobject is missing (or empty), so the flag staysFalse. The version fallback can never kick in (>= 999.209.8), so the integration creates the prefix sensors that readbatterySoc,batteryPower, … — keys that evcc no longer publishes.evcc dropped these keys in 0.301.0:
core/site.goin 0.300.2 still hassite.publish(keys.BatterySoc, …), since 0.301.0 onlysite.publish(keys.Battery, site.battery)is left.Fix
0.301.0as the version fallback instead of the placeholder999.209.8.batteryis missing/None), so an emptybatteryobject at startup is covered too.Observed with evcc 0.316.0 (HA add-on) and ha-evcc 2026.9.5: the add-on update restarted evcc, the integration reloaded one minute later and battery sensors stayed
unknownuntil a manual reload.🤖 Generated with Claude Code