diff --git a/goodwe_controller/CHANGELOG.md b/goodwe_controller/CHANGELOG.md index 99cc06d..068d416 100644 --- a/goodwe_controller/CHANGELOG.md +++ b/goodwe_controller/CHANGELOG.md @@ -2,6 +2,7 @@ ### Not in a release yet +- **Each battery can have its own round-trip efficiency, and a battery that loses too much is not charged from the grid for the price gap.** New optional setting per inverter, *Round-trip efficiency* (`inverters.round_trip_eff`, 0.5 to 1). Set on a battery, its cheap hour counts at its price divided by it, so a battery at 0.75 is not charged at night for the day when a battery at 0.86 would be. The day plan and Home use each battery's own number, and the status page shows it, or "not set". If you set it, lower *Battery cycle cost* to wear only: the add-on never changes that value. Not set, nothing changes. How the work is split between the batteries is unchanged ([[TARIFF-30]]). - **Solar no longer writes over another writer's car current or phases.** If something else changes the car's current or its phases, also in the middle of a phase change, the add-on writes nothing over it. After 30 seconds it stops writing until you press Solar, and warns CHARGER_OTHER once. Manual does the same for a current changed during its own phase change ([[EV-22]]). - **A car phase change whose current the charger refuses no longer sends that current five times.** After three refused tries the add-on stops at once and warns CHARGER_REFUSED; the car stays at 0 A until you change something. A value you change meanwhile gets its own three tries ([[EV-59]]). - **A car current the add-on cannot send because of an error is no longer sent again every second.** It counts as a write the charger did not take: 3 tries a minute apart, then the add-on stops and warns CHARGER_REFUSED. The error is logged once per current ([[EV-56]]). diff --git a/goodwe_controller/DOCS.md b/goodwe_controller/DOCS.md index b46f044..76a46c8 100644 --- a/goodwe_controller/DOCS.md +++ b/goodwe_controller/DOCS.md @@ -183,6 +183,7 @@ The label and description each setting shows on the Configuration tab, in tab or | Hardware · Inverter list | Battery power entity (W) (optional) | `inverters.batt_entity` | This inverter's own battery power sensor. Leave it empty if it has none. | | Hardware · Inverter list | Battery power sign is reversed (optional) | `inverters.batt_invert` | Switch this on if this inverter's sensor shows giving power as a negative number. | | Hardware · Inverter list | Usable battery capacity (kWh) (optional) | `inverters.capacity_kwh` | This battery's usable capacity from its datasheet. Fill it in on every inverter or on none. The add-on then shares the work by the energy each battery has left. | +| Hardware · Inverter list | Round-trip efficiency (0.5 to 1) (optional) | `inverters.round_trip_eff` | The share of energy this battery gives back, for example 0.86. Leave it empty if unknown. If you set round-trip efficiency, lower the cycle cost to wear only. | | Hardware | RS485 emergency stop is fitted | `estop_fitted` | Switch this on if the emergency stop is installed. It only changes a warning on the status page. | | Hardware | Battery modes | `battery_modes_enabled` | Give each battery an on and off switch and a mode, set on the Batteries screen. | | Hardware | Solar forecast, today (kWh) | `pv_forecast_entity` | Optional. A forecast sensor with today's remaining solar energy, such as Forecast.Solar or Solcast. A battery then buys only what the sun will not give. | @@ -229,7 +230,7 @@ The label and description each setting shows on the Configuration tab, in tab or | Tariff | Current price entity (older) | `price_now_entity` | The older way to get a price, used only to charge in a cheap window during maintenance. Do not combine it with a dynamic price source. | | Tariff | Average price entity (older) | `price_avg_entity` | The average the current price is compared with. Use it only with the current price entity, not with a dynamic price source. | | Tariff | Trade on the price spread | `arbitrage_enabled` | Charge in the cheapest hour and draw the battery down in the dearest, when the spread covers the cost. Turning it off does not turn the price feed off. | -| Tariff | Battery cycle cost (EUR/kWh) | `cycle_cost_threshold_eur` | What one full battery cycle costs per kWh. A smaller price spread is not traded, and the value is a product choice, not a measured one. | +| Tariff | Battery cycle cost (EUR/kWh) | `cycle_cost_threshold_eur` | Cost of one cycle per kWh. Smaller gaps are not traded. A product choice, not a measured one. If you set round-trip efficiency, lower the cycle cost to wear only. | | Tariff | Trading keeps at least (%) | `arbitrage_soc_floor` | Price trading will not draw the battery below this level. It is separate from the maintenance settings. | | Tariff | Trading charges at most (%) | `arbitrage_soc_ceiling` | Price trading will not charge the battery above this level. | | Maintenance | Run the monthly battery cycle | `maintenance_enabled` | Once a month, empty the battery deeply, charge it full and hold it there, so its level reading stays accurate. Off by default. | @@ -283,6 +284,7 @@ When the add-on refuses to start, each reason names the setting by its label and - **Battery power entity** (`batt_entity`): on the reference installation this is holding register 0x0518, read by the control board. The wrong-direction checks and the opposing-inverters alarm both grade each inverter against it. - **Inverter list** (`inverters`): empty means the single-inverter settings describe the one inverter you have. Filled in, the list replaces them and nothing is inherited: each entry names its own setpoint entity, rating and cut-out level, so no inverter is judged by another's numbers. “Inverter setpoint entity” must then be empty, and the add-on refuses to start when both are set. Each entry's name keys its own safety stop and records in the add-on's state, so two entries may not share one. - **Usable battery capacity** (`inverters.capacity_kwh`): read only to share the site target by the energy each battery has left rather than by its rating. The reference batteries are 5000 W with 15.36 kWh and 4600 W with 20.48 kWh, so the two ways of sharing give the work to different batteries. Stated on some entries and not others, the add-on refuses to start. +- **Round-trip efficiency** (`inverters.round_trip_eff`, 0.5 to 1, optional per entry): the share of the energy a battery gives back after it took it in, measured by you (for example 0.86 and 0.75 on two batteries). Set, the cheap hour for that battery counts at its price divided by this number, and it is charged from the grid only when the price gap still covers that and the cycle cost. Not set, nothing changes. A battery can have it while another does not. The day plan then uses the square root of it for each way in and out. **Settings impact:** *Battery cycle cost* then means wear only, so lower it when you set this; the add-on never changes your cycle cost by itself. Taking the key out again leaves the add-on as it was; nothing is stored. The status page shows each battery's value, or "not set". How the work is split between the batteries when giving power does not depend on it. - **Solar production entities** (`pv_entity`, `pv_entities`, `pv_invert_entities`): measurement only, no control behaviour changes. The unit is read off each entity, so a sensor without one is refused rather than guessed. With several entities, one that stops reporting gives no site total at all, because a partial sum looks like a real one. Setting `pv_entities` ignores `pv_entity`. - **Where the meter reading comes from** (`meter_source`): 'off' keeps “Grid power entity”. ha_dsmr follows the DSMR integration, mqtt_p1 reads an MQTT topic, ha_signed reads one signed entity (what a HomeWizard P1 publishes), and homewizard_local polls the meter's own local API. Only homewizard_local can tell "the meter did not answer" from "the value did not change", so the stuck-meter alarm only means something there. - **Grid import and export entities** (`p1_import_entity`, `p1_export_entity`, `p1_net_entity`): the add-on computes net power itself, so the sign convention lives in tested code rather than in a template sensor. diff --git a/goodwe_controller/app/ui_text/en.json b/goodwe_controller/app/ui_text/en.json index 215462c..51cf249 100644 --- a/goodwe_controller/app/ui_text/en.json +++ b/goodwe_controller/app/ui_text/en.json @@ -105,7 +105,7 @@ "toast": {"started": "Control started.", "stopped": "Control stopped.", "done": "Done.", "failed": "That did not work. Try again."}, "offline": {"name": "Cannot reach the add-on", "description": "The page tries again every 3 seconds."}, "setup_only": {"name": "Setup: nothing is controlled yet", "description": "Nothing is sent to any inverter until setup is saved and the add-on restarts.", "control": "Control starts after setup.", "open": "Open Setup"}, - "batteries": {"name": "Batteries", "description": "To choose a mode for each battery, turn on battery modes in the settings.", "level": "Level", "now": "Now", "stored": "Stored", "round_trip": "Round trip", "round_trip_unset": "not set", "mode": "Mode", "settings": "Change inverter settings", + "batteries": {"name": "Batteries", "description": "To choose a mode for each battery, turn on battery modes in the settings.", "level": "Level", "now": "Now", "stored": "Stored", "round_trip": "Efficiency", "round_trip_unset": "not set", "mode": "Mode", "settings": "Change inverter settings", "on": "On", "off": "Off", "choice": { "solar_first": {"name": "Solar first", "description": "Charges from solar before the other batteries, covers the house and never charges from the grid."}, diff --git a/goodwe_controller/app/ui_text/nl.json b/goodwe_controller/app/ui_text/nl.json index 6bec08d..726c9f5 100644 --- a/goodwe_controller/app/ui_text/nl.json +++ b/goodwe_controller/app/ui_text/nl.json @@ -102,7 +102,7 @@ "toast": {"started": "Regeling gestart.", "stopped": "Regeling gestopt.", "done": "Klaar.", "failed": "Dat lukte niet. Probeer opnieuw."}, "offline": {"name": "Add-on niet bereikbaar", "description": "De pagina probeert het elke 3 seconden opnieuw."}, "setup_only": {"name": "Installatie: nog niets wordt geregeld", "description": "Er gaat niets naar een omvormer tot de installatie bewaard is en de add-on herstart.", "control": "De regeling start na de installatie.", "open": "Installatie openen"}, - "batteries": {"name": "Batterijen", "description": "Zet batterijmodi aan in de instellingen om per batterij een modus te kiezen.", "level": "Laadniveau", "now": "Nu", "stored": "Opgeslagen", "round_trip": "Rendement heen en terug", "round_trip_unset": "niet ingesteld", "mode": "Modus", "settings": "Instellingen van omvormers wijzigen", + "batteries": {"name": "Batterijen", "description": "Zet batterijmodi aan in de instellingen om per batterij een modus te kiezen.", "level": "Laadniveau", "now": "Nu", "stored": "Opgeslagen", "round_trip": "Rendement", "round_trip_unset": "niet ingesteld", "mode": "Modus", "settings": "Instellingen van omvormers wijzigen", "on": "Aan", "off": "Uit", "choice": { "solar_first": {"name": "Eerst zonne-energie", "description": "Laadt met zonne-energie vóór de andere batterijen, dekt het huis en laadt nooit van het net."}, diff --git a/goodwe_controller/app/uilayout.py b/goodwe_controller/app/uilayout.py index 8bbe1ea..559ec97 100644 --- a/goodwe_controller/app/uilayout.py +++ b/goodwe_controller/app/uilayout.py @@ -93,8 +93,9 @@ ROSTER_FIELDS = ( Field("inverters.capacity_kwh", NUMBER, "kWh", step=0.1, show=_LISTED, wizard=2), # TARIFF-30: optional, 0.5 to 1; not shown for the flat single inverter - # (it stores no per-unit keys) and not in the setup wizard. - Field("inverters.round_trip_eff", NUMBER, step=0.01, show=_LISTED), + # (it stores no per-unit keys). + Field("inverters.round_trip_eff", NUMBER, step=0.01, show=_LISTED, + wizard=2), ) GROUPS = ( diff --git a/goodwe_controller/config.yaml b/goodwe_controller/config.yaml index 24010e2..277767d 100644 --- a/goodwe_controller/config.yaml +++ b/goodwe_controller/config.yaml @@ -969,7 +969,8 @@ schema: # no `max_w` would have to borrow a rating, which is the sibling-grading # defect DEV-02 removed; `bms_soc_floor` is SAFETY-32's (options block above). # The optional keys are the sensors, whose absence honestly means "this unit - # reports none", and `capacity_kwh`. + # reports none", `capacity_kwh`, and TARIFF-30's `round_trip_eff` (0.5 to 1; + # absent means today's behaviour exactly, so nothing is invented for it). # # ⚠️ THIS BLOCK IS DECLARED BEFORE `max_w:` ON PURPOSE. `max_w` now appears # TWICE under `schema:` - once nested here, once flat below - and a reader @@ -986,7 +987,6 @@ schema: batt_entity: str? batt_invert: bool? capacity_kwh: float(0.1,200)? - # TARIFF-30: optional per entry, 0.5 to 1. Not set = today's behaviour. round_trip_eff: float(0.5,1)? estop_fitted: bool diff --git a/goodwe_controller/test_inverter.py b/goodwe_controller/test_inverter.py index 217c7fc..8562616 100644 --- a/goodwe_controller/test_inverter.py +++ b/goodwe_controller/test_inverter.py @@ -1558,13 +1558,13 @@ check("...and the schema half declares it as a LIST OF OBJECTS whose `name`, " "refuses every options blob written before it existed", set(_decl9) == {"name", "setpoint_entity", "max_w", "bms_soc_floor", "soc_entity", "batt_entity", "batt_invert", - "capacity_kwh"} + "capacity_kwh", "round_trip_eff"} and not any(_decl9[k].endswith("?") for k in ("name", "setpoint_entity", "max_w", "bms_soc_floor")) and all(_decl9[k].endswith("?") for k in ("soc_entity", "batt_entity", "batt_invert", - "capacity_kwh"))) + "capacity_kwh", "round_trip_eff"))) # ⚠️ NOTHING IS INHERITED, AND THIS IS DEV-02 RESTATED AS A CONFIG RULE. # ⚠️ THE FLAT KEYS ARE SET TO REAL ENTITIES HERE, AND THAT IS THE WHOLE CHECK. diff --git a/goodwe_controller/test_tariff30.py b/goodwe_controller/test_tariff30.py index d2f5298..f87119f 100644 --- a/goodwe_controller/test_tariff30.py +++ b/goodwe_controller/test_tariff30.py @@ -312,6 +312,18 @@ def _t1(): and share(bl, B) == -4600) check("T1 reason: today's sentence (the buy leg is sized by whom it " "charges)", "charging 5000 W" in last["reason"]) + imp = lambda rs, load: [max(0.0, load - sum(r["plant"].values())) # noqa: E731 + for r in rs] + check("N11 no more grid import than base on the same inputs, on every " + "cycle and in total (the unit that fails its leg imports less)", + all(a <= b + 1e-6 for a, b in zip(imp(rows, 500.0), + imp(base_rows, 500.0))) + and sum(imp(rows, 500.0)) < sum(imp(base_rows, 500.0))) + d_eta, _c1 = drive(ETA, load=2000.0, variant="modes_off") + d_base, _c2 = drive(NONE2, load=2000.0, variant="modes_off") + check("N11 discharging: the same import, cycle by cycle, with and " + "without an efficiency (no window exception)", + imp(d_eta, 2000.0) == imp(d_base, 2000.0) and len(d_eta) > 5) @guarded("T5") @@ -633,7 +645,8 @@ def _t24(): c.mode_tick = modetrade.Tick({}, dict(roles), None, 0.0, None) cs.append(c.pack_weights(tgt)) check(f"T28 modes on {sorted(roles.values())}: the weights are the " - f"base's", cs[0] == cs[1]) + f"base's", present(nth(cs, 0), nth(cs, 1)) + and nth(cs, 0) == nth(cs, 1)) @guarded("T29") @@ -1040,8 +1053,8 @@ def _t50(): def _t34(): sentence = "If you set round-trip efficiency, lower the cycle cost to " \ "wear only." - nl_sentence = "Als u het rendement heen en terug instelt, verlaag dan " \ - "de kosten van een batterijcyclus tot alleen slijtage." + nl_sentence = "Stelt u het rendement in, verlaag dan de kosten van een " \ + "batterijcyclus tot alleen slijtage." en = open(os.path.join(HERE, "translations", "en.yaml"), encoding="utf-8").read() nl = open(os.path.join(HERE, "translations", "nl.yaml"), @@ -1119,7 +1132,7 @@ def _t41(): nl = json.load(open(os.path.join(HERE, "app", "ui_text", "nl.json"), encoding="utf-8"))["home"]["batteries"] check("T41 short plain words in en and nl", - en.get("round_trip") == "Round trip" + en.get("round_trip") == "Efficiency" and en.get("round_trip_unset") == "not set" and nl.get("round_trip") and nl.get("round_trip_unset")) js = open(os.path.join(HERE, "app", "static", "app.js"), diff --git a/goodwe_controller/test_translations.py b/goodwe_controller/test_translations.py index 6ee0d59..91e0d34 100644 --- a/goodwe_controller/test_translations.py +++ b/goodwe_controller/test_translations.py @@ -75,7 +75,7 @@ check(f"the option surface was actually read - {len(ORDER)} options, not zero", check("...and the repeatable `inverters:` section's per-entry keys were read " "too, which is the half a top-level-only reader would miss", NESTED.get("inverters", [])[:2] == ["name", "setpoint_entity"] - and len(NESTED["inverters"]) == 8) + and len(NESTED["inverters"]) == 9) # TARIFF-30: + round_trip_eff print("\n2. AC: every option and every per-entry key is translated, in BOTH " "languages") @@ -282,7 +282,7 @@ check("...and the accepted subset really does round-trip the shipped files - " f"per-entry keys came back out of each, which is what says the " f"strictness above is not just refusing everything", all(len(TR[lg]["configuration"]) == len(ORDER) - and len(TR[lg]["configuration"]["inverters"]["fields"]) == 8 + and len(TR[lg]["configuration"]["inverters"]["fields"]) == 9 for lg in LANGS)) print(" ⚠️ the licence for this hand parser is NOT this file. " "tools/supervisor_shape_probe.py section F loads the same two files with " diff --git a/goodwe_controller/translations/en.yaml b/goodwe_controller/translations/en.yaml index f0d3b11..717ba7b 100644 --- a/goodwe_controller/translations/en.yaml +++ b/goodwe_controller/translations/en.yaml @@ -81,7 +81,7 @@ configuration: description: "This battery's usable capacity from its datasheet. Fill it in on every inverter or on none. The add-on then shares the work by the energy each battery has left." round_trip_eff: name: "Round-trip efficiency (0.5 to 1) (optional)" - description: "Share of the energy that comes back out of this battery after it went in, for example 0.86. Leave it empty if you do not know it. If you set round-trip efficiency, lower the cycle cost to wear only." + description: "The share of energy this battery gives back, for example 0.86. Leave it empty if unknown. If you set round-trip efficiency, lower the cycle cost to wear only." estop_fitted: name: "Hardware · RS485 emergency stop is fitted" description: "Switch this on if the emergency stop is installed. It only changes a warning on the status page." @@ -222,7 +222,7 @@ configuration: description: "Charge in the cheapest hour and draw the battery down in the dearest, when the spread covers the cost. Turning it off does not turn the price feed off." cycle_cost_threshold_eur: name: "Tariff · Battery cycle cost (EUR/kWh)" - description: "What one full battery cycle costs per kWh. A smaller price spread is not traded, and the value is a product choice, not a measured one. If you set round-trip efficiency, lower the cycle cost to wear only." + description: "Cost of one cycle per kWh. Smaller gaps are not traded. A product choice, not a measured one. If you set round-trip efficiency, lower the cycle cost to wear only." arbitrage_soc_floor: name: "Tariff · Trading keeps at least (%)" description: "Price trading will not draw the battery below this level. It is separate from the maintenance settings." diff --git a/goodwe_controller/translations/nl.yaml b/goodwe_controller/translations/nl.yaml index 14b0885..067c10a 100644 --- a/goodwe_controller/translations/nl.yaml +++ b/goodwe_controller/translations/nl.yaml @@ -61,8 +61,8 @@ configuration: name: "Bruikbare capaciteit (kWh) (optioneel)" description: "De bruikbare capaciteit van deze batterij, van het datablad. Vul ze bij elke omvormer in of bij geen. Dan verdeelt de add-on het werk volgens de energie in elke batterij." round_trip_eff: - name: "Rendement heen en terug (0,5 tot 1) (optioneel)" - description: "Het deel van de energie dat uit deze batterij terugkomt nadat het erin ging, bijvoorbeeld 0,86. Laat het leeg als u het niet weet. Als u het rendement heen en terug instelt, verlaag dan de kosten van een batterijcyclus tot alleen slijtage." + name: "Rendement heen en terug (optioneel)" + description: "Het deel energie dat de batterij teruggeeft, bijvoorbeeld 0,86. Leeg laten als onbekend. Stelt u het rendement in, verlaag dan de kosten van een batterijcyclus tot alleen slijtage." estop_fitted: name: "Hardware · RS485-noodstop is geplaatst" description: "Zet dit aan als de noodstop geïnstalleerd is. Het verandert alleen een waarschuwing op de statuspagina." @@ -203,7 +203,7 @@ configuration: description: "Laden in het goedkoopste uur en de batterij laten leveren in het duurste, als het verschil de kosten dekt. Dit uitzetten zet de prijsfeed niet uit." cycle_cost_threshold_eur: name: "Tarief · Kosten van een batterijcyclus (EUR/kWh)" - description: "Wat één volledige batterijcyclus per kWh kost. Een kleiner prijsverschil wordt niet verhandeld. De waarde is een productkeuze, geen meting. Als u het rendement heen en terug instelt, verlaag dan de kosten van een batterijcyclus tot alleen slijtage." + description: "Wat één cyclus per kWh kost. Een kleiner prijsverschil wordt niet verhandeld. Stelt u het rendement in, verlaag dan de kosten van een batterijcyclus tot alleen slijtage." arbitrage_soc_floor: name: "Tarief · Handel houdt minstens (%)" description: "Prijshandel laat de batterij niet onder dit niveau zakken. Dit staat los van de onderhoudsinstellingen."