Goal
Every unit of your site uploads one record a day, with fixed and published rules, without anyone running a command. Your units can then take part in the energy statistics and forecasts your tenant approves.
Before you start
- A machine on the site network that can reach your broker or your units, and the platform over HTTPS. A small Linux computer is enough. We test the gateway on Python 3.13.
- Your units registered as devices of your tenant, with their keys. The tenant admin's Onboarding checklist shows which are registered and paired.
- The gateway. It is part of the Python client (
python -m tlay_client.gateway). The code is not public yet: ask us for it and its example mappings. - An owner token for the units' owner, and the key authority's public key, pinned once.
Steps
- Write a mapping. One JSON file says:
- which source unit is which device;
- each unit's usable capacity;
- where each signal is: an MQTT topic with
{unit}where the unit id goes, a Modbus register, or a CSV column.
fault_codes. A scheduled stop or standby is then reported, not counted as a fault. - Connect.
- MQTT: name your broker in the mapping's
mqttsection (host, TLS with your CA and, if your broker asks, a client certificate, a user name and a password file). Then runlistenfor a minute to see what arrives, as one sample per line. With a persistent session, the broker keeps readings while the gateway is down. Each payload must then carry its own time (time_field), or late readings would be put at the minute they arrive. - Modbus: map each unit to
host:port/unit_idfor Modbus TCP, or give the serial line and each unit's slave address for RTU.poll-modbusreads every register once.
- MQTT: name your broker in the mapping's
- Check a day before you upload anything:
check --day YYYY-MM-DDprints the records it would send. A unit observed for less than 20 hours of the day, or with a value out of range, gets no record, and the line says why. - Run it as a service:
run --source mqtt-broker(ormodbus), with a spool directory, under systemd (an example unit comes with the gateway). It keeps every sample on disk. Five minutes after each UTC day ends, it finds the day's energy policy, checks it against the pinned key, sends each unit's record once, and keeps every upload receipt. - Add a standby (optional): the same gateway on a second machine, with its own spool and a later upload delay, for example two hours, and its own MQTT client id. It sends only what the first one did not.
What success looks like
status.jsonin the spool lists each day as done, with how many records were sent and why the others were not.- Each sent unit has its upload receipt in the spool, checked against the platform's key when it arrived. These are the receipts the unit's owner checks against their data-use trail.
- In the Admin console, Device health shows each unit uploading every day, and the Onboarding checklist moves on to the first policy.
Common refusals
| What you see | Why | What to do |
|---|---|---|
only 14.0 h of 20 h … | The unit was not observed for enough of the day | Check the unit's connection and max_gap_seconds; the day is skipped, not guessed |
sent elsewhere (409 DUPLICATE_CONTRIBUTION) | The platform already holds that unit's record for the day | Nothing: your other gateway sent it first, and its spool holds the receipt |
missed, SNAPSHOT_SEALED | The day was sealed before the gateway sent it | Keep the gateway's downtime under the seal grace; a standby helps |
Missing Authority Key … | Your broker's certificate chain lacks key identifiers, which the gateway's strict TLS check requires | Reissue the broker certificate from your CA |
not authorized from the broker | Wrong user name or password, or no access to the topics | Fix the password file or the broker's access list |
a persistent session needs … (mapping check) | Kept readings would arrive late with the wrong time | Add time_field, or use a clean session |
What it does not do yet
- It has run on synthetic telemetry, against real Mosquitto, EMQX and HiveMQ CE brokers in containers, a simulated serial line and our full stack. It has not run on a real battery management system or an RS-485 adapter.
- The gateway holds your units' keys, so they are software keys. Their owner states that, and buyers' models can weigh it.
- Without
--peer, a standby does not know whether the first gateway is alive: it only waits longer, and each unit's receipt is on the gateway that sent it, so keep both spools. With--peerthe two watch each other and copy each other's receipts (ADR 0052, proposed). - It reads only. It never writes to your units or your broker.