batpred icon indicating copy to clipboard operation
batpred copied to clipboard

Ohme: ohme_automatic overwrites a user's car_charging_soc with Ohme's battery reading

Open chalfontchubby opened this issue 3 days ago • 1 comments

Raised by Claude on behalf of @chalfontchubby.

Summary

With ohme_automatic: true, Predbat's Ohme component replaces any car_charging_soc the user set in apps.yaml with Ohme's own battery reading, and logs nothing. For a car Ohme cannot read the SoC of, the planner then uses Ohme's figure instead of the car's real level, even when the user has a working SoC sensor from the car's own integration.

The user cannot keep both: ohme_control needs ohme_automatic (ohme.py warns "ohme_control needs ohme_automatic set to register the car"), so turning ohme_automatic off to protect car_charging_soc also loses the auto-wiring and charger control.

Where

apps/predbat/ohme.py, automatic_config() (main at d832bad2):

self.set_arg("car_charging_soc", ["sensor.predbat_ohme_battery_percent"])

This is a plain set_arg, so it overwrites apps.yaml without the one-time note set_arg_auto() would log. A few lines below, car_charging_now already uses set_arg_auto(..., overwrite=False) so that a user's sensor (for example the car's own) is kept.

sensor.predbat_ohme_battery_percent comes from batterySoc.percent on the charge session and falls back to 0 when Ohme has no reading (self.battery = ... or 0).

Example

Reported on a user forum: IOG with an Ohme Go and a 2016 BMW i3. Ohme cannot read the i3's SoC and asks for it in the Ohme app at each plug-in. The car's SoC is available in Home Assistant from the car's own integration, and the user wants Predbat to plan from it.

The case is common: Ohme reads the SoC only for cars it has an API link to, and plenty of cars have a better SoC sensor from their own integration.

Proposal

  1. Recommended: bind car_charging_soc with set_arg_auto(..., overwrite=False), the same as car_charging_now. A user who set car_charging_soc keeps it; everyone else gets Ohme's reading as now.
  2. Alternative: keep overwriting, but switch to set_arg_auto() so the override is at least logged, and document in docs/car-charging.md (Ohme section) that car_charging_soc cannot be overridden.

On the trade-off: PR #6457/#6458 rejected overwrite=False for car_charging_planned, because a stale apps.yaml line would then silently win. car_charging_soc differs in that the user's own entry is usually the better source: the car knows its SoC, while the charger often does not, and Ohme's fallback is 0. Option 1 does carry the same risk for a stale car_charging_soc line left in apps.yaml, so it may want a log line when the user's entry is kept.

Docs to update either way: docs/car-charging.md "Ohme car charger direct integration" currently says ohme_automatic wires car_charging_soc from sensor.predbat_ohme_battery_percent, without saying whether it can be overridden.

chalfontchubby avatar Dec 01 '26 11:12 chalfontchubby

This is an automated first-pass triage from the Predbat triage bot. A maintainer will review it before any action is taken.

Classification: bug · Priority: medium

Bug: With ohme_automatic on, the Ohme component overwrites any car_charging_soc set in apps.yaml with sensor.predbat_ohme_battery_percent, which publishes 0 when Ohme has no SoC for the car, so the planner treats an unreadable car as empty and cannot be pointed at the car's own SoC sensor.

Confirmed against main v9.10.6 (d832bad2) by reading the tree. The ohme test module passes on main (139/139); it asserts the binding when nothing is configured, and has no case for a user-set value (unlike car_charging_now), so this is current behaviour rather than a regression.

What the code does

  • apps/predbat/ohme.py:718 binds it with a plain set_arg, while car_charging_now two lines below uses set_arg_auto(..., overwrite=False) - which is exactly the "keep the user's apps.yaml entry and log that we did" path (component_base.py).
  • apps/predbat/ohme.py:1677 computes self.battery = ... or 0, and publish_data() publishes that as sensor.predbat_ohme_battery_percent, so "no reading" is a real 0, not unknown. fetch.py imports it as the car's SoC unexamined.
  • Ohme is the only charger component that writes car_charging_soc (checked all of apps/predbat). Wallbox, Hypervolt and the gateway leave it unset, and the docs already tell Wallbox and Hypervolt users to set it from the car's own integration - Ohme is the odd one out.
  • The coupling to ohme_control is as described in the issue (ohme.py: "ohme_control needs ohme_automatic set to register the car"), so turning ohme_automatic off is not a workaround for anyone who wants charger control.

A second consequence worth folding into the same decision (from car_manual_soc_config() in apps/predbat/fetch.py, and the "t5" case in test_car_manual_soc.py): manual car SoC tracking from #5678 treats any configured car_charging_soc as authoritative and stands down. Ohme's own binding counts, so a car Ohme cannot read is planned from a hard 0 every cycle with the energy tracking that would otherwise correct it switched off. Proposal 1 fixes the reporter's case (a working sensor of their own), but not the car with no SoC sensor at all - overwrite=False alone does not help there, because with nothing in apps.yaml Ohme still binds the sensor.

Proposal

I agree with option 1: set_arg_auto("car_charging_soc", [...], overwrite=False) keeps the existing "keeping your apps.yaml setting" note for free, and a sentence in the Ohme section of docs/car-charging.md should say the setting may point at the car's own sensor and is then kept. The stale-apps.yaml risk the issue notes for car_charging_planned is smaller here: a wrong car_charging_soc only mis-plans the car, and the "keeping your apps.yaml setting" note names which value is in use.

For the no-sensor case, one of two, both needing a maintainer call on which source should win:

  • do not bind car_charging_soc when Ohme has no reading, letting #5678's energy tracking take over (the gateway component's approach); or
  • keep the binding but stop car_manual_soc_config() counting an auto-bound SoC as the user's own, so the sensor and the tracking can coexist.

I have left that as an open question rather than a defect claim.

Evidence

This was raised on behalf of a forum reporter with no install attached, so there is no predbat.log or predbat_debug.yaml here, and the cause is visible in the code. A debug yaml from an affected install would confirm which entity car_charging_soc lands on and that it reads 0; it would not change the finding.

Possibly related, not duplicates: #4443 (same "Ohme can't read this car's SoC" situation, but about unused slots and off-peak pricing), #3277 (manual SoC reset, Zappi), #4824 (vendor auto-config overwriting args).

springfall2008 avatar Dec 01 '26 11:12 springfall2008