From ee12380087ae8da594080b117ae22ed27dc1bd45 Mon Sep 17 00:00:00 2001 From: Sleeper85 Date: Thu, 5 Nov 2026 22:18:10 +0100 Subject: [PATCH] YamBMS: Inverter brand registry and RS485 entry point Rename the inverter registry to yambms_brand_registry.yaml and add the new brands. yambms_rs485.yaml becomes the file to include, with a rs485_protocol var that selects PYLON or Voltronic LIB. --- documents/README/Supported_devices.md | 18 +++++- documents/README/YamBMS_functions.md | 18 ++++++ documents/README/changelog/Changelog.md | 7 ++- .../Changelog_Inverter_brand_and_protocol.md | 42 +++++++++----- documents/README/dev/Design_decisions.md | 37 +++++++++++- documents/README/dev/Project_structure.md | 4 +- packages/yambms/yambms.yaml | 8 +-- ...gistry.yaml => yambms_brand_registry.yaml} | 57 ++++++++++++++----- packages/yambms/yambms_canbus.yaml | 14 ++++- packages/yambms/yambms_rs485.yaml | 54 ++++++++++++++---- packages/yambms/yambms_rs485_pylon.yaml | 23 ++++---- packages/yambms/yambms_rs485_voltronic.yaml | 45 ++++++++++----- packages/yambms/yambms_rs485_web_server.yaml | 7 ++- 13 files changed, 255 insertions(+), 79 deletions(-) rename packages/yambms/{yambms_inverter_registry.yaml => yambms_brand_registry.yaml} (73%) diff --git a/documents/README/Supported_devices.md b/documents/README/Supported_devices.md index 15517b1..6afe174 100644 --- a/documents/README/Supported_devices.md +++ b/documents/README/Supported_devices.md @@ -110,5 +110,19 @@ The following are confirmed and known to work: | MidNite Solar | MN15-12KW-AIO | PYLON | CAN : PYLON V1 | --- | [@goldserve](https://diysolarforum.com/members/goldserve.52541/), [@jahyde](https://diysolarforum.com/members/jahyde.7475/) | | SRNE | HESP48120U200-H | UZE | CAN : PYLON V2 | Most PYLON-based protocols show same results. Inverter does not work in PYLON mode, UZE works. Incorrect temp reported. | [@ogremustcrush](https://diysolarforum.com/members/ogremustcrush.116979/) | | Studer | XTM-4000 | Pylontech | CAN : PYLON V2 | DIP Switch in Xcom-CAN: 11000110 (1 to 8, ON==1). | [@kolins-cz](https://github.com/kolins-cz) | -| Schneider | XW Pro 6848 NA | Voltage Control Li-Ion | CAN : PYLON V2 | The extended 29-bit ACK is handled automatically since YamBMS 1.8.1, no option to set. | [@AGDorsum](https://diysolarforum.com/members/agdorsum.29403/), [@ngustas](https://diysolarforum.com/members/ngustas.126045/) | -| SMA | Sunny Island | --- | --- | --- | --- | \ No newline at end of file +| Schneider | XW Pro 6848 NA | Voltage Control Li-Ion | CAN : PYLON V2 | The extended 29-bit ACK is handled automatically since YamBMS 1.8.0, no option to set. | [@AGDorsum](https://diysolarforum.com/members/agdorsum.29403/), [@ngustas](https://diysolarforum.com/members/ngustas.126045/) | +| SMA | Sunny Island | --- | CAN : SMA | --- | --- | + +## Supported MPPT chargers + +The following are confirmed and known to work: + +| Brand | Model | Inverter bat. mode | CAN/RS485 protocol | Remarks | Reported by | +| --- | --- | --- | --- | --- | --- | +| Epever | IT-NC | BPRO 21 | RS485 : PYLON | --- | --- | +| Epever | ET-NC | BPRO 21 | RS485 : PYLON | --- | --- | +| Epever | TIS | BPRO 21 | RS485 : PYLON | --- | --- | +| Epever | TES | BPRO 21 | RS485 : PYLON | --- | --- | +| Epever | TEP | BPRO 21 | RS485 : PYLON | --- | --- | +| Epever | TBP | BPRO 21 | RS485 : PYLON | --- | --- | +| Epever | Tracer-AN G3 | BPRO 21 | RS485 : PYLON | --- | --- | diff --git a/documents/README/YamBMS_functions.md b/documents/README/YamBMS_functions.md index b0bb8ba..578cd16 100644 --- a/documents/README/YamBMS_functions.md +++ b/documents/README/YamBMS_functions.md @@ -40,13 +40,31 @@ works well for you. | Growatt | CAN L52 | CAN | PYLON V1 | | LuxPower | Lithium 6 | CAN | LuxPower | | MidNite Solar | PYLON | CAN | PYLON V1 | +| MPP Solar | PYL | RS485 | PYLON | +| MPP Solar | LIB | RS485 | LIB | | Schneider | Voltage Control Li-Ion | CAN | PYLON V2 | | SMA | - | CAN | SMA | | Sofar | Automatic | CAN | PYLON V1 | +| Sol-Ark | Lithium 00 | CAN | PYLON V1 | +| Sol-Ark | Lithium 12 | RS485 | PYLON | | Solis | AoBo | CAN | SMA | | SRNE | UZE | CAN | PYLON V2 | | Studer | Pylontech | CAN | PYLON V2 | +| Sunsynk | Lithium 00 | CAN | PYLON V1 | +| Sunsynk | Lithium 12 | RS485 | PYLON | | Victron | CAN-bus BMS LV (500 kbit/s) | CAN | Victron | +| Voltronic | PYL | RS485 | PYLON | +| Voltronic | LIB | RS485 | LIB | + +Any other brand of the list, or a listed brand on the other bus, uses `PYLON V2` on CAN by default, +and the protocol compiled on the node on RS485. Such a combination has not been validated, and the +`Note` entity says so. + +On RS485 the protocol is chosen in your YAML with `rs485_protocol` (`pylon` or `voltronic`), and the +brand does not change it. `LIB` only works with `Voltronic` and `MPP Solar`: in `Automatic`, a node +compiled for `LIB` stays silent for any other brand. Rebranded Voltronic inverters must select +`Voltronic`. The protocols offered by parameter `05` depend on the inverter firmware, see its user +manual. A few couples outside the default mapping are known to work as well, and YamBMS reports the right battery mode for them too: `EG4` on `PYLON V1` (Lithium 2, 6000XP only) and `Solis` on `PYLON V2` diff --git a/documents/README/changelog/Changelog.md b/documents/README/changelog/Changelog.md index 6d5caaf..c87f92f 100644 --- a/documents/README/changelog/Changelog.md +++ b/documents/README/changelog/Changelog.md @@ -8,7 +8,12 @@ * YamBMS 1.8.1 : * **Breaking change** - New `Inverter brand` select and reworked `Protocol` select : selecting your inverter brand is enough, the protocol follows ; a protocol chosen explicitly still takes priority over the brand. Both selects are renamed, so their stored value is reset : **the inverter link stays inactive until you select your inverter brand**, see [release note](documents/README/changelog/Changelog_Inverter_brand_and_protocol.md) + * Removed the `YamBMS name` select : the manufacturer name sent on CAN frame `0x35E` is now derived from the protocol in use, which is what the `Automatic` mode already did ; the `GOODWE`, `SHEnergy` and `BYD` names are no longer selectable + + * The RS485 baud rate is now applied at runtime with `set_baud_rate()` + `load_settings()` instead of extending the `uart` component : `uart: !extend` only works on a native ESP32 UART, so boards using a UART expander (`wk2168` on the PVbrain2) had to include an internal file to avoid it ; every board now includes the same entry point + * RS485 packages reorganised for the additional protocols to come : the file you include changes from `yambms_rs485_pylon.yaml` to `yambms_rs485.yaml`, which now takes a `rs485_protocol` var (`pylon` or `voltronic`) and includes the matching protocol implementation for you ; a node with several RS485 links on different UARTs can run a different protocol on each, one var per link ; `yambms_rs485_pylon_web_server.yaml` becomes `yambms_rs485_web_server.yaml` and must now be included alongside the entry point with its own `rs485_id`, instead of swapping one for the other, see [release note](documents/README/changelog/Changelog_Inverter_brand_and_protocol.md) + * New diagnostic entities per inverter link : `Inverter link protocol` (what the link is actually doing, e.g. `Solis - CAN SMA`), `Inverter battery mode` (how to configure the battery type on the inverter, keyed on brand *and* protocol so that forcing a protocol never displays a wrong instruction) and `Note` (what is specific to that brand and protocol) * Renamed CAN protocol `PYLON 1.2` to `PYLON V1` and RS485 protocol `Pylontech` to `PYLON` * Schneider XW Pro : the extended 29-bit ACK is now handled automatically and the `canbus_extended_ack` substitution is removed - both the 11-bit and the 29-bit ACK are listened to at the same time, which the CAN component supports natively @@ -17,8 +22,6 @@ * Fixed the RS485 link staying up with `Disabled` : the proxy sensors kept their last value, so the Pylontech component went on answering the inverter with stale data and kept reporting its status as ON ; the sensors it checks are now invalidated when the protocol is off, which makes it stop answering and report the link as down * Fixed the CAN bus not stopping when the protocol was set to `Disabled` at runtime : the frame index kept its previous value and the last frame was re-emitted every 100 ms * Fixed the reported communication bus and protocol being overwritten when a node declares several inverter links : each link now owns its slot, and the telemetry reports every link instead of the last one - * The RS485 baud rate is now applied at runtime with `set_baud_rate()` + `load_settings()` instead of extending the `uart` component : `uart: !extend` only works on a native ESP32 UART, so boards using a UART expander (`wk2168` on the PVbrain2) had to include an internal file to avoid it ; every board now includes the same entry point - * RS485 packages reorganised internally for the additional protocols to come : `yambms_rs485_pylon.yaml` **stays the file you include**, no change there ; its selects/diagnostics/UART machinery move out to a new shared `yambms_rs485.yaml` (replacing the old internal `yambms_rs485_pylon_core.yaml`), which `yambms_rs485_pylon.yaml` includes itself so that a node with several RS485 links on different UARTs can run a different protocol on each ; `yambms_rs485_pylon_web_server.yaml` becomes `yambms_rs485_web_server.yaml` and must now be included alongside the protocol file with its own `rs485_id`, instead of swapping one for the other, see [release note](documents/README/changelog/Changelog_Inverter_brand_and_protocol.md) * YamBMS 1.8.0 : * Set esphome `min_version` to `2026.8.0` diff --git a/documents/README/changelog/Changelog_Inverter_brand_and_protocol.md b/documents/README/changelog/Changelog_Inverter_brand_and_protocol.md index 956efee..3aae07b 100644 --- a/documents/README/changelog/Changelog_Inverter_brand_and_protocol.md +++ b/documents/README/changelog/Changelog_Inverter_brand_and_protocol.md @@ -6,13 +6,21 @@ The inverter link is now described by **two selects** instead of one: | Select | Options | Default | | --- | --- | --- | -| `Inverter brand` | `Not defined`, `Other`, then the supported brands | `Not defined` | +| `Inverter brand` | `Not defined`, `Other`, then the inverter brands | `Not defined` | | `Protocol` | `Automatic`, `Disabled`, then the protocols of that bus | `Automatic` | Selecting your inverter brand is enough: with `Protocol` on `Automatic`, YamBMS applies the protocol that matches your brand. Choosing a protocol explicitly always takes priority over the brand, so an inverter that does not follow the usual mapping can still be driven. +The brand list also covers manufacturers that are not validated yet. Those use `PYLON V2` on CAN +and the protocol compiled on the node on RS485, and the `Note` entity tells you the brand has not +been validated on that bus. + +On RS485 the brand never changes the protocol, which is the `rs485_protocol` of your YAML. `LIB` +only works with `Voltronic` and `MPP Solar`: in `Automatic`, a node compiled for `LIB` stays silent +for any other brand. Rebranded Voltronic inverters must select `Voltronic`. + The old `YamBMS name` select is **removed**. The manufacturer name announced on CAN frame `0x35E` is now derived from the protocol in use — exactly the names the `Automatic` mode already sent, and which are known to work. The `GOODWE`, `SHEnergy` and `BYD` names are no longer selectable. @@ -73,18 +81,24 @@ line from your YAML if you had set it. ## RS485 package files -`yambms_rs485_pylon.yaml` **stays the file you include** — no change there. Its internals are -reorganised to make room for the additional RS485 protocols to come: the `Inverter brand`/ -`Protocol` selects, diagnostics and telemetry move out to a new shared file, `yambms_rs485.yaml`, -which `yambms_rs485_pylon.yaml` includes itself. Each protocol file includes -`yambms_rs485.yaml` this way round, rather than the other way, so that a node with several RS485 -links on different UARTs can run a different protocol on each. +**The file you include changes**, from `yambms_rs485_pylon.yaml` to `yambms_rs485.yaml`. This +makes room for the additional RS485 protocols to come: `yambms_rs485.yaml` carries the `Inverter +brand`/`Protocol` selects, diagnostics and telemetry, and takes a new `rs485_protocol` var +(`pylon` or `voltronic`) that tells it which protocol implementation to include for you +(`yambms_rs485_pylon.yaml`, keeping the PYLON implementation only, or the new +`yambms_rs485_voltronic.yaml`). A node with several RS485 links on different UARTs can run a +different protocol on each, since each link's `vars:` names its own `rs485_protocol`. -`yambms_rs485_pylon_web_server.yaml` becomes `yambms_rs485_web_server.yaml`, and unlike before it -no longer includes the link itself: add it **alongside** `yambms_rs485_pylon.yaml` in your YAML, -with its own `vars: { rs485_id: '1' }` matching the link it decorates, instead of swapping one file -for the other. +> [!IMPORTANT] +> Point your `!include` to `yambms_rs485.yaml` and add `rs485_protocol: 'pylon'` to its `vars:`. +> This relies on substitutions in an `!include` filename, added in ESPHome 2026.4.0 +> ([esphome#12213](https://github.com/esphome/esphome/pull/12213)) — already covered by this +> project's `min_version: 2026.10.0`, so no extra requirement for you. -`rs485_uart_baud_rate` keeps the same meaning but is now applied at runtime instead of extending -the `uart` component, and defaults to `9600`. Boards using a UART expander — the `wk2168` of the -PVbrain2 — no longer need a separate include: every board now uses the same entry point. +`yambms_rs485_pylon_web_server.yaml` becomes `yambms_rs485_web_server.yaml`. It includes the link +itself, so use it **instead of** `yambms_rs485.yaml`, not alongside it, with the same `vars:`. + +`rs485_uart_baud_rate` keeps the same meaning and defaults to `9600`. The link now declares its +UART itself from `rs485_uart_id`, so remove the `board_options_itf_uart_*.yaml` include of that UART +from your YAML. Boards using a UART expander — the `wk2168` of the PVbrain2 — no longer need a +separate include: every board now uses the same entry point. diff --git a/documents/README/dev/Design_decisions.md b/documents/README/dev/Design_decisions.md index 68a49e2..5195c1b 100644 --- a/documents/README/dev/Design_decisions.md +++ b/documents/README/dev/Design_decisions.md @@ -254,7 +254,7 @@ may not have happened yet, not a scheduling order. ## The inverter protocol is resolved once, never in the loop -**Files:** `packages/yambms/yambms_inverter_registry.yaml`, `packages/yambms/yambms_canbus.yaml`, +**Files:** `packages/yambms/yambms_brand_registry.yaml`, `packages/yambms/yambms_canbus.yaml`, `packages/yambms/yambms_rs485.yaml` The protocol actually applied on a link is not readable from a single select. It is the result of @@ -318,6 +318,39 @@ of the interval publishes those `NaN` once per transition, guarded by Only those eight sensors matter — the ones read by `update_state_from_sensors_()`. Invalidating the others would be harmless but pointless, and would hide which ones the contract actually depends on. +### On RS485 the protocol is compiled, the brand only gates it + +**Files:** `packages/yambms/yambms_rs485.yaml`, `packages/yambms/yambms_rs485_pylon.yaml`, +`packages/yambms/yambms_rs485_voltronic.yaml` + +`rs485_protocol` picks the implementation at compile time, and each implementation declares what +it is in `rs485${rs485_id}_compiled_protocol`. In `Automatic` the resolution script applies that +value and never derives a protocol from the brand: a node can only speak what was compiled into +it, and resolving anything else made the diagnostics describe a protocol that was not running. + +Voltronic and MPP Solar are the reason this cannot be a brand mapping. On recent firmwares, +parameter `05` offers both `PYL` and `LIB` on RS485, so either implementation is a valid choice +for the same inverter and the brand says nothing about which one was compiled. + +`LIB` is the one exception. It is a Voltronic protocol and no other brand can use it, so in +`Automatic` a node compiled for `LIB` stays silent for any other brand, and `Note` says why. +Forcing `LIB` is still possible, because an explicit protocol always takes priority over the +brand. Rebranded inverters are expected to select `Voltronic`. MPP Solar is not a rebrand, which +is why it has its own entry. + +### Turning the LIB link off means moving its Modbus address + +**File:** `packages/yambms/yambms_rs485_voltronic.yaml` + +`modbus_server` has no off switch, and returning nothing from a `read_lambda` only turns the reply +into an exception frame, so the inverter still gets an answer on a link that should be silent. +`ModbusServerHub::find_device_()` matches the address on every request, so moving the server to +address `248` makes the hub drop the request instead. The 100 ms interval moves it back to `1` +only while `rs485${rs485_id}_active_protocol` is `LIB`. + +Do not replace this with reported charge and discharge limits of zero: the inverter would still +see a battery, on a link the user believes is off. + ### `Disabled` unregisters the link instead of faulting it **File:** `packages/base/device_base_fault_registry.yaml` @@ -339,7 +372,7 @@ Without the second one the link timer would re-raise the fault a few seconds lat A link left at `Automatic` with no brand selected is deliberately **not** unregistered — it faults. That is the signal telling the user the node was never configured, which is the whole point of the -1.8.1 breaking change. +1.8.0 breaking change. ### Both ACK triggers are registered diff --git a/documents/README/dev/Project_structure.md b/documents/README/dev/Project_structure.md index f003ddf..433156f 100644 --- a/documents/README/dev/Project_structure.md +++ b/documents/README/dev/Project_structure.md @@ -51,12 +51,12 @@ All three follow the same layered scheme, per brand and protocol: ### `yambms/` -The central engine. `yambms.yaml` aggregates `yambms_inverter_registry.yaml`, +The central engine. `yambms.yaml` aggregates `yambms_brand_registry.yaml`, `yambms_core.yaml`, the `yambms_auto_*.yaml` functions (CVL / CCL / DCL / Float / EOC / temperature / SoC limit) and `yambms_service.yaml`, then `yambms_canbus*.yaml` or `yambms_rs485*.yaml` for the link to the inverter. -`yambms_inverter_registry.yaml` holds the protocol dictionary (`YB_PROTO_*`), the brand to +`yambms_brand_registry.yaml` holds the protocol dictionary (`YB_PROTO_*`), the brand to protocol mapping and the per-couple battery mode and note. Both inverter buses read it. On the RS485 side, `yambms_rs485.yaml` is the entry point — selects, diagnostics, telemetry diff --git a/packages/yambms/yambms.yaml b/packages/yambms/yambms.yaml index 098aa60..7be797d 100644 --- a/packages/yambms/yambms.yaml +++ b/packages/yambms/yambms.yaml @@ -1,5 +1,5 @@ -# Updated : 2026.09.02 -# Version : 1.1.7 +# Updated : 2026.11.05 +# Version : 1.1.8 # GitHub : https://github.com/Sleeper85/esphome-yambms # YamBMS ( Yet another multi-BMS Merging Solution ) @@ -18,8 +18,8 @@ # along with this program. If not, see . packages: - # Inverter registry (protocol dictionary, brand mapping, battery modes) - yambms_inverter_registry: !include yambms_inverter_registry.yaml + # Brand registry (protocol dictionary, brand mapping, battery modes) + yambms_brand_registry: !include yambms_brand_registry.yaml # YamBMS Core yambms_core: !include yambms_core.yaml # YamBMS Auto Functions diff --git a/packages/yambms/yambms_inverter_registry.yaml b/packages/yambms/yambms_brand_registry.yaml similarity index 73% rename from packages/yambms/yambms_inverter_registry.yaml rename to packages/yambms/yambms_brand_registry.yaml index d1c4087..364f88a 100644 --- a/packages/yambms/yambms_inverter_registry.yaml +++ b/packages/yambms/yambms_brand_registry.yaml @@ -1,5 +1,5 @@ -# Updated : 2026.09.04 -# Version : 1.1.1 +# Updated : 2026.11.05 +# Version : 1.1.2 # GitHub : https://github.com/Sleeper85/esphome-yambms # YamBMS ( Yet another multi-BMS Merging Solution ) @@ -18,7 +18,7 @@ # along with this program. If not, see . # +----------------------------------------------------------------------------+ -# | Inverter registry | +# | Brand registry | # | | # | Shared by the CAN and the RS485 inverter links. Holds: | # | - the protocol dictionary (YB_PROTO_*) | @@ -31,6 +31,10 @@ # | user can always override it with the `Protocol` select. Only the battery | # | mode is asserted, and only for couples that were actually confirmed by a | # | user; anything else returns "See inverter manual". | +# | | +# | A brand with no mapping gets PYLON V2 on CAN and the compiled protocol on | +# | RS485, and its note says it was not validated. `Not defined` and `Other` | +# | are not brands: they resolve to nothing and the user has to choose. | # +----------------------------------------------------------------------------+ substitutions: @@ -76,20 +80,20 @@ globals: if (brand == "Schneider") return ${YB_PROTO_CAN_PYLON_V2}; if (brand == "SMA") return ${YB_PROTO_CAN_SMA}; if (brand == "Sofar") return ${YB_PROTO_CAN_PYLON_V1}; + if (brand == "Sol-Ark") return ${YB_PROTO_CAN_PYLON_V1}; if (brand == "Solis") return ${YB_PROTO_CAN_SMA}; if (brand == "SRNE") return ${YB_PROTO_CAN_PYLON_V2}; if (brand == "Studer") return ${YB_PROTO_CAN_PYLON_V2}; + if (brand == "Sunsynk") return ${YB_PROTO_CAN_PYLON_V1}; if (brand == "Victron") return ${YB_PROTO_CAN_VICTRON}; - return ${YB_PROTO_NONE}; + // Any other brand was not validated on CAN: the note reports it. + return ${YB_PROTO_CAN_PYLON_V2}; } - // RS485: every known brand maps to PYLON, except the Voltronic-derived - // family (Axpert, InfiniSolar, MPP Solar) whose "LIB" battery type is a - // distinct, unrelated protocol - see yambms_rs485_voltronic.yaml. - if (bus == "RS485") { - if (brand == "MPP Solar" || brand == "Voltronic") return ${YB_PROTO_RS485_VOLTRONIC_LIB}; - return ${YB_PROTO_RS485_PYLON}; - } + // RS485: the protocol is chosen at compile time (`rs485_protocol`), so the + // link only needs to know that a brand was selected. The script in + // yambms_rs485.yaml replaces this value with the compiled protocol. + if (bus == "RS485") return ${YB_PROTO_RS485_PYLON}; return ${YB_PROTO_NONE}; } @@ -140,14 +144,20 @@ globals: if (brand == "Growatt" && proto == ${YB_PROTO_CAN_PYLON_V1}) return "CAN L52"; if (brand == "LuxPower" && proto == ${YB_PROTO_CAN_LUXPOWER}) return "Lithium 6"; if (brand == "MidNite Solar" && proto == ${YB_PROTO_CAN_PYLON_V1}) return "PYLON"; + if (brand == "MPP Solar" && proto == ${YB_PROTO_RS485_PYLON}) return "PYL"; if (brand == "MPP Solar" && proto == ${YB_PROTO_RS485_VOLTRONIC_LIB}) return "LIB"; if (brand == "Schneider" && proto == ${YB_PROTO_CAN_PYLON_V2}) return "Voltage Control Li-Ion"; if (brand == "Sofar" && proto == ${YB_PROTO_CAN_PYLON_V1}) return "Automatic"; + if (brand == "Sol-Ark" && proto == ${YB_PROTO_CAN_PYLON_V1}) return "Lithium 00"; + if (brand == "Sol-Ark" && proto == ${YB_PROTO_RS485_PYLON}) return "Lithium 12"; if (brand == "Solis" && proto == ${YB_PROTO_CAN_SMA}) return "AoBo"; if (brand == "Solis" && proto == ${YB_PROTO_CAN_PYLON_V2}) return "Pylon LV"; if (brand == "SRNE" && proto == ${YB_PROTO_CAN_PYLON_V2}) return "UZE"; if (brand == "Studer" && proto == ${YB_PROTO_CAN_PYLON_V2}) return "Pylontech"; + if (brand == "Sunsynk" && proto == ${YB_PROTO_CAN_PYLON_V1}) return "Lithium 00"; + if (brand == "Sunsynk" && proto == ${YB_PROTO_RS485_PYLON}) return "Lithium 12"; if (brand == "Victron" && proto == ${YB_PROTO_CAN_VICTRON}) return "CAN-bus BMS LV (500 kbit/s)"; + if (brand == "Voltronic" && proto == ${YB_PROTO_RS485_PYLON}) return "PYL"; if (brand == "Voltronic" && proto == ${YB_PROTO_RS485_VOLTRONIC_LIB}) return "LIB"; return "See inverter manual"; @@ -165,15 +175,36 @@ globals: [](std::string brand, int proto) -> std::string { if (brand == "EG4" && proto == ${YB_PROTO_CAN_PYLON_V1}) return "6000XP only."; - if (brand == "Epever" && proto == ${YB_PROTO_RS485_PYLON}) return "Verified on ET-NC and IT-NC inverter-chargers. Other Epever models may only support the Epever BMS Link protocol. BPRO 21 defaults to 115200 baud on ET/IT chargers, not the 9600 default - set rs485_uart_baud_rate accordingly."; - if (brand == "Epever") return "Unverified: Epever inverter-chargers are documented on RS485 PYLON."; + if (brand == "Epever" && proto == ${YB_PROTO_RS485_PYLON}) return "Set protocol ID 21 (BPRO 21). A direct RS485 link works on most models, UPower-Hi requires the external BMS-Link. BPRO 21 defaults to 115200 baud not the 9600 default - set rs485_uart_baud_rate accordingly."; + if (brand == "Epever") return "Unverified: Epever is documented on RS485 PYLON, no CAN support is known."; if ((brand == "MPP Solar" || brand == "Voltronic") && proto == ${YB_PROTO_RS485_VOLTRONIC_LIB}) return "Unverified: per Voltronic's own documentation, only the charge voltage limit is applied by the inverter firmware - discharge voltage and both current limits are documented as unused."; + if ((brand == "MPP Solar" || brand == "Voltronic") && proto == ${YB_PROTO_RS485_PYLON}) + return "See user manual: set parameter 05 to PYL. For LIB, set rs485_protocol to 'voltronic'."; if (brand == "Schneider" && proto == ${YB_PROTO_CAN_PYLON_V2}) return "The extended 29-bit ACK is handled automatically."; if (brand == "Sofar" && proto == ${YB_PROTO_CAN_PYLON_V1}) return "A 120 Ohm resistor may be required on the Sofar side."; if (brand == "Solis" && proto == ${YB_PROTO_CAN_PYLON_V2}) return "A 3.3V CAN transceiver (SN65HVD230) is required."; if (brand == "SRNE" && proto == ${YB_PROTO_CAN_PYLON_V2}) return "The inverter reports an incorrect battery temperature."; if (brand == "Studer" && proto == ${YB_PROTO_CAN_PYLON_V2}) return "Xcom-CAN DIP switches: 11000110 (1 to 8, ON = 1)."; + // Not brands: nothing to validate, even with a protocol forced by hand. + if (brand == "Not defined" || brand == "Other") return ""; + + // LIB is a Voltronic protocol: the two brands it applies to returned above. + if (proto == ${YB_PROTO_RS485_VOLTRONIC_LIB}) + return "LIB only works with Voltronic and MPP Solar. Rebranded inverters must select Voltronic, otherwise set rs485_protocol to 'pylon'."; + + // Brands confirmed on each bus. The leading digit of a protocol names its + // bus, so this also covers a protocol forced by hand. + bool can_validated = brand == "Deye" || brand == "EG4" || brand == "GoodWe" || + brand == "Growatt" || brand == "LuxPower" || brand == "MidNite Solar" || + brand == "Schneider" || brand == "SMA" || brand == "Sofar" || + brand == "Sol-Ark" || brand == "Solis" || brand == "SRNE" || + brand == "Studer" || brand == "Sunsynk" || brand == "Victron"; + bool rs485_validated = brand == "Deye" || brand == "Epever" || brand == "Sol-Ark" || brand == "Sunsynk"; + + if (proto / 100 == 1 && !can_validated) return "Unverified: this brand has not been validated on CAN bus yet."; + if (proto / 100 == 2 && !rs485_validated) return "Unverified: this brand has not been validated on RS485 yet."; + return ""; } diff --git a/packages/yambms/yambms_canbus.yaml b/packages/yambms/yambms_canbus.yaml index 15650fa..bcf47ac 100644 --- a/packages/yambms/yambms_canbus.yaml +++ b/packages/yambms/yambms_canbus.yaml @@ -1,5 +1,5 @@ -# Updated : 2026.09.04 -# Version : 2.7.1 +# Updated : 2026.11.05 +# Version : 2.7.2 # GitHub : https://github.com/Sleeper85/esphome-yambms # YamBMS ( Yet another multi-BMS Merging Solution ) @@ -107,20 +107,30 @@ select: options: - "Not defined" - "Other" + - "Afore" - "Deye" - "EG4" - "Epever" + - "Felicity Solar" + - "FoxESS" - "GoodWe" - "Growatt" + - "Kstar" - "LuxPower" + - "Megarevo" - "MidNite Solar" - "MPP Solar" + - "Must" + - "Phocos" + - "Renogy" - "Schneider" - "SMA" - "Sofar" + - "Sol-Ark" - "Solis" - "SRNE" - "Studer" + - "Sunsynk" - "Victron" - "Voltronic" restore_value: true diff --git a/packages/yambms/yambms_rs485.yaml b/packages/yambms/yambms_rs485.yaml index 4fc741b..e0700ee 100644 --- a/packages/yambms/yambms_rs485.yaml +++ b/packages/yambms/yambms_rs485.yaml @@ -1,5 +1,5 @@ -# Updated : 2026.09.04 -# Version : 1.1.1 +# Updated : 2026.11.05 +# Version : 1.1.2 # GitHub : https://github.com/Sleeper85/esphome-yambms # YamBMS ( Yet another multi-BMS Merging Solution ) @@ -20,15 +20,19 @@ # +----------------------------------------------------------------------------+ # | RS485 inverter link | # | | -# | Shared machinery for an RS485 link: the `Inverter brand` and `Protocol` | -# | selects, the diagnostics and the telemetry slot. Not the file you include | -# | - you never `!include` this one directly. Each protocol implementation | -# | (yambms_rs485_pylon.yaml, yambms_rs485_voltronic.yaml) includes THIS file, | -# | not the other way around, so that a node with several RS485 links on | -# | several UARTs can run a different protocol on each: including this file | -# | directly would hardcode one protocol for every link that does so. | +# | Entry point of the RS485 link: it carries the `Inverter brand` and | +# | `Protocol` selects, the diagnostics and the telemetry slot, then includes | +# | the protocol implementation named by the `rs485_protocol` substitution | +# | ('pylon' or 'voltronic') - requires ESPHome >= 2026.4.0 for substitutions | +# | in an `!include` filename (esphome#12213), already covered by the | +# | project's min_version. Each RS485 link passes its own `rs485_protocol` in | +# | its `vars:`, so a node with several links on several UARTs can run a | +# | different protocol on each. | # +----------------------------------------------------------------------------+ +packages: + rs485_protocol: !include yambms_rs485_${rs485_protocol}.yaml + substitutions: # The ID of the LED on your board used for this component rs485_status_led_id: "virtual_status_light" @@ -113,20 +117,30 @@ select: options: - "Not defined" - "Other" + - "Afore" - "Deye" - "EG4" - "Epever" + - "Felicity Solar" + - "FoxESS" - "GoodWe" - "Growatt" + - "Kstar" - "LuxPower" + - "Megarevo" - "MidNite Solar" - "MPP Solar" + - "Must" + - "Phocos" + - "Renogy" - "Schneider" - "SMA" - "Sofar" + - "Sol-Ark" - "Solis" - "SRNE" - "Studer" + - "Sunsynk" - "Victron" - "Voltronic" restore_value: true @@ -226,10 +240,20 @@ script: std::string choice = id(rs485${rs485_id}_protocol).current_option(); std::string source; int proto; + bool lib_refused = false; // An explicit protocol always takes priority over the brand if (choice == "Automatic") { - proto = id(global_inverter_default_protocol)(brand, "RS485"); + // The protocol is chosen at compile time: the brand only decides + // whether this link may run it. + int compiled = id(rs485${rs485_id}_compiled_protocol); + bool brand_defined = id(global_inverter_default_protocol)(brand, "RS485") != ${YB_PROTO_NONE}; + proto = brand_defined ? compiled : ${YB_PROTO_NONE}; + // LIB is a Voltronic protocol: answering any other brand is pointless + if (proto == ${YB_PROTO_RS485_VOLTRONIC_LIB} && brand != "MPP Solar" && brand != "Voltronic") { + proto = ${YB_PROTO_NONE}; + lib_refused = true; + } source = "auto"; } else { source = "manual"; @@ -244,14 +268,20 @@ script: std::string label = id(global_inverter_protocol_label)(proto); // --- Diagnostics --- - if (proto == ${YB_PROTO_NONE}) { + if (lib_refused) { + id(rs485${rs485_id}_inverter_link_protocol).publish_state(brand + " - RS485 LIB not applicable"); + ESP_LOGW("rs485", "LIB does not apply to %s: nothing is sent on the RS485 bus", brand.c_str()); + } else if (proto == ${YB_PROTO_NONE}) { id(rs485${rs485_id}_inverter_link_protocol).publish_state("Inverter RS485 bus not defined"); ESP_LOGW("rs485", "No inverter brand selected and no protocol forced: nothing is sent on the RS485 bus"); } else { id(rs485${rs485_id}_inverter_link_protocol).publish_state(brand + " - RS485 " + label); } - if (proto == ${YB_PROTO_NONE} || proto == ${YB_PROTO_DISABLED}) { + if (lib_refused) { + id(rs485${rs485_id}_inverter_battery_mode).publish_state(""); + id(rs485${rs485_id}_note).publish_state(id(global_inverter_note)(brand, ${YB_PROTO_RS485_VOLTRONIC_LIB})); + } else if (proto == ${YB_PROTO_NONE} || proto == ${YB_PROTO_DISABLED}) { id(rs485${rs485_id}_inverter_battery_mode).publish_state(""); id(rs485${rs485_id}_note).publish_state(""); } else { diff --git a/packages/yambms/yambms_rs485_pylon.yaml b/packages/yambms/yambms_rs485_pylon.yaml index a57b018..16f1569 100644 --- a/packages/yambms/yambms_rs485_pylon.yaml +++ b/packages/yambms/yambms_rs485_pylon.yaml @@ -1,5 +1,5 @@ -# Updated : 2026.09.04 -# Version : 1.5.1 +# Updated : 2026.11.05 +# Version : 1.5.2 # GitHub : https://github.com/fahmula/esphome-pylontech-rs485 # YamBMS ( Yet another multi-BMS Merging Solution ) @@ -17,15 +17,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# This is the file you include for a PYLON RS485 link: it pulls in the shared -# selects/diagnostics/telemetry machinery from `yambms_rs485.yaml` and adds -# the PYLON protocol itself. Included this way round (rather than the other -# way, as before 1.8.1) so that a node with several RS485 links on several -# UARTs can run PYLON on one and Voltronic LIB on another - see -# yambms_rs485_voltronic.yaml for that alternative entry point. - -packages: - rs485_entry: !include yambms_rs485.yaml +# PYLON protocol implementation. Not the file you include - include +# `yambms_rs485.yaml` instead, with `rs485_protocol: 'pylon'` in its `vars:`; +# it includes this file for you (`!include yambms_rs485_${rs485_protocol}.yaml`), +# so that a node with several RS485 links on several UARTs can run PYLON on +# one and Voltronic LIB on another, each naming its own protocol. external_components: - source: github://fahmula/esphome-pylontech-rs485@main @@ -39,6 +35,11 @@ select: - "PYLON" globals: + # Protocol this file implements, read by the resolution script in yambms_rs485.yaml + - id: rs485${rs485_id}_compiled_protocol + type: int + restore_value: no + initial_value: "${YB_PROTO_RS485_PYLON}" # True while the proxy sensors carry data the component may serve to the # inverter. Turning the protocol off does not clear them by itself, so they # have to be invalidated explicitly - see the interval below. diff --git a/packages/yambms/yambms_rs485_voltronic.yaml b/packages/yambms/yambms_rs485_voltronic.yaml index de04730..e3a276d 100644 --- a/packages/yambms/yambms_rs485_voltronic.yaml +++ b/packages/yambms/yambms_rs485_voltronic.yaml @@ -1,5 +1,5 @@ -# Updated : 2026.09.04 -# Version : 1.1.0 +# Updated : 2026.11.05 +# Version : 1.1.1 # GitHub : https://github.com/Sleeper85/esphome-yambms # YamBMS ( Yet another multi-BMS Merging Solution ) @@ -17,13 +17,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# This is the file you include for a Voltronic LIB RS485 link: it pulls in -# the shared selects/diagnostics/telemetry machinery from `yambms_rs485.yaml` -# and adds the Voltronic "LIb" protocol itself - see documents/PRIVATE/ -# Voltronic/Voltronic Inverter and BMS 485 communication protocol -# 20201202.docx (Voltronic Power, also referenced by Epever as PRO=26, same -# authors Ellis/Lory/Jenny). Use yambms_rs485_pylon.yaml instead for PYLON - -# never include both on the same UART, see the warning below. +# Voltronic "LIb" protocol implementation - see documents/PRIVATE/Voltronic/ +# Voltronic Inverter and BMS 485 communication protocol 20201202.docx +# (Voltronic Power, also referenced by Epever as PRO=26, same authors +# Ellis/Lory/Jenny). Not the file you include - include `yambms_rs485.yaml` +# instead, with `rs485_protocol: 'voltronic'` in its `vars:`; it includes +# this file for you (`!include yambms_rs485_${rs485_protocol}.yaml`). # # Unlike Pylontech, this is plain Modbus RTU (function 0x03, 9600 8N1) so it # is implemented with ESPHome's native `modbus_server:` - no external @@ -45,9 +44,6 @@ # own locally configured charge curve regardless of what is sent there. # - Not verified on real hardware yet. -packages: - rs485_entry: !include yambms_rs485.yaml - select: # Adds the option this file implements to the base Automatic/Disabled list # declared in yambms_rs485.yaml - see the comment there. @@ -56,6 +52,11 @@ select: - "LIB" globals: + # Protocol this file implements, read by the resolution script in yambms_rs485.yaml + - id: rs485${rs485_id}_compiled_protocol + type: int + restore_value: no + initial_value: "${YB_PROTO_RS485_VOLTRONIC_LIB}" # Set by the read_lambda of address 48 (the first register of the # aggregated-data block, always read by a normal polling cycle), cleared by # the interval below. Unlike pylontech_rs485's own update_timeout, nothing @@ -73,6 +74,23 @@ interval: bool polled = id(rs485${rs485_id}_voltronic_polled); id(rs485${rs485_id}_voltronic_polled) = false; id(rs485${rs485_id}_status).publish_state(polled); + # modbus_server has no off switch: it answers whatever is asked of its address. + # Moving it to 248, a reserved address no inverter polls, makes the hub ignore + # every request, which is the only way to keep this link truly silent. + - interval: 100ms + then: + - lambda: |- + bool active = id(rs485${rs485_id}_active_protocol) == ${YB_PROTO_RS485_VOLTRONIC_LIB}; + + // Mirror RS485 status into inverter_com_status. Turning the link off clears + // it once per transition, so a CAN link on the same node keeps owning it. + if (active) { + if (id(rs485${rs485_id}_status).has_state()) id(inverter_com_status).publish_state(id(rs485${rs485_id}_status).state); + } else if (id(rs485${rs485_id}_modbus_server).get_address() != 248) { + id(inverter_com_status).publish_state(false); + } + + id(rs485${rs485_id}_modbus_server).set_address(active ? 1 : 248); modbus: - uart_id: ${rs485_uart_id} @@ -80,7 +98,8 @@ modbus: role: server modbus_server: - - modbus_id: modbus_rs485_${rs485_id} + - id: rs485${rs485_id}_modbus_server + modbus_id: modbus_rs485_${rs485_id} address: 1 registers: # +--------------------------------------------------------------+ diff --git a/packages/yambms/yambms_rs485_web_server.yaml b/packages/yambms/yambms_rs485_web_server.yaml index 07afeef..774ef96 100644 --- a/packages/yambms/yambms_rs485_web_server.yaml +++ b/packages/yambms/yambms_rs485_web_server.yaml @@ -1,5 +1,5 @@ -# Updated : 2026.09.04 -# Version : 1.1.4 +# Updated : 2026.11.05 +# Version : 1.1.5 # GitHub : https://github.com/Sleeper85/esphome-yambms # YamBMS ( Yet another multi-BMS Merging Solution ) @@ -17,6 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +packages: + rs485: !include yambms_rs485.yaml + select: # YamBMS - Inverter Communication Protocol - id: !extend rs485${rs485_id}_inverter_brand