You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[Growatt with Solar Assistant](#growatt-with-solar-assistant)|[Solar Assistant](https://solar-assistant.io/help/home-assistant/setup)|[spa.yaml](https://raw.githubusercontent.com/springfall2008/batpred/main/templates/solar_assistant_growatt_spa.yaml) or [sph.yaml](https://raw.githubusercontent.com/springfall2008/batpred/main/templates/solar_assistant_growatt_sph.yaml)|
@@ -559,6 +560,173 @@ You need to have a Solar Assistant installation <https://solar-assistant.io>
559
560
560
561
Growatt has two popular series of inverters, SPA and SPH. Copy the template that matches your model from templates over the top of your `apps.yaml`, and edit inverter and battery settings as required. Yours may have different entity IDs on Home Assistant.
561
562
563
+
## Hanchu iESS
564
+
565
+
The Hanchu iESS has no native Predbat integration. Control is implemented via Predbat's generic Service API: Predbat calls four service hooks (`charge_start_service`, `charge_stop_service`, `discharge_start_service`, `discharge_stop_service`), all of which point at a single Home Assistant script that writes the corresponding time slots directly to the device via `hanchuess.device_control`.
566
+
567
+
Copy the template [hanchu_cloud.yaml](https://raw.githubusercontent.com/springfall2008/batpred/main/templates/hanchu_cloud.yaml) over your `apps.yaml` and follow the steps below.
568
+
569
+
### Hanchu iESS Prerequisites
570
+
571
+
Install the [hanchu-ess-ha](https://github.com/upton68/hanchu-ess-ha) integration via HACS and configure it with your Hanchu cloud account credentials. Confirm that inverter and battery sensors are appearing in Home Assistant before proceeding.
572
+
573
+
### Step 1 — Create helpers
574
+
575
+
Create the following helpers in Home Assistant (Settings → Devices & Services → Helpers):
| `input_text.hanchu_last_mode_action` | Hanchu Last Mode Action |
589
+
590
+
`input_text.hanchu_last_mode_action`tracks the last mode successfully applied so the bridge script can skip a redundant API call when Predbat reasserts a state that is already active.
591
+
592
+
### Step 2 — Create the bridge script
593
+
594
+
All four of Predbat's service hooks call the same script, `script.hanchu_set_state_queued`, passing a `mode_action` field to indicate which state to apply. The script runs with `mode: queued` so if Predbat fires two calls close together — for example stopping a discharge and starting a charge in the same plan-evaluation cycle — Home Assistant queues the second call behind the first rather than letting both `device_control` calls race each other.
595
+
596
+
Create a new script (Settings → Automations & Scenes → Scripts → Add Script → Edit in YAML) and paste the following, replacing `YOURSERIAL` with your device serial number as it appears in your HA entity IDs, and replacing `notify.notify` with your own mobile notification service:
597
+
598
+
```yaml
599
+
alias: Hanchu Set State Queued
600
+
mode: queued
601
+
fields:
602
+
mode_action:
603
+
required: true
604
+
selector:
605
+
select:
606
+
options:
607
+
- charge_start
608
+
- charge_stop
609
+
- discharge_start
610
+
- discharge_stop
611
+
sequence:
612
+
- variables:
613
+
# mode_action is sometimes only populated under `data` rather than as a
614
+
# bare template variable, depending on whether the script is invoked from
615
+
# the HA UI or by a real service call from Predbat's AppDaemon dispatch.
616
+
# Check both so it works reliably either way.
617
+
act: >-
618
+
{% if mode_action is defined %}{{ mode_action }}
619
+
{% elif data is defined and data.mode_action is defined %}{{ data.mode_action }}
The script always writes all four time slot fields (`TCT_START_1`, `TCT_END_1`, `TDT_START_1`, `TDT_END_1`) on every call, zeroing whichever pair is not the active mode. This keeps charge and discharge mutually exclusive on the device without relying on separate stop/start calls landing in the right order.
694
+
695
+
### Step 3 — Add the soc_kw template sensor
696
+
697
+
Predbat requires a `soc_kw` sensor reporting battery state of charge in kWh. Add the following to your `configuration.yaml`:
Replace `YOURSERIAL` with your device serial number and `NN.NN` with your total battery capacity in kWh (for example `18.80` for a dual 9.4 kWh system). Restart Home Assistant after adding this.
712
+
713
+
### Step 4 — Configure apps.yaml
714
+
715
+
- Replace `YOURSERIAL` throughout the template with your device serial number as it appears in your HA entity IDs
716
+
- Adjust `inverter_limit`, `inverter_limit_charge`, `inverter_limit_discharge`, `inverter_limit_export` and `battery_rate_max` to match your inverter and battery rated capacity in watts
717
+
- Delete the `template: True` line to allow Predbat to start
718
+
- Configure your energy rates — see [Energy Rates](https://springfall2008.github.io/batpred/energy-rates/)
719
+
720
+
> **Note:** Double-check that `inverter_limit` is spelled exactly as shown — an accented character (for example `é` instead of `e` from autocorrect) will cause Predbat to silently ignore the setting and fall back to its own default.
721
+
722
+
### Hanchu Notes
723
+
724
+
- **Skipping redundant calls:** Predbat re-evaluates its plan on its normal cycle and can re-issue the same service call mid-window, simply reasserting the plan rather than changing anything. The `input_text.hanchu_last_mode_action` check skips the API call entirely when the requested mode is already the last one successfully applied. The tracker only updates after a confirmed successful write, so a failed attempt still retries correctly on the next cycle.
725
+
- **Behaviour on Predbat restart:** Whenever Predbat restarts it issues both `charge_stop_service` and `discharge_stop_service` in quick succession to put the inverter into a known neutral state. This is expected behaviour. The queued script handles this cleanly — if one of the calls matches the already-active state it is skipped as redundant; the other runs if it represents a real change. You may see one or both fire immediately after any restart.
726
+
- **Automation latency:** Start/stop commands are occasionally delayed by up to ~2 minutes due to HA scheduling. This has not caused any practical issues in production use.
727
+
- **No charge/discharge enable toggle:** Hanchu has no explicit enable/disable for charge or discharge. The slot zeroing mechanism (setting both start and end to `00:00:00`) is the disable method.
728
+
- **Min SOC:** Managed via `battery_min_soc` pointing directly to the Hanchu entity — no separate Predbat reserve setting needed.
729
+
562
730
## Huawei
563
731
564
732
Copy the Huawei template over your existing `apps.yaml` and modify all entity IDs, battery capacity and power limits for your own system:
0 commit comments