Skip to content

fix: make Eco-Smart "Off" reachable/stable from Home Assistant (esm stays pegged)#30

Open
xtux77 wants to merge 1 commit into
botts7:mainfrom
xtux77:fix/eco-smart-disable-rebound
Open

fix: make Eco-Smart "Off" reachable/stable from Home Assistant (esm stays pegged)#30
xtux77 wants to merge 1 commit into
botts7:mainfrom
xtux77:fix/eco-smart-disable-rebound

Conversation

@xtux77

@xtux77 xtux77 commented Jul 23, 2026

Copy link
Copy Markdown

Fixes #29.

The eco_mode select (and the "Solar charging" switch) cannot be set to Off from Home Assistant — it bounces back to the previous mode. Two independent causes, both fixed here.

1. Read-back ignored ese (src/wb_ble.cpp)

g_ecos returns ese (master enable) + esm (mode). When Eco-Smart is off, the charger leaves esm pegged at its last value (e.g. 2) and only clears ese. Publishing raw esm made HA show a phantom "Solar + Grid".

-            merged["eco_mode"] = d["r"]["esm"] | 0;
+            merged["eco_mode"] = (d["r"]["ese"] | 0) ? (d["r"]["esm"] | 0) : 0;

2. Disabling write was self-defeating (src/wb_mqtt.cpp)

Selecting "Off" sent {esm:0, ese:0} in one shot; the charger ignores an esm change that arrives together with ese:0, so esm never cleared. Now disabling does a two-step write (mode change first with the flag still on, then drop the flag), mirroring the known-good manual BAPI workaround.

Testing

Pulsar MAX Pro, charger FW 6.11.25, gateway v3.2.1:

  • Before: selecting Off in HA → select snaps back to "Solar + Grid"; g_ecos = {"ese":0,"esm":2}.
  • After: selecting Offg_ecos = {"ese":0,"esm":0}, HA select stays on Off, no bounce.
  • Selecting Full Green / Solar + Grid still works (unchanged ese:1 path).

Changes are limited to the two mode paths; eco_power and every other control are untouched.

The `eco_mode` select bounces back to its previous value whenever a user
tries to select "Off" from Home Assistant. Two independent problems:

1. Read-back (wb_ble.cpp): the gateway publishes `eco_mode` from the raw
   `esm` field and discards `ese`. When Eco-Smart is disabled the charger
   leaves `esm` pegged at its last value (e.g. 2), so HA shows a phantom
   "Solar + Grid" even though the feature is off (ese=0). Now the reported
   mode is gated on `ese`: eco_mode = ese ? esm : 0.

2. Write (wb_mqtt.cpp): selecting "Off" sends {esm:0, ese:0} in one shot.
   The charger ignores the `esm` change when it arrives together with
   ese=0 (disabling), so `esm` never actually clears. Disabling now uses a
   two-step write ({esm:0,ese:1} then {esm:0,ese:0}) so the mode is
   accepted first and the master flag dropped after, leaving {ese:0,esm:0}.

Verified against a Pulsar MAX Pro (charger FW 6.11.25, gateway v3.2.1):
after selecting Off, g_ecos reads {ese:0, esm:0} and the HA select stays
on "Off" without bouncing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

Eco-Smart "Off" unreachable from Home Assistant — eco_mode select bounces back (esm stays pegged)

1 participant