Skip to main content

Building a remote-control screen

The requests compose like this:

  1. get_registers once per device, and the reply cached by model + access + registersVersion — the controllable catalog, writable-only by default: what exists, its dataType, scale, unit, category, and its min/max or options.
  2. Render by group. For a grouped model, use the server's {group, children} sections as the screen's sections (see Grouped replies); for a flat reply, group by category (control/config/alarm) yourself. Label each row with displayLabel and build each input from options / min/max. No access filtering and no parsing of vendor text is left to do client-side — the server already did both.
  3. Current values: either get_registers with includeValues: true (optionally narrowed with registers — at most 192 values per request), or a separate read_registers for up to 64 names at a time. One call is fewer round trips; the separate call lets you render the catalog before values arrive.
  4. write on edit → write_result.readBack updates that one row immediately, without a re-read.

Rendering a control from lowLimit / highLimit​

These are the vendor documentation's bounds, verbatim free text — not numbers, because that's what the source documents contain. For numeric settings they read like "5-50【default20】". For the many enum-style controls they carry the value meanings themselves:

{"name": "overload_restart", "lowLimit": "0:OFF\n1:ON [default]"}
{"name": "remote_on_off_enable", "lowLimit": "0:remote control off\n1:remote control on + power on [default]\n2:remote control on + power off/shutdown"}

That's what lets you choose a toggle, a dropdown or a number input and label the options, instead of hardcoding per register. Parse defensively — these strings come from parsed vendor PDFs, are not a guaranteed schema, and some are literally "reserved".

Confirming the new value: readBack​

value is what you asked for. readBack is what the device actually holds, re-read from the register immediately after the write. Render readBack, not value.

This matters because the write acknowledgement alone doesn't prove the value took. A function-6 write echoes address + value, which is reasonable evidence — but a function-16 write echoes address + quantity, so it confirms only that the device accepted a one-register write at that address. Every writable register on the Yorker profile (326 of them) writes via function 16, so for that model readBack is the only confirmation that exists.

readBack is absent — not zero — when no read-back was possible: a write-only register, or a read that failed. Absent does not mean the write failed; ok still reports that. Zero is a legitimate value for most of these registers, which is exactly why "unknown" is an absent field rather than 0.

:::caution value and values[].value are always present; only readBack is optional These fields previously used omitempty, so a value of 0 was omitted entirely — writing switch_on_and_off_enable: 0 (i.e. switching an inverter off) came back as {"ok":true} with no value at all, and reading it back gave {"register":"...","ok":true} with no value either. For an on/off register that made the "off" state indistinguishable from "no data". Both now always serialise. If you wrote a client that treats a missing value as "unknown", it can now rely on ok instead. :::

Where a vendor documents the same setting twice — once write-only and once read-write, which is common in these parsed specs — the write path picks the read-write definition, so readBack is available even though a write-only definition of the same name also exists.

Note that writable registers do not appear in telemetry. Settings live in the control/config/alarm register categories, and the telemetry cycle only reads the telemetry category — so a setting you change will never show up in a subsequent telemetry message. readBack is how you learn its new value.

A write_result with ok: false and error: "device offline or unreachable" means no tcpserver instance currently holds that device's live connection (it's disconnected, or the deviceKey doesn't correspond to any connected device) — this is the same failure mode you'd see trying to watch a device that never sends a telemetry message back.