From 6a3827e6467eb929a4ced8381c4d50a98768d653 Mon Sep 17 00:00:00 2001 From: Fredrik Ahlgren Date: Sat, 21 Nov 2026 17:52:03 +0100 Subject: [PATCH 1/2] feat(site): say whether FTW controls each device, and why not The catalog page took control from the manifest's control field, which had drifted from the code in seven drivers, and showed a faint "Read only" badge with no reason. An owner who added a Zaptec Go through zaptec_cloud had no way to learn FTW would only read the charger. The page now reads control the way the signed channel does, through one function in tools/ftw_repository.py: driver_command present and no read_only = true in the DRIVER table. Each driver says one of three things: - Controls the device: experimental until a field report confirms it, or confirmed when the driver's own record says production or tested. - Reads only: what stops it (no control code yet, or the driver turns control off), then the driver's own reason when its description, manifest notes or header comment gives one. - Telemetry only: meter and PV drivers, where control is not expected. The seven manifests that said control: false for drivers the channel ships with control (alphaess, deye, kstar, pixii, solaredge, solax, varta) now say true, and a test holds every manifest to the code. index.yaml and devices.yaml follow. Signed-off-by: Fredrik Ahlgren Co-Authored-By: Claude Opus 5.5 --- README.md | 9 +- devices.yaml | 40 ++++---- index.yaml | 14 +-- manifests/alphaess.yaml | 2 +- manifests/deye.yaml | 2 +- manifests/kstar.yaml | 2 +- manifests/pixii.yaml | 2 +- manifests/solaredge.yaml | 2 +- manifests/solax.yaml | 2 +- manifests/varta.yaml | 2 +- spec/manifest-v2.md | 2 +- tests/test_control_claims.py | 22 +++++ tests/test_site.py | 87 +++++++++++++++++- tools/ftw_repository.py | 49 +++++++--- tools/generate_site.py | 174 +++++++++++++++++++++++++++++++---- 15 files changed, 339 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index 4f3502c4..16a559be 100644 --- a/README.md +++ b/README.md @@ -121,9 +121,12 @@ channel=stable`; it accepts only the exact commit `drivers-beta` carries, and serves installs that read the stable channel. The channel contains every catalog driver as its own signed Lua asset. A driver -the catalog marks `control: true` keeps its control path; every other one is -read-only. Refreshing the signed catalog never installs or activates code. -FTW keeps its own safety, activation, rollback and bundled copies. +keeps its control path when its code has `driver_command` and its `DRIVER` +table does not say `read_only = true`; every other one is read-only. The +manifest's `control:` field must say the same, and `make check` fails when it +does not. The catalog page reads it the same way. Refreshing the signed +catalog never installs or activates code. FTW keeps its own safety, +activation, rollback and bundled copies. Each asset name contains the driver ID, semantic version and source hash. FTW downloads only the selected driver. The release workflow never replaces a diff --git a/devices.yaml b/devices.yaml index 49a8959b..61a1333c 100644 --- a/devices.yaml +++ b/devices.yaml @@ -137,7 +137,7 @@ manufacturers: driver: "alphaess" version: "1.1.1" ders: [pv, battery, meter] - control: false + control: true firmware_versions: "" notes: "Community driver, untested" - name: "Smile Series" @@ -148,7 +148,7 @@ manufacturers: driver: "alphaess" version: "1.1.1" ders: [pv, battery, meter] - control: false + control: true firmware_versions: "" notes: "Community driver, untested" - name: "Ambibox" @@ -259,7 +259,7 @@ manufacturers: driver: "deye" version: "2.1.1" ders: [battery, meter, pv] - control: false + control: true firmware_versions: "" notes: "Single-phase hybrid with LV battery" - name: "SUN String (Grid-Tie)" @@ -270,7 +270,7 @@ manufacturers: driver: "deye" version: "2.1.1" ders: [battery, meter, pv] - control: false + control: true firmware_versions: "" notes: "Three-phase grid-tie string inverter (PV + meter only)" - name: "SUN Three-Phase HV Hybrid" @@ -281,7 +281,7 @@ manufacturers: driver: "deye" version: "2.1.1" ders: [battery, meter, pv] - control: false + control: true firmware_versions: "" notes: "Three-phase hybrid with HV battery" - name: "SUN Three-Phase Hybrid" @@ -292,7 +292,7 @@ manufacturers: driver: "deye" version: "2.1.1" ders: [battery, meter, pv] - control: false + control: true firmware_versions: "" notes: "Three-phase hybrid, supports LV and HV variants with runtime detection" - name: "SUN-xK-SG0xLP3 / HP3 hybrid" @@ -763,7 +763,7 @@ manufacturers: driver: "kstar" version: "1.1.1" ders: [pv, battery, meter] - control: false + control: true firmware_versions: "" notes: "Community driver, untested" - name: "KSE (Hybrid)" @@ -774,7 +774,7 @@ manufacturers: driver: "kstar" version: "1.1.1" ders: [pv, battery, meter] - control: false + control: true firmware_versions: "" notes: "Community driver, untested" - name: "Kaifa" @@ -1047,7 +1047,7 @@ manufacturers: driver: "pixii" version: "2.1.9" ders: [battery, meter] - control: false + control: true firmware_versions: "" notes: "" - name: "Remne Technologies" @@ -1513,7 +1513,7 @@ manufacturers: driver: "solax" version: "1.1.1" ders: [pv, battery, meter] - control: false + control: true firmware_versions: "" notes: "Community driver, untested" - name: "X3 Hybrid G4" @@ -1524,7 +1524,7 @@ manufacturers: driver: "solax" version: "1.1.1" ders: [pv, battery, meter] - control: false + control: true firmware_versions: "" notes: "Community driver, untested" - name: "X3 Hybrid G4 PRO" @@ -1535,7 +1535,7 @@ manufacturers: driver: "solax" version: "1.1.1" ders: [pv, battery, meter] - control: false + control: true firmware_versions: "" notes: "Community driver, untested" - name: "X3 MIC/PRO G2 (String)" @@ -1546,7 +1546,7 @@ manufacturers: driver: "solax" version: "1.1.1" ders: [pv, battery, meter] - control: false + control: true firmware_versions: "" notes: "Community driver, untested" - name: "SolarEdge" @@ -1559,7 +1559,7 @@ manufacturers: driver: "solaredge" version: "2.1.1" ders: [meter, pv] - control: false + control: true firmware_versions: "" notes: "Single-phase string inverters, port 1502" - name: "SE Series (Three-Phase)" @@ -1570,7 +1570,7 @@ manufacturers: driver: "solaredge" version: "2.1.1" ders: [meter, pv] - control: false + control: true firmware_versions: "" notes: "Three-phase string inverters, port 1502" - name: "SolarEdge Home" @@ -1581,7 +1581,7 @@ manufacturers: driver: "solaredge" version: "2.1.1" ders: [meter, pv] - control: false + control: true firmware_versions: "" notes: "Residential single-phase series" - name: "SolarEdge inverter (PV only)" @@ -1614,7 +1614,7 @@ manufacturers: driver: "solaredge" version: "2.1.1" ders: [meter, pv] - control: false + control: true firmware_versions: "" notes: "Hybrid inverters with battery support" - name: "Solinteg" @@ -1891,7 +1891,7 @@ manufacturers: driver: "varta" version: "1.1.1" ders: [battery, meter] - control: false + control: true firmware_versions: "" notes: "Community driver, untested" - name: "link" @@ -1902,7 +1902,7 @@ manufacturers: driver: "varta" version: "1.1.1" ders: [battery, meter] - control: false + control: true firmware_versions: "" notes: "Community driver, untested" - name: "pulse neo" @@ -1913,7 +1913,7 @@ manufacturers: driver: "varta" version: "1.1.1" ders: [battery, meter] - control: false + control: true firmware_versions: "" notes: "Community driver, untested" - name: "Various (Austrian)" diff --git a/index.yaml b/index.yaml index e3bb580c..73e54dd0 100644 --- a/index.yaml +++ b/index.yaml @@ -80,7 +80,7 @@ drivers: protocol: modbus connectivity: local ders: [pv, battery, meter] - control: false + control: true size_bytes: 4031 sha256: "eb76e0ff3be764a001b110a82a58f75ad967d4610d866eeb37e99802624fc07d" - name: "ambibox" @@ -182,7 +182,7 @@ drivers: protocol: modbus connectivity: local ders: [battery, meter, pv] - control: false + control: true size_bytes: 23467 sha256: "5fdc1acd72f881ff02696e765df0528a68f300fa9ca557a4fba068874f0129df" - name: "easee_cloud" @@ -408,7 +408,7 @@ drivers: protocol: modbus connectivity: local ders: [pv, battery, meter] - control: false + control: true size_bytes: 3615 sha256: "c6e41381f5a59f197b8e9899a770c32acd1e49c4c70a9faa3fec6b43f291d862" - name: "mennekes" @@ -513,7 +513,7 @@ drivers: protocol: modbus connectivity: local ders: [battery, meter] - control: false + control: true size_bytes: 32519 sha256: "77e233e2d24e970ebff8eaacd67967f57b651677d25ce7b57a1f97c3eaeb71fe" - name: "pixii_pv" @@ -652,7 +652,7 @@ drivers: protocol: modbus connectivity: local ders: [meter, pv] - control: false + control: true size_bytes: 21555 sha256: "94b5f18fb42c1413540d7321bca47ed755c8a0a9b069f8d51dbac4384910c496" - name: "solaredge_legacy" @@ -679,7 +679,7 @@ drivers: protocol: modbus connectivity: local ders: [pv, battery, meter] - control: false + control: true size_bytes: 5110 sha256: "b5f07776c959d4891a0487c23a3bc7e29b8c9c063eaaef754b98f0572cc547b2" - name: "solinteg" @@ -793,7 +793,7 @@ drivers: protocol: modbus connectivity: local ders: [battery, meter] - control: false + control: true size_bytes: 2794 sha256: "68eb714ff41551437e50ac0a1e9bca4e4d70eca8a43006c7481cfc8761fdf60d" - name: "victron" diff --git a/manifests/alphaess.yaml b/manifests/alphaess.yaml index ecab864e..c5d2927c 100644 --- a/manifests/alphaess.yaml +++ b/manifests/alphaess.yaml @@ -5,7 +5,7 @@ author: "Sourceful Labs AB" protocol: modbus connectivity: local ders: [pv, battery, meter] -control: false +control: true tested_devices: - manufacturer: "AlphaESS" model_family: "Smile Series" diff --git a/manifests/deye.yaml b/manifests/deye.yaml index 2211f2a2..811b01be 100644 --- a/manifests/deye.yaml +++ b/manifests/deye.yaml @@ -5,7 +5,7 @@ author: "Sourceful Labs AB" protocol: modbus connectivity: local ders: [battery, meter, pv] -control: false +control: true tested_devices: - manufacturer: "Deye" model_family: "SUN Single-Phase Hybrid (LV)" diff --git a/manifests/kstar.yaml b/manifests/kstar.yaml index d61c05ca..fb28b5d2 100644 --- a/manifests/kstar.yaml +++ b/manifests/kstar.yaml @@ -5,7 +5,7 @@ author: "Sourceful Labs AB" protocol: modbus connectivity: local ders: [pv, battery, meter] -control: false +control: true tested_devices: - manufacturer: "KSTAR" model_family: "KSE (Hybrid)" diff --git a/manifests/pixii.yaml b/manifests/pixii.yaml index c8a20883..083a6fc6 100644 --- a/manifests/pixii.yaml +++ b/manifests/pixii.yaml @@ -5,7 +5,7 @@ author: "Sourceful Labs AB and community contributors" protocol: modbus connectivity: local ders: [battery, meter] -control: false +control: true tested_devices: - manufacturer: "Pixii" model_family: "PowerShaper" diff --git a/manifests/solaredge.yaml b/manifests/solaredge.yaml index 992acb86..ebfae807 100644 --- a/manifests/solaredge.yaml +++ b/manifests/solaredge.yaml @@ -5,7 +5,7 @@ author: "Sourceful Labs AB" protocol: modbus connectivity: local ders: [meter, pv] -control: false +control: true tested_devices: - manufacturer: "SolarEdge" model_family: "SE Series (Single-Phase)" diff --git a/manifests/solax.yaml b/manifests/solax.yaml index de5f487c..426a656b 100644 --- a/manifests/solax.yaml +++ b/manifests/solax.yaml @@ -5,7 +5,7 @@ author: "Sourceful Labs AB" protocol: modbus connectivity: local ders: [pv, battery, meter] -control: false +control: true tested_devices: - manufacturer: "SolaX" model_family: "X1 Hybrid G4" diff --git a/manifests/varta.yaml b/manifests/varta.yaml index 887ba9c7..3ddd9e99 100644 --- a/manifests/varta.yaml +++ b/manifests/varta.yaml @@ -5,7 +5,7 @@ author: "Sourceful Labs AB" protocol: modbus connectivity: local ders: [battery, meter] -control: false +control: true tested_devices: - manufacturer: "VARTA" model_family: "pulse neo" diff --git a/spec/manifest-v2.md b/spec/manifest-v2.md index cf1bc8f8..7ac5b54b 100644 --- a/spec/manifest-v2.md +++ b/spec/manifest-v2.md @@ -14,7 +14,7 @@ Each driver has a YAML manifest in `manifests/` that describes its metadata, cap | `connectivity` | string | Yes | `local` or `cloud` — where the driver talks while running | | `setup` | list | No | What a human must obtain before it connects (see below) | | `ders` | list | Yes | DER types the driver covers (see below) | -| `control` | bool | Yes | Whether the driver supports EMS control commands | +| `control` | bool | Yes | Whether the driver controls: `true` exactly when its code has `driver_command` and does not declare `read_only = true` | | `tested_devices` | list | No | Devices tested against (see below) | | `upstream_docs` | list | No | Vendor reference documents to watch for register/protocol changes (see below) | | `min_host_version` | string | No | Minimum gateway firmware version required | diff --git a/tests/test_control_claims.py b/tests/test_control_claims.py index c15e7a03..a1bfda12 100644 --- a/tests/test_control_claims.py +++ b/tests/test_control_claims.py @@ -18,9 +18,13 @@ from __future__ import annotations import re +import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT / "tools")) + +from ftw_repository import driver_controls # noqa: E402 # Keywords that open a Lua block, for balancing against `end`. OPENERS = re.compile(r"\b(function|if|for|while|do)\b") @@ -121,3 +125,21 @@ def test_a_refusal_stub_is_recognised_as_inert() -> None: "function driver_command(action, value)\n" " return host.modbus_write(40001, value)\n" "end") + + +def test_the_manifest_control_flag_matches_the_code() -> None: + """`control:` in a manifest says what the signed channel ships. + + The channel decides control from the code (`driver_controls`), and + index.yaml and devices.yaml copy the manifest's flag. Seven manifests said + control: false for drivers the channel shipped with control, so those two + files told a reader less than FTW would do. A driver that gains or loses + its control path changes this flag in the same pull request. + """ + wrong = [] + for manifest in sorted((ROOT / "manifests").glob("*.yaml")): + source = ROOT / "drivers" / "lua" / f"{manifest.stem}.lua" + code = driver_controls(source.read_text(encoding="utf-8")) + if (control_flag(manifest) == "true") is not code: + wrong.append(f"{manifest.stem} (manifest {control_flag(manifest)}, code {str(code).lower()})") + assert not wrong, "control: disagrees with the driver code: " + ", ".join(wrong) diff --git a/tests/test_site.py b/tests/test_site.py index d4888977..1150153d 100644 --- a/tests/test_site.py +++ b/tests/test_site.py @@ -24,6 +24,7 @@ sys.path.insert(0, str(ROOT / "tools")) import generate_site # noqa: E402 +from ftw_repository import _load_channel # noqa: E402 from manifest_parser import parse_upstream_docs, parse_yaml_simple # noqa: E402 @@ -58,7 +59,6 @@ def test_versions_match_the_manifests(catalog: dict) -> None: (ROOT / "manifests" / f"{driver['id']}.yaml").read_text(encoding="utf-8")) assert driver["version"] == manifest.get("version"), driver["id"] assert driver["tier"] == manifest.get("tier", "community"), driver["id"] - assert driver["control"] == bool(manifest.get("control", False)), driver["id"] def test_hardware_claims_come_only_from_the_driver_source(catalog: dict) -> None: @@ -196,3 +196,88 @@ def test_page_lists_every_driver_without_javascript(rendered: Path) -> None: noscript = html[html.index("")] for driver_id in sorted(manifest_ids()): assert driver_id in noscript, f"{driver_id} is missing from the noscript list" + + +def test_control_is_what_the_signed_channel_publishes(catalog: dict) -> None: + """The page says a driver controls only when the channel ships it so. + + A Zaptec Go owner read nothing that said FTW would only watch the charger. + The manifest's control field had drifted from the code before, so the page + takes the answer from the same rule the channel build uses. + """ + published = { + entry["id"]: entry["controls"] + for entry in _load_channel(ROOT / "ftw-channel.json", ROOT) + } + for driver in catalog["drivers"]: + assert driver["control"] is published[driver["id"]], driver["id"] + assert (driver["control_state"] == "controls") is driver["control"], driver["id"] + + +def test_every_driver_says_what_ftw_can_do(catalog: dict) -> None: + """One of three answers, each in words, for every driver.""" + for driver in catalog["drivers"]: + state = driver["control_state"] + assert state in generate_site.CONTROL_STATES, driver["id"] + assert driver["control_label"] == generate_site.CONTROL_STATES[state] + assert driver["control_note"].strip(), driver["id"] + if state == "telemetry": + # Only a meter or PV driver may be quietly read-only. + assert driver["ders"], driver["id"] + assert set(driver["ders"]) <= generate_site.TELEMETRY_DERS, driver["id"] + if state == "reads_only": + assert "cannot control" in driver["control_note"], driver["id"] + if state == "controls" and not driver["hardware_verified"]: + assert "Experimental" in driver["control_note"], driver["id"] + if state != "reads_only": + assert not driver["control_reason"], driver["id"] + + +def test_a_read_only_charger_says_why(catalog: dict) -> None: + """A charger FTW cannot steer says so, with the driver's own reason. + + zaptec_cloud started this: it read the charger and never said why it did + not control. It controls now, as an experiment until a field report, and + tesla_wall_connector is the charger that cannot, because Tesla offers no + way to set its current. + """ + by_id = {d["id"]: d for d in catalog["drivers"]} + zaptec = by_id["zaptec_cloud"] + assert zaptec["control_state"] == "controls" + assert "Experimental" in zaptec["control_note"] + wall = by_id["tesla_wall_connector"] + assert wall["control_state"] == "reads_only" + assert "turns its control off" in wall["control_note"] + assert "Tesla offers no way" in wall["control_reason"] + assert len(wall["control_reason"]) <= generate_site.MAX_REASON_CHARS + 1 + + +def test_a_product_description_is_not_a_reason() -> None: + """Text that never mentions reading or control is left out.""" + assert generate_site.read_only_reason( + "Zaptec Go / Go 2 / Pro via Zaptec Cloud.", ["Community driver, untested"], + ["Wallbox Commander 2 EV Charger Driver", "Emits: V2X Charger (READ-ONLY)"]) == "" + assert generate_site.read_only_reason( + "Huawei SUN2000 via Modbus TCP. Read-only until a held-zero command is verified.", + [], []) == "Read-only until a held-zero command is verified." + + +def test_the_card_and_device_view_render_the_control_state() -> None: + """Guard the rendering, as for the documents.""" + script = generate_site.SCRIPT + card = script[script.index("function driverCard"): + script.index("function manufacturerView")] + assert "d.control_label" in card and "d.control_note" in card + assert "d.control_reason" in card and "controlNote +" in card + devices = script[script.index("function manufacturerView"): + script.index("function render()")] + assert "row.driver.control_label" in devices + + +def test_page_says_what_ftw_can_do_without_javascript(rendered: Path, catalog: dict) -> None: + html = (rendered / "index.html").read_text(encoding="utf-8") + noscript = html[html.index("")] + for driver in catalog["drivers"]: + row = re.search(rf"
  • {re.escape(driver['id'])}[^<]*
  • ", noscript) + assert row, driver["id"] + assert driver["control_label"].lower() in row.group(0), driver["id"] diff --git a/tools/ftw_repository.py b/tools/ftw_repository.py index 5b1cde42..05330d5c 100644 --- a/tools/ftw_repository.py +++ b/tools/ftw_repository.py @@ -622,6 +622,37 @@ def _ftw_artifact( return prefix + raw.rstrip(b"\n") + b"\n" + suffix.encode("utf-8") +def declares_read_only(body: str | None) -> bool: + """Whether a DRIVER table body says `read_only = true`.""" + return bool(body) and re.search( + r"^\s*read_only\s*=\s*true", body, re.MULTILINE + ) is not None + + +def has_command_entrypoint(source: str) -> bool: + """Whether the Lua source defines driver_command.""" + return "driver_command" in set(ENTRYPOINT_RE.findall(source)) + + +def driver_controls(source: str) -> bool: + """Whether the signed channel publishes this driver with control. + + The code decides, not the manifest. Sixteen battery drivers carried a + working driver_command while their manifests still said control: false, + so trusting the manifest published them unable to do the one thing they + were ported for. + + A driver that declares read_only in its own DRIVER table overrides this: + a meter saying what it is outranks an entrypoint it may only have + inherited from a shared source. + + The catalog page and the manifest check read control through this + function too, so the three cannot disagree. + """ + body = _lua_named_table_body(source, "DRIVER") + return has_command_entrypoint(source) and not declares_read_only(body) + + def _load_channel(config_path: Path, repo_root: Path) -> list[dict[str, Any]]: config = _read_json(config_path) if config.get("schema_version") != SCHEMA_VERSION: @@ -670,9 +701,7 @@ def _load_channel(config_path: Path, repo_root: Path) -> list[dict[str, Any]]: # A meter or telemetry gateway saying what it is. That statement wins # over the catalog, so a stray control: true cannot hand a P1 reader a # write path it has no code for. - declares_read_only = bool(body) and re.search( - r"^\s*read_only\s*=\s*true", body, re.MULTILINE - ) is not None + read_only_declared = declares_read_only(body) declares_controls = body is not None and _lua_has_top_level_field( body, "controls" ) @@ -687,12 +716,10 @@ def _load_channel(config_path: Path, repo_root: Path) -> list[dict[str, Any]]: if not path.startswith("/"): raise RepositoryError( f"{driver_id}: auth_post_path must be a path beginning with '/'") - if auth_post_paths and not declares_read_only: + if auth_post_paths and not read_only_declared: raise RepositoryError( f"{driver_id}: auth_post_path only means anything with read_only") - has_driver_command = "driver_command" in set(ENTRYPOINT_RE.findall(source)) - required_entrypoints = {"driver_init", "driver_poll"} missing = sorted(required_entrypoints - set(ENTRYPOINT_RE.findall(source))) if missing: @@ -747,15 +774,7 @@ def _load_channel(config_path: Path, repo_root: Path) -> list[dict[str, Any]]: model = device.get("model_family") or device.get("model") if isinstance(model, str) and model and model not in tested_models: tested_models.append(model) - # The code decides, not the manifest. Sixteen battery drivers carried a - # working driver_command while their manifests still said control: - # false, so trusting the manifest published them unable to do the one - # thing they were ported for. - # - # A driver that declares read_only in its own DRIVER table overrides - # this: a meter saying what it is outranks an entrypoint it may only - # have inherited from a shared source. - controls = has_driver_command and not declares_read_only + controls = driver_controls(source) # The DRIVER block's verification claim reaches the artifact only # when it is one the review actually gated: a driver declaring # production or beta made a checkable statement that a reviewer diff --git a/tools/generate_site.py b/tools/generate_site.py index 01f6541e..7fc50693 100644 --- a/tools/generate_site.py +++ b/tools/generate_site.py @@ -25,6 +25,8 @@ from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) +from ftw_repository import ( + _lua_named_table_body, declares_read_only, driver_controls) from manifest_parser import ( parse_tested_devices, parse_upstream_docs, parse_yaml_simple) @@ -107,6 +109,28 @@ } HARDWARE_VERIFIED = {"production", "tested"} MAX_SOURCE_NOTE_LINES = 12 +# What FTW can do with a device through this driver. A new owner reads this +# before anything else, and a charger FTW accepted but never controlled, with +# nothing to say why, is how they learned it the first time. The state comes +# from the code the way the signed channel reads it, never from the +# manifest's control field alone. +CONTROL_STATES = { + "controls": "Controls the device", + "reads_only": "Reads only", + "telemetry": "Telemetry only", +} +# Meters and PV report what they measure; FTW does not expect to steer them, +# so a driver that only reads them is complete, not held back. +TELEMETRY_DERS = {"meter", "pv"} +# Words a driver uses when it explains why it does not control. Only text +# that says so counts as the driver's reason; a plain product description +# does not. +READ_ONLY_WORDS = re.compile( + r"read[- ]?only|observ|\bcontrol(?:s|led|ling)?\b|\bcommand(?:s|ed)?\b|\bwrites?\b", + re.IGNORECASE) +# A header line that starts a new "Key: value" fact, such as "Protocol: ...". +HEADER_FIELD = re.compile(r"^[A-Z][A-Za-z /()-]{0,30}:\s") +MAX_REASON_CHARS = 420 def git_output(*args: str) -> str: @@ -174,7 +198,12 @@ def read_driver_source(path: Path) -> dict: if not path.exists(): return {} text = path.read_text(encoding="utf-8") - info: dict = {} + info: dict = { + "controls": driver_controls(text), + "declares_read_only": declares_read_only( + _lua_named_table_body(text, "DRIVER")), + "header": header_comment(text), + } table = re.search(r'^DRIVER\s*=\s*\{(.*?)^\}', text, re.MULTILINE | re.DOTALL) if table: @@ -210,6 +239,92 @@ def read_driver_source(path: Path) -> dict: return info +def header_passage(lines: list[str]) -> str: + """The first header comment passage that may explain control, or "". + + It starts at a line that uses one of READ_ONLY_WORDS and runs to the end of + its paragraph or to the next "Key: value" line. An "Emits:" line lists + outputs, so a "(READ-ONLY)" there is a label, not a reason. + """ + for i, raw in enumerate(lines): + line = raw.strip() + if not READ_ONLY_WORDS.search(line) or line.startswith("Emits:"): + continue + taken = [line] + for following in lines[i + 1:]: + following = following.strip() + if not following or HEADER_FIELD.match(following): + break + taken.append(following) + return " ".join(taken) + return "" + + +def clip(text: str) -> str: + """The text from the sentence that names control, at most MAX_REASON_CHARS. + + "Huawei SUN2000 ... via Modbus TCP. Read-only until a held-zero command is + verified" keeps only the second sentence: the first says what the driver + is, which the page already shows. + """ + text = " ".join(text.split()) + match = READ_ONLY_WORDS.search(text) + if match: + start = text.rfind(". ", 0, match.start()) + if start >= 0: + text = text[start + 2:] + if len(text) <= MAX_REASON_CHARS: + return text + cut = text[:MAX_REASON_CHARS] + end = cut.rfind(". ") + if end > MAX_REASON_CHARS // 3: + return cut[:end + 1] + return cut.rsplit(" ", 1)[0] + "…" + + +def read_only_reason(description: str, notes: list[str], header: list[str]) -> str: + """Why a driver does not control, in its own words, or "" if it never says. + + The DRIVER description comes first, then the manifest notes, then the + header comment. Each counts only when it talks about reading or control: + "Zaptec Go via Zaptec Cloud" is what the driver is, not why it reads only. + """ + for text in [description, *notes]: + if text and READ_ONLY_WORDS.search(text): + return clip(text) + passage = header_passage(header) + return clip(passage) if passage else "" + + +def control_summary(source: dict, ders: list[str], notes: list[str], + hardware_verified: bool) -> dict: + """Which of the three things FTW can do, with the words the page shows.""" + if source.get("controls"): + state = "controls" + note = ("Confirmed on real hardware, by the driver's verification record." + if hardware_verified else + "Experimental until a field report confirms control on real hardware.") + reason = "" + elif ders and set(ders) <= TELEMETRY_DERS: + state = "telemetry" + note = "FTW reads this device. A meter or solar inverter needs no control to be useful." + reason = "" + else: + state = "reads_only" + why = ("The driver turns its control off." if source.get("declares_read_only") + else "The driver has no control code yet.") + note = "FTW reads this device but cannot control it. " + why + reason = read_only_reason( + source.get("description", ""), notes, source.get("header", [])) + return { + "control": state == "controls", + "control_state": state, + "control_label": CONTROL_STATES[state], + "control_note": note, + "control_reason": reason, + } + + def upstream_documents(text: str) -> list[dict]: """The vendor documents a manifest declares, as the page will link them. @@ -277,6 +392,9 @@ def collect_drivers() -> list[dict]: verification["status"], (verification["status"], "partial")) verification["label"] = label verification["level"] = level + hardware_verified = bool( + verification and verification["status"] in HARDWARE_VERIFIED) + ders = data.get("ders", []) or [] drivers.append({ "id": driver_id, @@ -290,8 +408,10 @@ def collect_drivers() -> list[dict]: "protocol": data.get("protocol", ""), "connectivity": data.get("connectivity", ""), "setup": data.get("setup", []) or [], - "ders": data.get("ders", []) or [], - "control": bool(data.get("control", False)), + "ders": ders, + **control_summary( + source, ders, [d["notes"] for d in tested if d["notes"]], + hardware_verified), "author": data.get("author", ""), "min_host_version": data.get("min_host_version", ""), "size_bytes": data.get("size_bytes", 0), @@ -299,8 +419,7 @@ def collect_drivers() -> list[dict]: "tested_devices": tested, "upstream_docs": upstream_documents(text), "verification": verification, - "hardware_verified": bool( - verification and verification["status"] in HARDWARE_VERIFIED), + "hardware_verified": hardware_verified, "targets": { name: { "conformance": target.get("target_conformance", "not_assessed"), @@ -344,6 +463,7 @@ def build_catalog() -> dict: "setup": SETUP_LABELS, "doc_kinds": DOC_KIND_LABELS, "url_stability": URL_STABILITY_LABELS, + "control_states": CONTROL_STATES, }, "totals": { "drivers": len(drivers), @@ -351,6 +471,7 @@ def build_catalog() -> dict: "model_families": len(families), "variants": variants, "control": sum(1 for d in drivers if d["control"]), + "reads_only": sum(1 for d in drivers if d["control_state"] == "reads_only"), "hardware_verified": sum(1 for d in drivers if d["hardware_verified"]), }, "source": { @@ -454,15 +575,24 @@ def embed_json(payload: dict) -> str: .catalog-body { padding-top: 30px; } .driver { border: 1px solid var(--line); background: var(--surface); margin-bottom: -1px; } .driver.is-open { border-color: var(--ink); position: relative; z-index: 1; } -.driver-head { width: 100%; display: grid; grid-template-columns: minmax(0, 3fr) 90px 74px minmax(0, 1.6fr) 76px 92px 74px 22px; align-items: center; gap: 14px; padding: 15px 18px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; } +.driver-head { width: 100%; display: grid; grid-template-columns: minmax(0, 3fr) 90px 74px minmax(0, 1.6fr) 150px 92px 74px 22px; align-items: center; gap: 14px; padding: 15px 18px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; } .driver-head:hover { background: var(--signal-light); } .driver-id { display: block; color: var(--ink); font-family: var(--mono); font-size: 14px; font-weight: 700; } .driver-title { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .cell-label { display: none; } .badge { display: inline-block; padding: 2px 8px; border: 1px solid var(--line); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; } .badge.tier-core { border-color: var(--ink); background: var(--ink); color: var(--cream); } -.badge.control-yes { border-color: var(--signal); color: var(--signal); font-weight: 700; } -.badge.control-no { color: var(--muted); opacity: 0.7; } +.badge.control-controls { border-color: var(--signal); color: var(--signal); font-weight: 700; } +/* A charger or battery FTW cannot steer is the case people miss, so it reads + as a warning, not as a quieter version of the control badge. */ +.badge.control-reads_only { border-color: var(--ink); color: var(--ink); border-style: dashed; } +.badge.control-telemetry { color: var(--muted); opacity: 0.7; } +.capability { max-width: 88ch; margin: 16px 0 0; padding: 9px 13px; border-left: 2px solid var(--muted); background: rgba(103, 103, 98, 0.09); font-size: 13px; } +.capability b { margin-right: 9px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; } +.capability .why { display: block; margin-top: 5px; color: var(--muted); } +.capability.control-controls { border-left-color: var(--signal); background: var(--signal-light); } +.capability.control-reads_only { border-left-color: var(--ink); } +.family .driver-link .state-reads_only { color: var(--ink); font-weight: 700; } /* Local-first is the default this project is built for, so the badge that earns attention is the one that says a device stops without the internet. */ .badge.conn-cloud { border-style: dotted; color: var(--muted); } @@ -519,7 +649,7 @@ def embed_json(payload: dict) -> str: .empty { padding: 60px 0; color: var(--muted); text-align: center; } noscript .empty { color: var(--body); } -.table-head { display: grid; grid-template-columns: minmax(0, 3fr) 90px minmax(0, 1.6fr) 76px 92px 74px 22px; gap: 14px; padding: 0 18px 8px; color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; } +.table-head { display: grid; grid-template-columns: minmax(0, 3fr) 90px 74px minmax(0, 1.6fr) 150px 92px 74px 22px; gap: 14px; padding: 0 18px 8px; color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; } footer { background: var(--ink); color: var(--cream); padding-block: 44px 26px; } footer h2 { margin-bottom: 10px; font-size: 22px; font-weight: 700; letter-spacing: -0.03em; } @@ -534,7 +664,7 @@ def embed_json(payload: dict) -> str: .footer-bottom a { color: rgba(245, 242, 225, 0.66); } @media (max-width: 1080px) { - .driver-head, .table-head { grid-template-columns: minmax(0, 2.4fr) 84px minmax(0, 1.4fr) 70px 74px 22px; } + .driver-head, .table-head { grid-template-columns: minmax(0, 2.4fr) 84px 70px minmax(0, 1.4fr) 150px 70px 22px; } .driver-head .cell-host, .table-head .cell-host { display: none; } } @media (max-width: 780px) { @@ -672,9 +802,14 @@ def embed_json(payload: dict) -> str: function driverCard(d) { var ders = d.ders.map(function (x) { return '' + esc(derLabel(x)) + ""; }).join(""); - var control = d.control - ? 'Control' - : 'Read only'; + // What FTW can do with the device, in the same three words everywhere. + var control = '' + + esc(d.control_label) + ""; + var controlNote = '

    ' + + "" + esc(d.control_label) + "" + esc(d.control_note) + + (d.control_reason + ? 'In the driver’s words: ' + esc(d.control_reason) + "" : "") + + "

    "; var reach = d.connectivity ? '' + (d.connectivity === "cloud" ? "Cloud" : "Local") + "" @@ -724,6 +859,7 @@ def embed_json(payload: dict) -> str: "" + '
    ' + (d.description ? '

    ' + esc(d.description) + "

    " : "") + + controlNote + sourceNote + verified + modelsTable(d) + @@ -760,7 +896,8 @@ def embed_json(payload: dict) -> str: (row.dev.notes ? '
    ' + esc(row.dev.notes) + "
    " : "") + "
    " + '" + + ' · ' + + esc(row.driver.control_label.toLowerCase()) + "" + ""; }).join(""); return '

    ' + esc(name) + "

    " + families + "
    "; @@ -904,7 +1041,7 @@ def render_html(catalog: dict) -> str: f"{PROTOCOL_LABELS.get(d['protocol'], d['protocol'])} · " f"{CONNECTIVITY_LABELS.get(d['connectivity'], d['connectivity'])} · " f"{', '.join(DER_LABELS.get(x, x) for x in d['ders']) or 'unspecified'}" - f"{' · control' if d['control'] else ''}" + f" · {d['control_label'].lower()}" for d in drivers) commit_line = "" @@ -973,7 +1110,8 @@ def render_html(catalog: dict) -> str:
    Manufacturers
    {totals['manufacturers']}
    Model families
    {totals['model_families']}
    Listed variants
    {totals['variants']}
    -
    With control
    {totals['control']}
    +
    Controls the device
    {totals['control']}
    +
    Reads only
    {totals['reads_only']}
    Verified on hardware
    {totals['hardware_verified']}
    @@ -999,7 +1137,7 @@ def render_html(catalog: dict) -> str:
    Reach{connectivity_chips}
    To set up{setup_chips}
    Tier{tier_chips}
    -
    Evidence{chip("control", "control", "Can control")}{chip("verified", "verified", "Verified on hardware")}
    +
    Evidence{chip("control", "control", "Controls the device")}{chip("verified", "verified", "Verified on hardware")}

    {totals['drivers']} drivers

    @@ -1008,7 +1146,7 @@ def render_html(catalog: dict) -> str:
    - DriverProtocolReachEmitsCapability + DriverProtocolReachEmitsControl TierVersion
    From a703e129b65c5e481f05543058967dfc96cb613b Mon Sep 17 00:00:00 2001 From: Fredrik Ahlgren Date: Sat, 21 Nov 2026 18:24:46 +0100 Subject: [PATCH 2/2] fix: four stub drivers say read-only; reasons stop repeating the note Review of this branch: alphaess, kstar, solax and varta have a driver_command that only logs "not yet implemented" and refuses. The channel counts any driver_command as control, so it shipped them as controlling, and flipping their manifests made the catalog say "Controls the device". That is the false claim this work removes. - The four keep control: false. Each gains a DRIVER table with read_only = true and a description that says why: no control code has been written for it yet. Each is bumped a patch version, with a CHANGELOG entry. Their channel artifacts change. - is_inert ignores host.log, so a logging stub counts as a refusal, and a new check fails when a driver ships as control with such a stub. - The page's reason drops a lead-in that repeats the note ("FTW can read it but not control it:", "Read-only:"), starts with a capital, and is left out when fewer than five words remain, as for sonnen and zap. Core's readOnlyReason does the same; each points at the other. - README and spec/manifest-v2.md say control: true means FTW can command the device, not that driver_command exists. Signed-off-by: Fredrik Ahlgren Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 10 ++++++++ README.md | 17 ++++++++------ SUPPORT_STATUS.md | 16 ++++++------- devices.yaml | 44 ++++++++++++++++++------------------ drivers/lua/alphaess.lua | 16 +++++++++++++ drivers/lua/kstar.lua | 16 +++++++++++++ drivers/lua/solax.lua | 16 +++++++++++++ drivers/lua/varta.lua | 16 +++++++++++++ index.yaml | 32 +++++++++++++------------- manifests/alphaess.yaml | 8 +++---- manifests/kstar.yaml | 8 +++---- manifests/solax.yaml | 8 +++---- manifests/varta.yaml | 8 +++---- spec/manifest-v2.md | 2 +- support-status.json | 8 +++---- tests/test_control_claims.py | 33 ++++++++++++++++++++++++++- tests/test_ftw_repository.py | 8 ++++--- tests/test_site.py | 20 +++++++++++++++- tools/generate_site.py | 28 ++++++++++++++++++++--- 19 files changed, 232 insertions(+), 82 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01a5ac1f..58f4bcec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -259,6 +259,16 @@ hardware. readings now come from the vendor maps, and the ECU's 0xFFFFFFFF "no meter" value stays nil. +### alphaess 1.1.2, kstar 1.1.2, solax 1.1.2, varta 1.1.2 + +These four declare `read_only = true` and say why in their new `DRIVER` +table: no control code has been written for them. Their `driver_command` +only logs and refuses, yet the signed channel shipped them as controlling, +because it counts any `driver_command` as control. FTW then offered control +that could not work. Reading is unchanged. Their channel artifacts change: +the generated header now marks them read-only and drops their write +permissions. + ### zaptec_cloud 0.2.1 The stand-down now acts only after FTW has written a current in this run. diff --git a/README.md b/README.md index 16a559be..1178906d 100644 --- a/README.md +++ b/README.md @@ -120,13 +120,16 @@ promoted with `gh workflow run ftw-drivers-release.yml --ref main -f channel=stable`; it accepts only the exact commit `drivers-beta` carries, and serves installs that read the stable channel. -The channel contains every catalog driver as its own signed Lua asset. A driver -keeps its control path when its code has `driver_command` and its `DRIVER` -table does not say `read_only = true`; every other one is read-only. The -manifest's `control:` field must say the same, and `make check` fails when it -does not. The catalog page reads it the same way. Refreshing the signed -catalog never installs or activates code. FTW keeps its own safety, -activation, rollback and bundled copies. +The channel contains every catalog driver as its own signed Lua asset. A +driver that can command its device ships with control: its `driver_command` +writes to the device. A driver that cannot declares `read_only = true` in its +`DRIVER` table and says why in its description, and ships read-only. A +`driver_command` that only logs and refuses does not count as control. The +manifest's `control:` field states the same, and `make check` fails when it +disagrees with the code or when a stub ships as control. The catalog page +shows each driver's answer. Refreshing the signed catalog never installs or +activates code. FTW keeps its own safety, activation, rollback and bundled +copies. Each asset name contains the driver ID, semantic version and source hash. FTW downloads only the selected driver. The release workflow never replaces a diff --git a/SUPPORT_STATUS.md b/SUPPORT_STATUS.md index 8b87f684..919402fd 100644 --- a/SUPPORT_STATUS.md +++ b/SUPPORT_STATUS.md @@ -20,8 +20,8 @@ Catalog source is not proof that a target can install or run a driver. | acuvim | 0.4.3 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | alfen | 1.1.1 | ftw-core | not_assessed | — | not_recorded | not_assessed | | alfen | 1.1.1 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | -| alphaess | 1.1.1 | ftw-core | not_assessed | — | not_recorded | not_assessed | -| alphaess | 1.1.1 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | +| alphaess | 1.1.2 | ftw-core | not_assessed | — | not_recorded | not_assessed | +| alphaess | 1.1.2 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | ambibox | 1.2.0 | ftw-core | not_assessed | — | not_recorded | not_assessed | | ambibox | 1.2.0 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | ambibox_v2x | 1.1.1 | ftw-core | not_assessed | — | not_recorded | not_assessed | @@ -90,8 +90,8 @@ Catalog source is not proof that a target can install or run a driver. | konja-261-svk | 0.3.2 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | kostal | 2.1.2 | ftw-core | not_assessed | — | not_recorded | not_assessed | | kostal | 2.1.2 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | -| kstar | 1.1.1 | ftw-core | not_assessed | — | not_recorded | not_assessed | -| kstar | 1.1.1 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | +| kstar | 1.1.2 | ftw-core | not_assessed | — | not_recorded | not_assessed | +| kstar | 1.1.2 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | mennekes | 1.1.1 | ftw-core | not_assessed | — | not_recorded | not_assessed | | mennekes | 1.1.1 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | myuplink | 1.2.4 | ftw-core | not_assessed | — | not_recorded | not_assessed | @@ -148,8 +148,8 @@ Catalog source is not proof that a target can install or run a driver. | solaredge_legacy | 0.3.3 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | solaredge_pv | 1.2.2 | ftw-core | not_assessed | — | not_recorded | not_assessed | | solaredge_pv | 1.2.2 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | -| solax | 1.1.1 | ftw-core | not_assessed | — | not_recorded | not_assessed | -| solax | 1.1.1 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | +| solax | 1.1.2 | ftw-core | not_assessed | — | not_recorded | not_assessed | +| solax | 1.1.2 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | solinteg | 1.1.1 | ftw-core | not_assessed | — | not_recorded | not_assessed | | solinteg | 1.1.1 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | solis | 2.1.1 | ftw-core | not_assessed | — | not_recorded | not_assessed | @@ -172,8 +172,8 @@ Catalog source is not proof that a target can install or run a driver. | tibber | 1.1.2 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | vag_vehicle | 0.3.0 | ftw-core | not_assessed | — | not_recorded | not_assessed | | vag_vehicle | 0.3.0 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | -| varta | 1.1.1 | ftw-core | not_assessed | — | not_recorded | not_assessed | -| varta | 1.1.1 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | +| varta | 1.1.2 | ftw-core | not_assessed | — | not_recorded | not_assessed | +| varta | 1.1.2 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | victron | 2.1.2 | ftw-core | not_assessed | — | not_recorded | not_assessed | | victron | 2.1.2 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | victron_mqtt | 1.0.3 | ftw-core | not_assessed | — | not_recorded | not_assessed | diff --git a/devices.yaml b/devices.yaml index 61a1333c..9b3679db 100644 --- a/devices.yaml +++ b/devices.yaml @@ -135,9 +135,9 @@ manufacturers: protocols: - protocol: modbus driver: "alphaess" - version: "1.1.1" + version: "1.1.2" ders: [pv, battery, meter] - control: true + control: false firmware_versions: "" notes: "Community driver, untested" - name: "Smile Series" @@ -146,9 +146,9 @@ manufacturers: protocols: - protocol: modbus driver: "alphaess" - version: "1.1.1" + version: "1.1.2" ders: [pv, battery, meter] - control: true + control: false firmware_versions: "" notes: "Community driver, untested" - name: "Ambibox" @@ -761,9 +761,9 @@ manufacturers: protocols: - protocol: modbus driver: "kstar" - version: "1.1.1" + version: "1.1.2" ders: [pv, battery, meter] - control: true + control: false firmware_versions: "" notes: "Community driver, untested" - name: "KSE (Hybrid)" @@ -772,9 +772,9 @@ manufacturers: protocols: - protocol: modbus driver: "kstar" - version: "1.1.1" + version: "1.1.2" ders: [pv, battery, meter] - control: true + control: false firmware_versions: "" notes: "Community driver, untested" - name: "Kaifa" @@ -1511,9 +1511,9 @@ manufacturers: protocols: - protocol: modbus driver: "solax" - version: "1.1.1" + version: "1.1.2" ders: [pv, battery, meter] - control: true + control: false firmware_versions: "" notes: "Community driver, untested" - name: "X3 Hybrid G4" @@ -1522,9 +1522,9 @@ manufacturers: protocols: - protocol: modbus driver: "solax" - version: "1.1.1" + version: "1.1.2" ders: [pv, battery, meter] - control: true + control: false firmware_versions: "" notes: "Community driver, untested" - name: "X3 Hybrid G4 PRO" @@ -1533,9 +1533,9 @@ manufacturers: protocols: - protocol: modbus driver: "solax" - version: "1.1.1" + version: "1.1.2" ders: [pv, battery, meter] - control: true + control: false firmware_versions: "" notes: "Community driver, untested" - name: "X3 MIC/PRO G2 (String)" @@ -1544,9 +1544,9 @@ manufacturers: protocols: - protocol: modbus driver: "solax" - version: "1.1.1" + version: "1.1.2" ders: [pv, battery, meter] - control: true + control: false firmware_versions: "" notes: "Community driver, untested" - name: "SolarEdge" @@ -1889,9 +1889,9 @@ manufacturers: protocols: - protocol: modbus driver: "varta" - version: "1.1.1" + version: "1.1.2" ders: [battery, meter] - control: true + control: false firmware_versions: "" notes: "Community driver, untested" - name: "link" @@ -1900,9 +1900,9 @@ manufacturers: protocols: - protocol: modbus driver: "varta" - version: "1.1.1" + version: "1.1.2" ders: [battery, meter] - control: true + control: false firmware_versions: "" notes: "Community driver, untested" - name: "pulse neo" @@ -1911,9 +1911,9 @@ manufacturers: protocols: - protocol: modbus driver: "varta" - version: "1.1.1" + version: "1.1.2" ders: [battery, meter] - control: true + control: false firmware_versions: "" notes: "Community driver, untested" - name: "Various (Austrian)" diff --git a/drivers/lua/alphaess.lua b/drivers/lua/alphaess.lua index e58b6db7..18b13d46 100644 --- a/drivers/lua/alphaess.lua +++ b/drivers/lua/alphaess.lua @@ -6,6 +6,22 @@ -- Register map from AlphaESS Modbus protocol v1.30 -- Hex addresses converted to decimal +-- No control code has been written for this inverter yet: driver_command +-- only refuses. It says read_only so FTW and the catalog tell the owner +-- plainly, instead of offering control that cannot work. +DRIVER = { + host_api_min = 1, + host_api_max = 1, + id = "alphaess", + name = "AlphaESS inverter", + manufacturer = "AlphaESS", + version = "1.1.2", + protocols = { "modbus" }, + capabilities = { "pv", "battery", "meter" }, + read_only = true, + description = "AlphaESS Smile and G2 series inverters via Modbus TCP. Read-only: no control code has been written for it yet, so FTW reads it but cannot charge or discharge the battery.", +} + PROTOCOL = "modbus" -- A register the inverter never answers costs a failed read on every poll for diff --git a/drivers/lua/kstar.lua b/drivers/lua/kstar.lua index 09c976bd..c231164b 100644 --- a/drivers/lua/kstar.lua +++ b/drivers/lua/kstar.lua @@ -4,6 +4,22 @@ -- Port: 502 -- Community tier (untested) +-- No control code has been written for this inverter yet: driver_command +-- only refuses. It says read_only so FTW and the catalog tell the owner +-- plainly, instead of offering control that cannot work. +DRIVER = { + host_api_min = 1, + host_api_max = 1, + id = "kstar", + name = "KSTAR inverter", + manufacturer = "KSTAR", + version = "1.1.2", + protocols = { "modbus" }, + capabilities = { "pv", "battery", "meter" }, + read_only = true, + description = "KSTAR KSE and BluE-S series inverters via Modbus TCP. Read-only: no control code has been written for it yet, so FTW reads it but cannot charge or discharge the battery.", +} + PROTOCOL = "modbus" -- Reading a register the device does not have costs a failed read on every diff --git a/drivers/lua/solax.lua b/drivers/lua/solax.lua index 3723cd79..45f48c73 100644 --- a/drivers/lua/solax.lua +++ b/drivers/lua/solax.lua @@ -5,6 +5,22 @@ -- Port: 502 -- Community tier (untested) +-- No control code has been written for this inverter yet: driver_command +-- only refuses. It says read_only so FTW and the catalog tell the owner +-- plainly, instead of offering control that cannot work. +DRIVER = { + host_api_min = 1, + host_api_max = 1, + id = "solax", + name = "SolaX X1/X3 inverter", + manufacturer = "SolaX", + version = "1.1.2", + protocols = { "modbus" }, + capabilities = { "pv", "battery", "meter" }, + read_only = true, + description = "SolaX X1 and X3 hybrid and string inverters via Modbus TCP. Read-only: no control code has been written for it yet, so FTW reads it but cannot charge or discharge the battery.", +} + PROTOCOL = "modbus" -- Reading a register the device does not have costs a failed read on every diff --git a/drivers/lua/varta.lua b/drivers/lua/varta.lua index 44faffef..3e7bed4a 100644 --- a/drivers/lua/varta.lua +++ b/drivers/lua/varta.lua @@ -5,6 +5,22 @@ -- Port: 502 -- Community tier (untested) +-- No control code has been written for this storage yet: driver_command +-- only refuses. It says read_only so FTW and the catalog tell the owner +-- plainly, instead of offering control that cannot work. +DRIVER = { + host_api_min = 1, + host_api_max = 1, + id = "varta", + name = "VARTA storage", + manufacturer = "VARTA", + version = "1.1.2", + protocols = { "modbus" }, + capabilities = { "battery", "meter" }, + read_only = true, + description = "VARTA pulse neo, element and link storage via Modbus TCP. Read-only: no control code has been written for it yet, so FTW reads it but cannot charge or discharge the battery.", +} + PROTOCOL = "modbus" -- The host counts every failed modbus_read against the poll whether or not diff --git a/index.yaml b/index.yaml index 73e54dd0..5b7c4348 100644 --- a/index.yaml +++ b/index.yaml @@ -75,14 +75,14 @@ drivers: size_bytes: 23895 sha256: "e38da421ba6e5d3ceed2e9c6b7fdd620537b34e63ca48da14ac1e42080b133d0" - name: "alphaess" - version: "1.1.1" + version: "1.1.2" tier: community protocol: modbus connectivity: local ders: [pv, battery, meter] - control: true - size_bytes: 4031 - sha256: "eb76e0ff3be764a001b110a82a58f75ad967d4610d866eeb37e99802624fc07d" + control: false + size_bytes: 4704 + sha256: "a7721ee771ad5d818df1e870e3556d34b553405d122693d731aea7685647a1aa" - name: "ambibox" version: "1.2.0" tier: core @@ -403,14 +403,14 @@ drivers: size_bytes: 11222 sha256: "d85eabff2e1cb3076c27c0d980bd93c4c26df3d27a4801310baec30fda96c127" - name: "kstar" - version: "1.1.1" + version: "1.1.2" tier: community protocol: modbus connectivity: local ders: [pv, battery, meter] - control: true - size_bytes: 3615 - sha256: "c6e41381f5a59f197b8e9899a770c32acd1e49c4c70a9faa3fec6b43f291d862" + control: false + size_bytes: 4278 + sha256: "77442a239ebdc41832c86cc39f5186cd5f74d782a7c9c455743a2c7f6c0f59f1" - name: "mennekes" version: "1.1.1" tier: community @@ -674,14 +674,14 @@ drivers: size_bytes: 12121 sha256: "50d0d07dd92d14f93d3a4ba123fa7e036762437eee450e2caea6556d3b770582" - name: "solax" - version: "1.1.1" + version: "1.1.2" tier: community protocol: modbus connectivity: local ders: [pv, battery, meter] - control: true - size_bytes: 5110 - sha256: "b5f07776c959d4891a0487c23a3bc7e29b8c9c063eaaef754b98f0572cc547b2" + control: false + size_bytes: 5785 + sha256: "f52388cbe300dc8af699baac59ce52ffe1c489b4303409926d4d694ee82198af" - name: "solinteg" version: "1.1.1" tier: community @@ -788,14 +788,14 @@ drivers: size_bytes: 47864 sha256: "fcaa4a44ce26438f3c89d26e8ed3056ea4a195a3516a9ca9ed698c4eca42c5d3" - name: "varta" - version: "1.1.1" + version: "1.1.2" tier: community protocol: modbus connectivity: local ders: [battery, meter] - control: true - size_bytes: 2794 - sha256: "68eb714ff41551437e50ac0a1e9bca4e4d70eca8a43006c7481cfc8761fdf60d" + control: false + size_bytes: 3453 + sha256: "198a19deb76ee9ebc3b693922240ceafe61f32b7ce467bbc142a0b0f7b7f9e77" - name: "victron" version: "2.1.2" tier: community diff --git a/manifests/alphaess.yaml b/manifests/alphaess.yaml index c5d2927c..c970f3a7 100644 --- a/manifests/alphaess.yaml +++ b/manifests/alphaess.yaml @@ -1,11 +1,11 @@ name: "alphaess" -version: "1.1.1" +version: "1.1.2" tier: community author: "Sourceful Labs AB" protocol: modbus connectivity: local ders: [pv, battery, meter] -control: true +control: false tested_devices: - manufacturer: "AlphaESS" model_family: "Smile Series" @@ -22,9 +22,9 @@ tested_devices: notes: "Community driver, untested" min_driver_version: "1.0.0" min_host_version: "2.0.0" -size_bytes: 4031 +size_bytes: 4704 dkb_id: "" -sha256: "eb76e0ff3be764a001b110a82a58f75ad967d4610d866eeb37e99802624fc07d" +sha256: "a7721ee771ad5d818df1e870e3556d34b553405d122693d731aea7685647a1aa" signature: "" bytecode_sha256: "" diff --git a/manifests/kstar.yaml b/manifests/kstar.yaml index fb28b5d2..750c8791 100644 --- a/manifests/kstar.yaml +++ b/manifests/kstar.yaml @@ -1,11 +1,11 @@ name: "kstar" -version: "1.1.1" +version: "1.1.2" tier: community author: "Sourceful Labs AB" protocol: modbus connectivity: local ders: [pv, battery, meter] -control: true +control: false tested_devices: - manufacturer: "KSTAR" model_family: "KSE (Hybrid)" @@ -22,9 +22,9 @@ tested_devices: notes: "Community driver, untested" min_driver_version: "1.0.0" min_host_version: "2.0.0" -size_bytes: 3615 +size_bytes: 4278 dkb_id: "" -sha256: "c6e41381f5a59f197b8e9899a770c32acd1e49c4c70a9faa3fec6b43f291d862" +sha256: "77442a239ebdc41832c86cc39f5186cd5f74d782a7c9c455743a2c7f6c0f59f1" signature: "" bytecode_sha256: "" diff --git a/manifests/solax.yaml b/manifests/solax.yaml index 426a656b..bb6a818a 100644 --- a/manifests/solax.yaml +++ b/manifests/solax.yaml @@ -1,11 +1,11 @@ name: "solax" -version: "1.1.1" +version: "1.1.2" tier: community author: "Sourceful Labs AB" protocol: modbus connectivity: local ders: [pv, battery, meter] -control: true +control: false tested_devices: - manufacturer: "SolaX" model_family: "X1 Hybrid G4" @@ -36,9 +36,9 @@ tested_devices: notes: "Community driver, untested" min_driver_version: "1.0.0" min_host_version: "2.0.0" -size_bytes: 5110 +size_bytes: 5785 dkb_id: "" -sha256: "b5f07776c959d4891a0487c23a3bc7e29b8c9c063eaaef754b98f0572cc547b2" +sha256: "f52388cbe300dc8af699baac59ce52ffe1c489b4303409926d4d694ee82198af" signature: "" bytecode_sha256: "" diff --git a/manifests/varta.yaml b/manifests/varta.yaml index 3ddd9e99..57a298be 100644 --- a/manifests/varta.yaml +++ b/manifests/varta.yaml @@ -1,11 +1,11 @@ name: "varta" -version: "1.1.1" +version: "1.1.2" tier: community author: "Sourceful Labs AB" protocol: modbus connectivity: local ders: [battery, meter] -control: true +control: false tested_devices: - manufacturer: "VARTA" model_family: "pulse neo" @@ -29,9 +29,9 @@ tested_devices: notes: "Community driver, untested" min_driver_version: "1.0.0" min_host_version: "2.0.0" -size_bytes: 2794 +size_bytes: 3453 dkb_id: "" -sha256: "68eb714ff41551437e50ac0a1e9bca4e4d70eca8a43006c7481cfc8761fdf60d" +sha256: "198a19deb76ee9ebc3b693922240ceafe61f32b7ce467bbc142a0b0f7b7f9e77" signature: "" bytecode_sha256: "" diff --git a/spec/manifest-v2.md b/spec/manifest-v2.md index 7ac5b54b..ab097b61 100644 --- a/spec/manifest-v2.md +++ b/spec/manifest-v2.md @@ -14,7 +14,7 @@ Each driver has a YAML manifest in `manifests/` that describes its metadata, cap | `connectivity` | string | Yes | `local` or `cloud` — where the driver talks while running | | `setup` | list | No | What a human must obtain before it connects (see below) | | `ders` | list | Yes | DER types the driver covers (see below) | -| `control` | bool | Yes | Whether the driver controls: `true` exactly when its code has `driver_command` and does not declare `read_only = true` | +| `control` | bool | Yes | Whether FTW can command the device through this driver: `driver_command` writes to it and the `DRIVER` table does not declare `read_only = true`. A stub that only refuses is `false` and declares `read_only` | | `tested_devices` | list | No | Devices tested against (see below) | | `upstream_docs` | list | No | Vendor reference documents to watch for register/protocol changes (see below) | | `min_host_version` | string | No | Minimum gateway firmware version required | diff --git a/support-status.json b/support-status.json index 53a611d1..1028c435 100644 --- a/support-status.json +++ b/support-status.json @@ -170,7 +170,7 @@ }, { "catalog_source": true, - "catalog_version": "1.1.1", + "catalog_version": "1.1.2", "driver_id": "alphaess", "targets": { "blixt-l1": { @@ -905,7 +905,7 @@ }, { "catalog_source": true, - "catalog_version": "1.1.1", + "catalog_version": "1.1.2", "driver_id": "kstar", "targets": { "blixt-l1": { @@ -1514,7 +1514,7 @@ }, { "catalog_source": true, - "catalog_version": "1.1.1", + "catalog_version": "1.1.2", "driver_id": "solax", "targets": { "blixt-l1": { @@ -1766,7 +1766,7 @@ }, { "catalog_source": true, - "catalog_version": "1.1.1", + "catalog_version": "1.1.2", "driver_id": "varta", "targets": { "blixt-l1": { diff --git a/tests/test_control_claims.py b/tests/test_control_claims.py index a1bfda12..8b18f2bb 100644 --- a/tests/test_control_claims.py +++ b/tests/test_control_claims.py @@ -32,6 +32,10 @@ ELSEIF = re.compile(r"\belseif\b") CALL = re.compile(r"\b([A-Za-z_][A-Za-z_0-9.]*)\s*\(") NOT_A_CALL = {"function", "if", "while", "for", "return", "and", "or", "not"} +# Calls that cannot reach the device. A stub that logs "not yet implemented" +# and refuses is still a refusal: alphaess, kstar, solax and varta shipped as +# controlling that way. +CANNOT_ACTUATE = {"host.log", "tostring", "tonumber", "type"} def control_flag(manifest: Path) -> str: @@ -70,7 +74,8 @@ def is_inert(body: str) -> bool: # signature, not a call, and counting it made every body look busy. lines = re.sub(r"--.*$", "", body, flags=re.M).split("\n")[1:] code = "\n".join(line for line in lines if line.strip()) - calls = [c for c in CALL.findall(code) if c not in NOT_A_CALL] + calls = [c for c in CALL.findall(code) + if c not in NOT_A_CALL and c not in CANNOT_ACTUATE] return not calls @@ -120,6 +125,12 @@ def test_a_refusal_stub_is_recognised_as_inert() -> None: ' if action == "init" or action == "deinit" then return true end\n' " return false\n" "end") + # Logging the refusal does not make it a control path. + assert is_inert( + "function driver_command(action, power_w, cmd)\n" + ' host.log("AlphaESS control not yet implemented: " .. action)\n' + " return false\n" + "end") # Reaching any call at all is not. assert not is_inert( "function driver_command(action, value)\n" @@ -143,3 +154,23 @@ def test_the_manifest_control_flag_matches_the_code() -> None: if (control_flag(manifest) == "true") is not code: wrong.append(f"{manifest.stem} (manifest {control_flag(manifest)}, code {str(code).lower()})") assert not wrong, "control: disagrees with the driver code: " + ", ".join(wrong) + + +def test_a_logging_stub_cannot_be_published_as_control() -> None: + """A driver whose driver_command only logs and refuses must say read_only. + + The channel counts any driver_command as control, so a stub without + read_only = true ships as controlling and the catalog says so. Every such + driver has to declare read_only, which keeps its manifest at control: + false through the agreement check above. + """ + stubs = [] + for source in sorted((ROOT / "drivers" / "lua").glob("*.lua")): + text = source.read_text(encoding="utf-8") + body = function_source(text, "driver_command") + if body is not None and is_inert(body) and driver_controls(text): + stubs.append(source.stem) + assert not stubs, ( + "these drivers ship as controlling but their driver_command only " + f"refuses: {stubs}. Declare read_only = true in the DRIVER table and " + "say why in its description.") diff --git a/tests/test_ftw_repository.py b/tests/test_ftw_repository.py index 79510f1a..de041dca 100644 --- a/tests/test_ftw_repository.py +++ b/tests/test_ftw_repository.py @@ -176,10 +176,12 @@ def test_publication_contains_the_full_read_only_catalog( # driver_command, and publishing them unable to use it was the whole # problem: the same file could drive a battery bundled and not downloaded. controlling = {d["id"] for d in manifest["drivers"] if d["control_enabled"]} - assert {"sungrow", "pixii", "alphaess", "ferroamp"} <= controlling + assert {"sungrow", "pixii", "deye", "ferroamp"} <= controlling # And a driver that declares read_only in its own DRIVER table stays a - # meter, whatever anything else says. - assert not ({"sdm630", "zap", "esphome_dsmr", "myuplink"} & controlling) + # meter, whatever anything else says. alphaess, kstar, solax and varta + # declare it because their driver_command only refuses. + assert not ({"sdm630", "zap", "esphome_dsmr", "myuplink", + "alphaess", "kstar", "solax", "varta"} & controlling) # nibe_local dropped read_only for its opt-in Solar PV surplus feed and # declares write_capabilities, so the channel must publish it as control. assert "nibe_local" in controlling diff --git a/tests/test_site.py b/tests/test_site.py index 1150153d..d2bebbd3 100644 --- a/tests/test_site.py +++ b/tests/test_site.py @@ -248,10 +248,28 @@ def test_a_read_only_charger_says_why(catalog: dict) -> None: wall = by_id["tesla_wall_connector"] assert wall["control_state"] == "reads_only" assert "turns its control off" in wall["control_note"] - assert "Tesla offers no way" in wall["control_reason"] + assert wall["control_reason"].startswith("Tesla offers no way"), ( + "the reason must not repeat the note it follows") assert len(wall["control_reason"]) <= generate_site.MAX_REASON_CHARS + 1 +def test_a_reason_that_only_repeats_the_note_is_dropped(catalog: dict) -> None: + """sonnen's "Read-only." and zap's "never writes" add nothing to the note.""" + by_id = {d["id"]: d for d in catalog["drivers"]} + assert by_id["sonnen"]["control_state"] == "reads_only" + assert by_id["sonnen"]["control_reason"] == "" + assert by_id["zap"]["control_reason"] == "" + for driver in catalog["drivers"]: + reason = driver["control_reason"] + assert not generate_site.REASON_LEAD_IN.match(reason), driver["id"] + assert not reason or reason[0].isupper() or not reason[0].isalpha(), driver["id"] + # The four stub drivers now say why in their own description. + for driver_id in ("alphaess", "kstar", "solax", "varta"): + assert by_id[driver_id]["control_state"] == "reads_only", driver_id + assert by_id[driver_id]["control_reason"].startswith( + "No control code has been written"), driver_id + + def test_a_product_description_is_not_a_reason() -> None: """Text that never mentions reading or control is left out.""" assert generate_site.read_only_reason( diff --git a/tools/generate_site.py b/tools/generate_site.py index 7fc50693..081de6b9 100644 --- a/tools/generate_site.py +++ b/tools/generate_site.py @@ -131,6 +131,12 @@ # A header line that starts a new "Key: value" fact, such as "Protocol: ...". HEADER_FIELD = re.compile(r"^[A-Z][A-Za-z /()-]{0,30}:\s") MAX_REASON_CHARS = 420 +# The page already says "FTW reads this device but cannot control it", so a +# reason that opens by saying the same loses that opening. What is left has +# to say more than "the driver never writes" to count as a reason. +REASON_LEAD_IN = re.compile( + r"^(ftw can read it but not control it|read-only)\s*[:.]\s*", re.IGNORECASE) +MIN_REASON_WORDS = 5 def git_output(*args: str) -> str: @@ -282,18 +288,34 @@ def clip(text: str) -> str: return cut.rsplit(" ", 1)[0] + "…" +def plain_reason(text: str) -> str: + """The reason without a lead-in that repeats the page, or "" if none is left. + + "FTW can read it but not control it: Tesla offers no way ..." becomes + "Tesla offers no way ...". sonnen's "Read-only." and zap's "The driver + never writes." say nothing the page has not, so they give no reason. + """ + text = REASON_LEAD_IN.sub("", text.strip(), count=1) + text = text[:1].upper() + text[1:] + return text if len(text.split()) >= MIN_REASON_WORDS else "" + + def read_only_reason(description: str, notes: list[str], header: list[str]) -> str: """Why a driver does not control, in its own words, or "" if it never says. The DRIVER description comes first, then the manifest notes, then the - header comment. Each counts only when it talks about reading or control: + header comment. The first that talks about reading or control decides: "Zaptec Go via Zaptec Cloud" is what the driver is, not why it reads only. + + FTW Core shows the same reason on the box from the description alone: + readOnlyReason in go/internal/drivers/catalog.go in srcfl/ftw. Change the + two together. """ for text in [description, *notes]: if text and READ_ONLY_WORDS.search(text): - return clip(text) + return plain_reason(clip(text)) passage = header_passage(header) - return clip(passage) if passage else "" + return plain_reason(clip(passage)) if passage else "" def control_summary(source: dict, ders: list[str], notes: list[str],