Connecting devices
flowchart LR
code["Claim code from site setup"] --> claim["Device: POST /v1/claims with code + certificate request"]
claim --> cert["Certificate for this device only"]
cert --> mqtt["MQTT over TLS, port 8883, client certificate"]
mqtt --> hello["v1/dev/{id}/hello → active"]
Directly (the default)
Most devices connect straight to the platform; no gateway is needed.
- In site setup, each device gets a claim code.
- The device (or its installer app) sends the code and a certificate signing request to
POST /v1/claims. No account is needed: the code is the credential.- A wrong, used or expired code gets a plain "not found".
- Repeated tries are slowed down.
- The device receives its certificate and connects to the broker over TLS (port 8883), using that certificate.
- It publishes
hello, then reports state and telemetry. It receives commands onv1/dev/{id}/cmdand answers oncmd/ack.
Topics and message format: contracts/asyncapi.yaml.
- Every message uses the shared envelope: an
idthat deduplicates, and aseqper device. - QoS 1.
- Certificates renew themselves through
cert/renewbefore they expire.
Through a gateway (optional)
A gateway is itself a device (template meryxon.sim-gateway or your own with gateway@1). It is useful when devices speak serial or a local radio, or when a site must keep working while the internet is down.
- Children: register them with the gateway's ID. A gateway may only speak for its own children.
- Configuration from the platform:
PUT /v1/gateways/{id}/configsends the gateway its whole configuration: each child's transport (serial, TCP, I2C…), driver and mapping, plus local rules.- The gateway applies it live and keeps the last good version.
GET /v1/gateways/{id}/configshows the version that runs, and any version the gateway refused, with its reason.
- Discovery: devices the gateway finds but nobody configured are listed at
GET /v1/gateways/{id}/discovered. Adopting one registers its devices and sends a new version with them. - Offline: the gateway keeps every message on disk until the platform confirms it stored it, and sends them in order once it reconnects.
- Local rules: they keep running locally, so a door can still lock and a wall button still switches its lights with the internet down. Rules fire on readings and on events such as button presses.
- The phone on site: with the local link on, the mobile app reaches the gateway on the site network with a 7-day local pass. It sees and switches devices with the internet down, with the same permissions.
- Updates: gateway software updates roll out in waves from the platform (fleet jobs) and roll back automatically if a wave fails.
A worked example, a Raspberry Pi with four lighting boards, is in A Raspberry Pi as the site gateway.
Devices wired to the gateway: I2C and GPIO
Sensors and relays on the gateway's own I2C bus, and relays, wall buttons and door contacts on its GPIO pins, are children like any other. The transport's address is the bus: /dev/i2c-1 or /dev/gpiochip0. The mapping says what is on it.
{ "children": [
{ "device": "dev_…", "transport": { "kind": "gpio", "address": "/dev/gpiochip0" }, "driver": { "kind": "native", "ref": "gpio" },
"mapping": { "line": 17, "kind": "switch" } },
{ "device": "dev_…", "transport": { "kind": "gpio", "address": "/dev/gpiochip0" }, "driver": { "kind": "native", "ref": "gpio" },
"mapping": { "line": 4, "kind": "button", "activeLow": true } },
{ "device": "dev_…", "transport": { "kind": "i2c", "address": "/dev/i2c-1" }, "driver": { "kind": "native", "ref": "i2c-map" },
"mapping": { "address": "0x48", "model": "tmp102", "everyS": 5,
"points": [{ "capability": "sensor.temperature@1", "property": "celsius", "register": 0, "length": 2, "type": "tmp102" }] } },
{ "device": "dev_…", "transport": { "kind": "i2c", "address": "/dev/i2c-1" }, "driver": { "kind": "native", "ref": "i2c-map" },
"mapping": { "address": "0x20", "points": [{ "capability": "switch@1", "property": "on", "register": -1, "length": 1, "type": "uint8", "bit": 0, "writable": true }] } }
] }
- GPIO kinds:
switchdrives a relay and reads the line back after each change.buttonturns presses intobutton@1events:single,double(a second press within 400 ms) orlong(held 900 ms or more), with a 50 ms debounce. Local rules can act on them with the internet down.contactreportssensor.contact@1open or closed, withopenedandclosedevents.activeLowis for lines that are on when low, such as a button to ground with a pull-up.
- I2C maps:
- Each point reads
lengthbytes fromregister(-1for devices without registers, like the PCF8574), asuint8,uint16be,int16beortmp102, then appliesscaleandoffset. - A writable point is one bit of a
uint8, as on a port expander driving relays. The state is read back from the device after each change. - The address is a number or hex as the datasheet gives it (
"0x48"). Children on one bus share it.
- Each point reads
- Offline: a device that stops answering on the bus is shown offline, and comes back when it answers again.
- Templates:
meryxon.wired-switch,meryxon.wired-button,meryxon.wired-contactandmeryxon.i2c-temperature. - The inventory lists the I2C buses and GPIO chips the gateway can see.
ONVIF cameras through the gateway
IP cameras that speak ONVIF are driven by the gateway: live view through the media relay, snapshots, PTZ and presets where the camera has them.
Discovery: add
"onvif": {}tolocalNetworkin the gateway's bootstrap file. The gateway probes the site network by WS-Discovery every 5 minutes (everySto change that) and lists each camera atGET /v1/gateways/{id}/discovered, with templatemeryxon.onvif-camera.Passwords stay on the gateway. A discovered camera comes with
driver.secrets: ["password"]. Adopt it with the camera's user added todriver.config, and put the password in the gateway's bootstrap file:- under
"secrets": { "password": "…" }for every camera on the site; - or under
"<device id>.password"for one camera.
The platform refuses a configuration with a secret in
driver.config.- under
A child:
{ "device": "dev_…", "transport": { "kind": "http", "address": "http://192.168.1.60/onvif/device_service" },
"driver": { "kind": "native", "ref": "onvif", "config": { "address": "http://192.168.1.60/onvif/device_service", "user": "meryxon" }, "secrets": ["password"] } }
- Then set it up as a gateway camera with
PUT /v1/devices/{id}/cameraand{"source": {"kind": "gateway"}, "features": {}}. What the camera reports wins over what was typed, and its owner gets live view and PTZ.
TVs and media renderers through the gateway (UPnP/DLNA)
TVs, speakers and other DLNA media renderers on the site network become media.player@1 devices.
- Discovery: add
"ssdp": {}tolocalNetworkin the gateway's bootstrap file. The gateway searches the network by SSDP every 5 minutes (everySto change that), lists each renderer atGET /v1/gateways/{id}/discoveredwith templatemeryxon.tv, and fills in the TV's MAC from its ARP table for Wake-on-LAN. - A child names the renderer's description URL:
{ "device": "dev_…", "transport": { "kind": "http", "address": "http://192.168.1.40:9197/dmr" }, "driver": { "kind": "native", "ref": "upnp-renderer" },
"mapping": { "location": "http://192.168.1.40:9197/dmr", "wol": { "mac": "a8:23:fe:01:02:03" } } }
What it does:
- volume and mute (RenderingControl);
- play, pause and stop, with the playback state (AVTransport);
- power on by Wake-on-LAN, when
wolis set (broadcast255.255.255.255:9unlesswol.addresssays otherwise).
The state is read back from the TV after every command and every 5 seconds.
featuressays which controls the TV has, and the apps show only those.Power off and inputs: UPnP has no standard for either. Samsung and LG sets have their own LAN APIs, and a TV plugged into the gateway's HDMI port can be driven over HDMI-CEC (both below).
Offline: a TV that doesn't answer is shown as off. It stays online if it can be woken; otherwise it shows offline.
Samsung and LG sets by their vendor LAN API
A Samsung (Tizen) or LG (webOS) set found by SSDP is listed twice in discovered: once with upnp-renderer, once with samsung-tv or lg-webos. Both control the same set; pick one.
- Pairing: the first time the gateway connects, the TV asks the person in front of it to allow it. Accept it on the TV with the remote. Until then the device's commands fail with
not_paired, and the gateway asks again 30 seconds after a refusal. - What the gateway keeps: the token (Samsung) or client key (LG), and the fingerprint of the TV's self-signed certificate, pinned on first use. Both are stored in the gateway's store for that device, so a restart doesn't prompt again. If the certificate changes (another set at the address, or someone in the middle), the gateway stops talking to it. Remove the device and add it again to pair anew.
- Samsung children use the REST port (8001) for the power state and the remote-control WebSocket (8002, TLS) for keys:
{ "device": "dev_…", "transport": { "kind": "tcp", "address": "192.168.1.41" }, "driver": { "kind": "native", "ref": "samsung-tv" },
"mapping": { "inputs": ["HDMI1", "HDMI2"], "wol": { "mac": "a8:23:fe:0a:0b:0c" } } }
- Power off and inputs (
HDMI1…, sent as remote keys). Power on by Wake-on-LAN. - The LAN API has no absolute volume, and doesn't say which input is showing, so neither is reported. Use the UPnP driver if you need volume.
- LG children use SSAP over TLS on port 3001:
{ "device": "dev_…", "transport": { "kind": "tcp", "address": "192.168.1.42" }, "driver": { "kind": "native", "ref": "lg-webos" },
"mapping": { "wol": { "mac": "64:95:6c:01:02:03" } } }
- Power state and off, volume and mute, and the inputs the set lists (
HDMI_1…), with the current input read back from the set. Power on by Wake-on-LAN (enable "Turn on via Wi-Fi/LAN" on the TV).
A TV on the gateway's HDMI port (HDMI-CEC)
A gateway with an HDMI port wired to a TV (a Raspberry Pi has two) drives the TV over HDMI-CEC, through the Linux CEC framework (/dev/cec0, /dev/cec1). The gateway claims a playback address on the bus. The inventory lists each adapter as transport cec.
- A child names the adapter and the TV's inputs by physical address (HDMI 1 is
1.0.0.0, HDMI 2 is2.0.0.0):
{ "device": "dev_…", "transport": { "kind": "cec", "address": "/dev/cec0" }, "driver": { "kind": "native", "ref": "hdmi-cec" },
"mapping": { "inputs": [{ "name": "Gateway", "address": "1.0.0.0" }, { "name": "Blu-ray", "address": "2.0.0.0" }] } }
- What it does:
- power on (Image View On) and standby, done when the TV reports its power status;
- inputs by Set Stream Path;
- the power status every 5 seconds (
everySto change that).
- What it reports:
- the input only when the bus says which one shows: a player announcing itself, or the TV announcing a change made with its own remote;
- after switching to an input with nothing CEC on it, the input is unknown, never the old one;
- a TV that doesn't acknowledge on the bus (unplugged, or the cable) shows offline.
- Not offered: volume. CEC has no absolute volume, only key presses.
Zigbee devices through the gateway (zigbee2mqtt)
The gateway doesn't speak Zigbee itself. zigbee2mqtt does, with a Zigbee USB coordinator, as a separate program next to the gateway (it is GPL-3.0). The two meet on the site's MQTT, the broker the gateway runs.
- Set up zigbee2mqtt with
mqtt.server: mqtt://<gateway>:1883, the site MQTT's user and password, the default base topiczigbee2mqtt, andavailability: enabled: true, so a device that drops off shows offline. - Pair devices from the platform: on the gateway, Add devices opens the Zigbee network (
pairing@1start, 2 minutes by default) and the new device shows in the discovered devices. zigbee2mqtt's own frontend works too. Add"zigbee2mqtt": {}tolocalNetworkso the gateway offers it. - Let the gateway run it (optional): give
localNetwork.zigbee2mqttacommand, for example{ "command": ["node", "index.js"], "dir": "/opt/zigbee2mqtt", "env": ["ZIGBEE2MQTT_DATA=/var/lib/zigbee2mqtt"] }. The gateway starts it as its own process after the site MQTT is up, restarts it whenever it exits (1 s, doubling to a minute) and stops it with the gateway. Without a command, run zigbee2mqtt yourself (systemd or Docker). - Discovery: every joined device is listed at
GET /v1/gateways/{id}/discovered, identified by its IEEE address, with the template it fits. Adopt it from there. - A child names the device by IEEE address, so renaming it in zigbee2mqtt changes nothing:
{ "device": "dev_…", "transport": { "kind": "mqtt-local", "address": "embedded://0.0.0.0:1883" }, "driver": { "kind": "native", "ref": "zigbee2mqtt" },
"mapping": { "ieee": "0x00158d0001a2b3c4", "baseTopic": "zigbee2mqtt" } }
- What it reports:
stateasswitch@1, switched through<base>/<name>/set; a command succeeds only when the device reports the new state;temperatureandhumidityas sensors;contactassensor.contact@1(zigbee2mqtt'struemeans closed);action(single,double,hold) asbutton@1presses;brightness(0–254) aslevel@1(0–100 %), set withstateON; level 0 switches the light off and keeps its brightness;- climate devices as
thermostat@1:occupied_heating_setpoint(or the cooling set point in cool mode) as the set point, to the nearest 0.5 °C;system_modeas the mode (off, heat, cool, auto only);running_stateas running;local_temperatureassensor.temperature@1;features(the set-point range and the modes) from the device's exposes, and a set outside them is refused.
- Offline: a device reported unavailable, or zigbee2mqtt itself stopping, shows offline.
- Templates:
meryxon.zigbee-switch,meryxon.zigbee-dimmer,meryxon.zigbee-thermostat,meryxon.zigbee-thermometer,meryxon.zigbee-contact,meryxon.zigbee-button.
Z-Wave devices through the gateway (Z-Wave JS UI)
The gateway doesn't speak Z-Wave itself. Z-Wave JS UI (MIT) does, with a Z-Wave USB stick, as a separate program whose MQTT gateway publishes on the site's MQTT.
Set up its MQTT gateway:
- point it at the gateway's site MQTT with the site user and password, prefix
zwave(or name yours inlocalNetwork.zwaveJsUi.prefix); - topic type ValueID topics, with Use node names instead of numeric nodeIDs off;
- payload type JSON Time-Value;
- Retain values and Publish node details on.
- point it at the gateway's site MQTT with the site user and password, prefix
Include devices from the platform (
pairing@1start starts inclusion through Z-Wave JS UI's MQTT API; it ends when one node is added or the time is up), or in Z-Wave JS UI. Add"zwaveJsUi": {}tolocalNetworkso the gateway offers it. A device that asks for an S2 PIN still needs Z-Wave JS UI's frontend for now.Discovery: each node is listed at
GET /v1/gateways/{id}/discovered, with a value map built from the values it publishes:- Binary Switch →
switch@1; - Multilevel Sensor air temperature and humidity → sensors;
- Notification door state →
sensor.contact@1; - Central Scene →
button@1(pressed, pressed twice, held → single, double, long); - Multilevel Switch →
switch@1andlevel@1(0–99 as 0–100 %, 99 being full; switching on writes 255, the last level); - Thermostat Setpoint (heating), Mode and Operating State →
thermostat@1.
A remote shows up once a button has been pressed. Adopt from there.
- Binary Switch →
Thermostat limits: Z-Wave JS UI's value topics don't carry them. Add them to the mapping as
"features": { "setpoint_min": 5, "setpoint_max": 30, "modes": ["off", "heat"] }; the apps then offer only those, and a set outside them is refused.A child is that map, which can be edited for other devices:
{ "device": "dev_…", "transport": { "kind": "mqtt-local", "address": "embedded://0.0.0.0:1883" }, "driver": { "kind": "native", "ref": "zwave-js-ui" },
"mapping": { "prefix": "zwave", "node": 5, "points": [{ "capability": "switch@1", "property": "on", "value": "37/0/currentValue", "set": "37/0/targetValue", "type": "bool" }] } }
- Commands: a command writes the target value (or set point, or mode) and succeeds only when the node reports the new state.
- Offline: a node marked dead shows offline.
- Templates:
meryxon.zwave-switch,meryxon.zwave-dimmer,meryxon.zwave-thermostat,meryxon.zwave-multisensor,meryxon.zwave-contact,meryxon.zwave-button.
Matter devices through the gateway (python-matter-server)
The gateway doesn't speak Matter itself. python-matter-server (Apache-2.0) does: it holds the site's Matter fabric (over Wi-Fi, or Thread with a border router) and offers a WebSocket API. Run it next to the agent.
- Turn it on: add
"matter": { "server": "ws://127.0.0.1:5580/ws" }to the gateway's bootstrap file. - Commission devices from the platform with the device's setup code (
pairing@1start withcode: the QR payloadMT:…or the 11 or 21-digit manual code), or with the Matter server. SetnetworkOnlywhen the device is already on the site's Wi-Fi or Thread network. - Discovery: every node endpoint the server knows is listed at
GET /v1/gateways/{id}/discovered, with the template its clusters fit. Adopt it from there. - A child is one endpoint of a node, and its children share one connection to the server:
{ "device": "dev_…", "transport": { "kind": "matter", "address": "ws://127.0.0.1:5580/ws" }, "driver": { "kind": "native", "ref": "matter" }, "mapping": { "node": 11, "endpoint": 1 } }
- What it does:
- OnOff as
switch@1; a command succeeds only when the node reports the new state; - TemperatureMeasurement and RelativeHumidityMeasurement as sensors;
- BooleanState as
sensor.contact@1; - Switch presses (multi-press complete, long press) as
button@1; - LevelControl as
level@1(CurrentLevel 1–254), set with MoveToLevelWithOnOff; level 0 switches the light off; - the Thermostat cluster as
thermostat@1:- the occupied heating set point (cooling in cool mode) is written as an attribute;
- SystemMode as the mode;
- ThermostatRunningState as running;
- LocalTemperature as
sensor.temperature@1; featuresfrom the set-point limits, ControlSequenceOfOperation and the AUTO feature.
- OnOff as
- Offline: a node the server can't reach, or the server itself going away, shows offline. The gateway reconnects on its own.
- Templates:
meryxon.matter-switch,meryxon.matter-dimmer,meryxon.matter-thermostat,meryxon.matter-sensor,meryxon.matter-contact,meryxon.matter-button.
Bluetooth LE sensors (BTHome) through the gateway
Battery sensors and buttons that advertise BTHome v2 are heard by the gateway; nothing connects to them. Examples are Shelly BLU devices and thermometers running BTHome firmware.
- Turn it on in the gateway's bootstrap file with
"bluetooth": { "adapter": "hci0" }. The gateway uses BlueZ over D-Bus. - Discovery: every BTHome device heard is listed at
GET /v1/gateways/{id}/discovered, with the template it fits. Adopt it from there. - A child names the device's address in its transport:
{ "device": "dev_…", "transport": { "kind": "ble", "address": "A4:C1:38:12:34:56" }, "driver": { "kind": "native", "ref": "bthome" }, "mapping": { "timeoutS": 600 } }
- What it reports:
- temperature as
sensor.temperature@1, humidity assensor.humidity@1; - door and window objects as
sensor.contact@1, withopenedandclosedevents; - button presses (single, double, long) as
button@1events. A packet repeated in the air counts once, and local rules can act on presses with the internet down.
- temperature as
- Offline: a device not heard for
timeoutSseconds (10 minutes by default) shows offline. - Encrypted BTHome: a device with encryption on is discovered and marked
encrypted; it asks for its bind key (32 hex digits, from the vendor's app) as the device secretbindKey, set when adding it or later withsetGatewayChildSecrets("driver": { "kind": "native", "ref": "bthome", "secrets": ["bindKey"] }). The gateway opens each advertisement with AES-128-CCM and refuses a packet whose counter is not higher than the last one (a replay) and a clear packet from a device that has a key. Without the key, or with the wrong one, the device stays offline. A sensor whose counter restarts (some do after a battery change) is refused until the gateway restarts. - Templates:
meryxon.ble-thermometer,meryxon.ble-contact,meryxon.ble-button.
Adding devices from the apps (pairing@1)
A gateway with zigbee2mqtt, Z-Wave JS UI or a Matter server next to it offers pairing@1; features.protocols lists which.
startopens the Zigbee network, starts Z-Wave inclusion, or commissions a Matter device with its code.- It is a guarded action: only a person with the right to guarded actions can start it, and they confirm it (
POST /v1/commands/{id}/confirm). - Rules, plugins and AI never can.
- Matter commissioning can take up to two minutes, so send
timeoutS: 150.
- It is a guarded action: only a person with the right to guarded actions can start it, and they confirm it (
stopcloses the Zigbee network or ends inclusion.opensays until when each network accepts devices, as the sidecar confirmed it.joinedevents name each new device, which then shows in the discovered devices to adopt.- Over the local link, a phone on the site network can start pairing while the internet is down.
- The gateway records the command but can't yet send it to the platform: the broker accepts
cmd/localonly for a gateway's children.
- The gateway records the command but can't yet send it to the platform: the broker accepts
LoRaWAN devices through a network server
LoRaWAN devices join a network server, ChirpStack v4 or The Things Stack, never a Meryxon gateway. The LoRaWAN connector (apps/connectors/lorawan, compose profile lorawan) subscribes to the network server's MQTT integration and forwards each frame to the platform under the device's vendor prefix: v1/dev/{id}/x/lorawan/up/{fPort} with the payload as hex, and .../x/lorawan/join when it joins. Ingest decodes it with the template's codec, as for any vendor device; commands are encoded by the same codec and queued as confirmed downlinks that expire with the command.
- Template:
meryxon.lorawan-cayenne(codecmeryxon.cayenne-lpp): temperature, humidity and a relay output in Cayenne LPP. Other payloads need their own codec; try one on a pasted frame in the codec playground (developer tools). - Activation: a device activates on its first join after it is linked.
- Not done yet: downlink acknowledgements: a command is not confirmed even when the device ran it, and the device's next report shows its real state; the HTTP webhook integration (Networks) remains for field mappings without a codec.
What each protocol does today
The protocol labels in the apps promise only what is below. A model is supported only when its template records a field validation (support in the device template, ON-10); these families have no such record yet, so their models show untested. A found device the gateway can't drive says why in the list of found devices.
| Family | Discovery | Read | Write | Events | Offline | Not supported yet |
|---|---|---|---|---|---|---|
| Bluetooth LE sensors (BTHome v2) | Yes, every device heard | Yes | No (they only advertise) | Yes (buttons, contacts) | Yes | Encrypted BTHome works with the bind key (secret bindKey); a sensor whose counter restarts is refused until the gateway restarts |
| BACnet/IP and BACnet MS/TP behind a router | No (configured by address) | Yes, present-value, including answers that come in segments (up to 16 segments) | Binary objects, at a priority | No (polled) | Yes | Who-Is discovery, change-of-value subscriptions, writing analog objects |
| Wired M-Bus (EN 13757) | No (configured by primary address) | Yes, variable data records | No (read only) | No (polled) | Yes | Secondary addressing, multi-telegram answers |
| Wireless M-Bus (through wmbusmeters) | No (configured by topic and ID) | Yes, wmbusmeters' numeric fields | No (read only) | No | Yes | Decoding in the gateway (wmbusmeters does it); meters wmbusmeters has no driver for |
| CANopen (CiA 301, SocketCAN) | No (configured by node ID) | Yes, by SDO and TPDO | switch@1 (a bool or one bit), read back |
No (TPDO values go out at once) | Yes | PDO mapping from the gateway, LSS, segmented writes |
| SNMP v2c and v3 | No (configured by address) | Yes, numeric OIDs | No (read only) | No (polled) | Yes | Traps; DES privacy (refused) |
| KNX (tunnelling, plain or IP Secure) | No (configured by group address) | Yes, from the bus | switch@1 with status read-back |
Yes (event groups) | Yes | KNX Data Secure group addresses; routing (multicast) |
| OPC UA | No (configured by NodeId) | Yes, polled or by subscription | Boolean switch@1 nodes |
Changes through a subscription | Yes | Events and alarms (A&C), methods; the gateway's certificate is supplied, not generated |
| Scriptable drivers (WebAssembly) | Through the driver, on its serial ports | Yes | Yes | Yes | Yes | Transports other than serial: a child on another transport is refused with the reason |
When a device does not come online
Open the device and look at Health: last seen, uptime, certificate expiry, refused messages and their reasons. The support playbook lists the usual fixes.
Modbus devices through the gateway
Energy meters, PLCs and other Modbus TCP devices connect through the gateway agent. Create the device from a Modbus template (for example Modbus energy meter), then add it to the gateway's configuration with its address and a register map that says where each value is:
{ "device": "dev_…", "modbus": { "address": "10.0.0.20:502", "unit": 1, "map": { "model": "acme-meter-3", "points": [
{ "capability": "meter.energy@1", "property": "watts", "kind": "holding", "address": 100, "type": "float32" },
{ "capability": "meter.energy@1", "property": "kwh", "kind": "input", "address": 10, "type": "uint32", "scale": 0.01 },
{ "capability": "switch@1", "property": "on", "kind": "coil", "address": 3, "type": "bool", "writable": true } ] } } }
Points: holding or input registers (uint16, int16, uint32, int32, float32, high word first), with an optional scale and offset, and coils (on/off).
Writing: only coils marked
writableare ever written, for switch commands, and 16-bit holding registers markedwritableunderconfiguration@1, for the device's settings. Each write is read back before the new state is reported.Settings: a point with
"capability": "configuration@1"names one setting (itsproperty, for examplectRatio); settings are reported asconfiguration@1.values, never as telemetry.configuration@1.setis checked against the template'sconfiguration.schemaon the platform and against the map on the gateway, and nothing is written unless every setting in it can be. 32-bit settings are not written yet.Failures: if the device stops answering, no reading is sent for that poll. The last known values stay shown as last known, never as new readings.
Modbus RTU (RS-485): use
serialinstead ofaddress, for meters and PLCs on a serial line. Units on the same port share it, one request at a time. Parity defaults to even (8E1, the Modbus default); set"parity": "N", "stopBits": 2for 8N2. Frames with a wrong CRC are refused, and a unit that doesn't answer within a second is ahardware_timeout.{ "device": "dev_…", "modbus": { "serial": { "path": "/dev/ttyUSB0", "baud": 9600 }, "unit": 7, "map": { "model": "eastron-sdm120", "points": [ { "capability": "meter.energy@1", "property": "watts", "kind": "input", "address": 12, "type": "float32" } ] } } }Other protocols: SNMP, KNX, OPC UA, BACnet/IP and Siemens S7 are below.
SNMP devices through the gateway
UPS units, PDUs, network switches and environmental probes that speak SNMP v2c or v3 are polled by the gateway, read only. Each point names a numeric OID, with an optional scale and offset:
{ "device": "dev_…", "snmp": { "address": "10.0.0.30:161", "community": "public", "map": { "model": "apc-smart-ups", "points": [
{ "capability": "sensor.temperature@1", "property": "celsius", "oid": "1.3.6.1.4.1.318.1.1.1.2.2.2.0" },
{ "capability": "meter.energy@1", "property": "watts", "oid": "1.3.6.1.4.1.318.1.1.1.4.2.8.0", "scale": 0.1 } ] } } }
- Read only: the gateway sends GetRequest, never Set, and refuses every command to these devices.
- Failures: an agent that doesn't answer (including a wrong community, which agents ignore) sends nothing for that poll. An OID the agent doesn't have, or one that isn't a number, is left out and logged.
- Security: v2c communities travel in clear text. Keep SNMP on the site's own network, on the gateway's side, or use v3.
- SNMP v3: put
"v3": { "user": "meryxon", "authProtocol": "SHA256" }in place of the community, and name the passwords as device secrets:"driver": { …, "secrets": ["authPassword", "privPassword"] }. Authentication is HMAC-SHA-256 (SHA256), HMAC-SHA-1 (SHA, the default) or HMAC-MD5 (MD5); with aprivPasswordthe requests and answers are encrypted with AES-128 (DES is refused). Without passwords the user is sent alone (noAuthNoPriv). The gateway discovers the agent's engine on the first poll and again when the agent reports it rebooted; an answer without a valid digest, or a clear answer to an encrypted request, is never read. A wrong password shows as the agent refused the request in the gateway log. Optional:contextName.
KNX devices through the gateway
KNX lighting, blinds and HVAC connect through the gateway agent over KNXnet/IP tunnelling to a KNX IP interface or router. Give the gateway the interface's address once, then each KNX device its group addresses, as set in ETS:
{ "knx": { "address": "192.168.1.50:3671" },
"children": [
{ "device": "dev_…", "knx": { "map": { "model": "knx-actuator", "points": [
{ "capability": "switch@1", "property": "on", "dpt": "1.001", "write": "1/0/1", "status": "1/0/2" } ] } } },
{ "device": "dev_…", "knx": { "map": { "model": "knx-room-sensor", "points": [
{ "capability": "sensor.temperature@1", "property": "celsius", "dpt": "9.001", "status": "2/0/1" } ] } } } ] }
- Datapoint types: 1.001, 1.002, 1.009 and 1.019 (on/off, open/closed), 5.001 (percent), 9.x (two-byte float such as temperature, lux, humidity), 13.x (energy in Wh) and 14.x (four-byte float such as power). Other types are refused when the gateway starts.
- State comes from the bus. The gateway listens to every group telegram and asks once for values it hasn't heard yet. Nothing is reported for a value the bus hasn't given.
- Switching: only
switch@1points with awriteaddress are written. After the write, the gateway waits up to 3 seconds for the actuator's status telegram. If it doesn't come, the command fails withhardware_timeout, never a false success. A switch with nostatusaddress can't read its state back, so its state is marked assumed. - One tunnel: KNX IP interfaces allow only a few tunnels, so all KNX devices share the gateway's one connection. The gateway keeps it alive every minute and reconnects after three missed answers.
- KNX IP Secure: for an interface with security on, add
"secure": { "userId": 2 }next to the map and name two device secrets,"secrets": ["userPassword", "deviceAuthCode"]: the tunnel user's password and the interface's device authentication code, both from the ETS project (Security tab of the interface). The gateway then connects over TCP (port 3671), agrees a session key with X25519, checks that the interface knows the device authentication code before it sends anything, signs in as the user, and seals every frame (AES-128, KNX AN159). A frame that does not authenticate, or one replayed, is dropped. The session is kept alive every 30 seconds. KNX Data Secure (end-to-end security of group telegrams on the bus) is not supported: a group address with Data Secure on stays silent. - Template: KNX switch actuator channel. For sensors, use any template with the matching capability.
OPC UA servers through the gateway
PLCs, SCADA servers and edge controllers that publish an OPC UA server connect through the gateway agent as an OPC UA client. Each point names a variable node by its NodeId, as shown in the server's address space (UaExpert shows it under Attributes):
{ "device": "dev_…", "opcua": { "endpoint": "opc.tcp://10.0.0.40:4840", "map": { "model": "line-controller", "points": [
{ "capability": "sensor.temperature@1", "property": "celsius", "node": "ns=2;s=Line1.Temperature" },
{ "capability": "meter.energy@1", "property": "kwh", "node": "ns=2;i=1001", "scale": 0.001 },
{ "capability": "switch@1", "property": "on", "node": "ns=2;s=Line1.Pump", "writable": true } ] } } }
- Values: numbers of any OPC UA numeric type, with an optional scale and offset, and booleans. All nodes are read in one request per poll. A node with a bad or uncertain status, or a value that isn't a number or a boolean (a string, an array, a structure), is left out and logged.
- Writing: only
switch@1points markedwritableare ever written, as a boolean. The gateway then reads the node back until it shows the new value; if the server's logic keeps it where it was for 3 seconds, the command fails withhardware_timeout. A node the server refuses to write is ahardware_error. - Security:
securityPolicyisNone(the default),Basic256Sha256,Aes128_Sha256_RsaOaeporAes256_Sha256_RsaPss, andsecurityModeisNone,SignorSignAndEncrypt. Anything butNoneneeds the gateway's applicationcertificateandprivateKeyfiles, and the server has to trust that certificate. Addusernameandpasswordfor a server that refuses anonymous sessions; prefer a secured channel when you do. Pin the server's certificate withserverThumbprint(its SHA-1 thumbprint, 40 hex digits, colons allowed, as UaExpert shows it): a server offering another certificate is refused before any session, so nobody on the network can pose as it. Without a pin the certificate is taken as the server offers it. - Failures: if the server goes away, no reading is sent for that poll and the client reconnects and restores its session on its own.
- Polling or subscriptions: values are polled every telemetry interval, unless the map says
"subscribe": true: then the server reports changes through a subscription (one monitored item per point, sent everypublishingIntervalMs, 1000 by default) and the gateway reports each change at once, only the points that changed. A server that refuses the subscription is polled instead; while a subscription is lost the gateway polls, until the client restores it after reconnecting.
BACnet devices through the gateway
Building management controllers (air handlers, chillers, VAV boxes, meters) that speak BACnet/IP connect through the gateway agent. Each point names an object; the gateway reads its present-value:
{ "bacnet": { "local": ":0" },
"children": [
{ "device": "dev_…", "bacnet": { "address": "10.0.0.50", "map": { "model": "ahu-controller", "points": [
{ "capability": "sensor.temperature@1", "property": "celsius", "object": "analog-input:1" },
{ "capability": "sensor.humidity@1", "property": "percent", "object": "analog-value:2" },
{ "capability": "switch@1", "property": "on", "object": "binary-output:1", "writable": true, "priority": 8 } ] } } },
{ "device": "dev_…", "bacnet": { "address": "10.0.0.51", "network": 5, "station": 9, "map": { "model": "vav-box", "points": [
{ "capability": "sensor.temperature@1", "property": "celsius", "object": "ai:0" } ] } } } ] }
- Objects: analog input, output and value (numbers, with an optional scale and offset) and binary input, output and value (true when active). Short forms
ai,ao,av,bi,boandbvwork too. An object the device doesn't have is left out and logged; a device that doesn't answer sends nothing for that poll. - Writing: only
switch@1points on a binary output markedwritableare ever written, with WriteProperty at the point'spriority(1 to 16 except 6; 8, manual operator, by default). The gateway then reads present-value back. BACnet lets a higher priority win, so if a life-safety or schedule command holds the output, the write doesn't take effect and the command fails withhardware_timeoutafter 3 seconds, never a false success. - MS/TP devices behind a BACnet router: give the router's address with the device's
networknumber and its MS/TPstationaddress. - One endpoint: all BACnet children share the gateway's one UDP socket. It uses any free port by default; set
"bacnet": { "local": ":47808" }for devices that only answer to the standard port. - Segmented answers: a long answer is taken in segments, each acknowledged, up to 16 segments; an answer missing a segment fails the read rather than returning part of it.
- Not yet: device discovery (Who-Is), ReadPropertyMultiple, change-of-value subscriptions and BACnet/SC.
Siemens S7 PLCs through the gateway
S7-300, S7-400, S7-1200 and S7-1500 PLCs connect through the gateway agent over S7comm on ISO-on-TCP, port 102. Each point is an address in Siemens notation:
{ "device": "dev_…", "s7": { "address": "10.0.0.60:102", "rack": 0, "slot": 1, "map": { "model": "s7-1200-pump", "points": [
{ "capability": "sensor.temperature@1", "property": "celsius", "address": "DB1.DBD0", "type": "float32" },
{ "capability": "meter.energy@1", "property": "kwh", "address": "DB1.DBD4", "type": "uint32", "scale": 0.01 },
{ "capability": "contact@1", "property": "open", "address": "I0.1" },
{ "capability": "switch@1", "property": "on", "address": "Q0.0", "writable": true } ] } } }
- Addresses: data blocks (
DB1.DBX0.3,DB1.DBB2,DB1.DBW4,DB1.DBD8), flags (M10.0,MW20), inputs (I0.1orE0.1,IW64) and outputs (Q0.0orA0.0,QD4). Bits are booleans; bytes areuint8orint8; wordsuint16orint16; double wordsuint32,int32orfloat32(REAL), big-endian as the PLC stores them, with an optional scale and offset. A type that doesn't fit its address is refused when the gateway starts. - Rack and slot: S7-300 is usually rack 0, slot 2; S7-1200 and S7-1500 are rack 0, slot 0 or 1.
- S7-1200 and S7-1500: allow PUT/GET access from remote partners in the CPU's protection settings, and turn off optimized block access for every data block the gateway reads.
- Reading: all points are read in as few requests as the PLC's PDU size allows. An address the PLC refuses (a missing data block, beyond its end) is left out and logged. If the PLC stops answering, nothing is sent for that poll and the gateway connects again on the next one.
- Writing: only
switch@1bit points markedwritableare ever written, one bit at a time. The gateway then reads the bit back; if the PLC program overwrites it for 3 seconds, the command fails withhardware_timeout. Writing a bit the program also drives is a design decision for the PLC programmer: prefer a flag or data block bit the program reads.
Wired M-Bus meters through the gateway
Heat, water, gas and electricity meters on a wired M-Bus segment (EN 13757-2 and -3) are read by the gateway agent, read only. The segment reaches the gateway through an M-Bus-to-IP converter (address, host:port) or a level converter on a serial port (serial.path, 2400 baud 8E1 unless baud says otherwise). Meters on one converter or port share it; each child names its meter's primary address (0 to 250):
{ "device": "dev_…", "mbus": { "address": "10.0.0.70:10001", "primary": 1, "map": { "model": "heat-meter", "serial": "12345678", "points": [
{ "capability": "meter.energy@1", "property": "kwh", "quantity": "energy" },
{ "capability": "meter.energy@1", "property": "watts", "quantity": "power" },
{ "capability": "sensor.temperature@1", "property": "celsius", "quantity": "flowTemperature" } ] } } }
- Records: a point picks a data record by
quantity(energyin kWh,volumem³,masskg,powerW,volumeFlowm³/h,flowTemperature,returnTemperatureandexternalTemperature°C,temperatureDifferenceK,pressurebar), and optionallystorage(0, the current value, by default; 1 is often the last due date),tariffandfunction(instantaneous,maximum,minimum). Units are converted (Wh, J and GJ to kWh; J/h to W), with an optional scale and offset. A record the meter doesn't send is left out; a record with a modifier the gateway doesn't apply is never reported as the plain quantity. - Serial: with
serialin the map, an answer from another meter (two meters on one primary address) is refused instead of reported as this one. - Polling: the gateway sends SND_NKE once, then REQ_UD2 each poll; a meter that doesn't answer sends nothing for that poll and shows offline. Battery meters on M-Bus count each read against their battery: keep
telemetrySat the meter's documented rate (often 15 minutes or more). - Not yet: secondary addressing (finding meters by serial), multi-telegram answers (only the first telegram is read), the second VIF extension table (0xFD: errors, dates, counters), and water volume as its own capability (no volume capability exists; a template can name a model-specific one).
Wireless M-Bus meters through the gateway (wmbusmeters)
The gateway doesn't decode wireless M-Bus (EN 13757-4) itself. wmbusmeters does, with its own radio dongle (im871a, iu891a, amb8465, a CUL stick or rtl-sdr), as a separate program next to the gateway. It is GPL-3.0: run it unmodified, in its own process; the gateway only reads the JSON it publishes on the site's MQTT.
- Set up wmbusmeters with one meter file per meter (its driver, ID and AES key, which stays in wmbusmeters' configuration, not in the platform) and a shell hook that publishes each telegram:
shell=/usr/bin/mosquitto_pub -h <gateway> -u <user> -P <password> -t wmbusmeters/$METER_NAME -m "$METER_JSON". Keepformat=jsonand the defaulttimestampfield. - A child names the meter's topic and ID, and which JSON fields are which properties:
{ "device": "dev_…", "transport": { "kind": "mqtt-local", "address": "embedded://0.0.0.0:1883" }, "driver": { "kind": "native", "ref": "wmbusmeters" },
"mapping": { "topic": "wmbusmeters/Heat", "id": "67676767", "model": "kamheat", "points": [
{ "field": "total_energy_consumption_kwh", "capability": "meter.energy@1", "property": "kwh" },
{ "field": "power_kw", "capability": "meter.energy@1", "property": "watts", "scale": 1000 },
{ "field": "flow_temperature_c", "capability": "sensor.temperature@1", "property": "celsius" } ] } }
- What it reports: numeric fields only, with an optional scale and offset; text fields (
current_status) are not read.rssi_dbmis the link quality. - Ignored: a message that is not JSON, another meter's ID on the topic, a telegram older than the last one (a replay), and one older than
staleS. - Offline: a meter that sends nothing for
staleS(one hour by default) shows offline. Meters send every 16 seconds to 15 minutes; setstaleSto a few of the meter's intervals. - Read only: every command is refused.
CANopen devices through the gateway
CANopen nodes (CiA 301: I/O modules, drives, sensors) on a CAN bus connect through the gateway agent on Linux, over SocketCAN: a CAN hat or a USB adapter shows as can0. Set the bit rate on the interface, not in the platform: ip link set can0 type can bitrate 250000 && ip link set can0 up. Nodes on one interface share it; each child names its node ID (1 to 127):
{ "device": "dev_…", "canopen": { "interface": "can0", "node": 5, "map": { "model": "can-io", "start": true, "heartbeatMs": 1000, "points": [
{ "capability": "sensor.temperature@1", "property": "celsius", "index": "0x6401", "subindex": 1, "type": "int16", "scale": 0.1, "tpdo": { "n": 1, "offset": 1 } },
{ "capability": "sensor.contact@1", "property": "open", "index": "0x6000", "subindex": 1, "type": "uint8", "bit": 0 },
{ "capability": "switch@1", "property": "on", "index": "0x6200", "subindex": 1, "type": "uint8", "bit": 2, "writable": true } ] } } }
- Points: an object dictionary entry (
indexas0x…,subindex) of typebool,uint8,int8,uint16,int16,uint32,int32orfloat32, little-endian as CANopen sends it, with an optional scale and offset;bit(0 to 7) reads one bit of auint8, such as one digital input or output of a CiA 401 module. - Reading: points are polled by SDO each poll. A node that doesn't answer sends nothing polled; an entry it refuses (an SDO abort, logged with its reason) is left out. A point with
tpdois taken from that transmit PDO (1 to 4 at the default COB-IDs,0x180+ node and so on) at a byte offset, and goes out as soon as it arrives; the node's PDO mapping is set on the node (with its own tool), not by the gateway. - Writing: only
switch@1points markedwritable(abool, or abitof auint8) are written, by SDO; a bit is read, changed and written back, so the byte's other outputs keep their state. The gateway then reads it back; a node that keeps its own value for 3 seconds fails the command withhardware_timeout. - Start and presence: with
start, the gateway sends NMT start when the node boots up or reports pre-operational, so it sends its PDOs. WithheartbeatMs(the node's heartbeat producer time, object 0x1017), a node is online while its heartbeats or PDOs keep coming; otherwise while it answers polls. Emergency messages are logged. - Not yet: segmented SDO downloads (writes of more than 4 bytes), configuring PDO mapping from the gateway, LSS (setting node IDs), SYNC production, CAN FD and 29-bit identifiers.
BACnet MS/TP and BACnet/SC through the gateway
Beside BACnet/IP (above), the gateway reaches BACnet controllers on an MS/TP line of its own and on a BACnet/SC network. The map is the same as BACnet/IP's: analog and binary objects to capability properties, writes only for switch@1 binary outputs.
MS/TP. The gateway joins the RS-485 line as a master station, on an RS-485 adapter (serial.path, 38400 baud 8N1 unless baud says otherwise) or behind a serial-to-TCP server (address). Give it a station no other master uses; every child on one line gives the same station. maxMaster (127 by default) is the highest master address it polls for; set it to the line's highest to find the next master quicker.
{ "device": "dev_…", "bacnetMstp": { "serial": { "path": "/dev/ttyUSB1" }, "station": 0, "maxMaster": 31, "mac": 5, "map": { "model": "vav", "points": [
{ "capability": "sensor.temperature@1", "property": "celsius", "object": "ai:1" },
{ "capability": "switch@1", "property": "on", "object": "bo:2", "writable": true } ] } } }
- Token: the gateway passes the token, finds the next master by Poll For Master, makes the token when the line is silent and keeps it when it is the only master (slave devices). It sends one request per token; a device that answers Reply Postponed sends the answer when it next holds the token.
- Not served: requests from devices to the gateway (it is a client), segmented answers larger than one frame (501 bytes), and a line where the gateway is not a master.
BACnet/SC. The gateway connects to the network's primary hub over TLS 1.3 WebSocket with its operational certificate. The installer puts three PEM files on the gateway: the gateway's certificate, its key and the network's CA; each child names the device's VMAC. Children on one hub share the connection; a hub restart is dialled again with a growing pause.
{ "device": "dev_…", "bacnetSc": { "hub": "wss://bms-hub.site:443/", "cert": "/etc/meryxon/bsc/cert.pem", "key": "/etc/meryxon/bsc/key.pem", "ca": "/etc/meryxon/bsc/ca.pem",
"vmac": "12:34:56:78:9A:BC", "map": { "model": "ahu", "points": [ { "capability": "sensor.temperature@1", "property": "celsius", "object": "ai:1" } ] } } }
- Not yet: a failover hub, direct connections between nodes, address resolution (the VMAC comes from the BMS tool), and certificate enrolment from the platform.
EnOcean devices through the gateway
Battery-free EnOcean switches and sensors are heard by an EnOcean transceiver on the gateway (a USB 300 or alike, ESP3 at 57600 8N1; serial.path), or the same stick behind a serial-to-TCP server (address). Devices on one transceiver share it; each child names the device's sender ID (printed on it) and its EEP:
{ "device": "dev_…", "enocean": { "serial": { "path": "/dev/ttyUSB0" }, "map": { "model": "window", "id": "0181A2B3", "eep": "D5-00-01" } } }
- EEPs:
F6-02-01rocker switch (button@1pressed;rockerAI,AO,BIorBOmakes one child per rocker),D5-00-01contact (sensor.contact@1, opened and closed events),A5-02-05temperature 0 to 40 °C,A5-04-01temperature and humidity. Teach-in telegrams and a rocker's release report nothing; other EEPs are refused when the child is built. - Offline: a sensor that sends nothing for
timeoutS(one hour by default) shows offline. A rocker sends only when pressed, so it never shows offline. - Security: plain EnOcean telegrams carry no authentication: anyone in radio range can send a sender ID's telegrams. Use EnOcean contacts for comfort, not as alarm or access inputs. Secure telegrams (EEP with encryption) are not read yet.
- Read only: every command is refused; EnOcean actuators are not driven yet.
DALI lights through the gateway
DALI control gear (LED drivers, ballasts; IEC 62386-102) is driven through a DALI interface on the gateway, one child per gear at its short address (0 to 63, set when the line was commissioned). The interface speaks the gateway's line protocol on a serial port (serial.path, 19200 baud) or TCP (address): S hhhh sends a forward frame, Q hhhh waits for the answer.
{ "device": "dev_…", "dali": { "address": "10.0.0.80:7000", "map": { "model": "led-driver", "short": 3 } } }
- State:
level@1andswitch@1are what the gear answers to QUERY ACTUAL LEVEL, on DALI's logarithmic curve (arc 85 is 1 %, 254 is 100 %; near full output a step is about 2.7 %). A lamp failure appearing or clearing is adevice.events@1raw event. A gear that doesn't answer shows offline. - Commands:
level@1set sends the arc level;switch@1on recalls the gear's maximum level and off switches it off. The gateway reads the level back once the fade is over; a command fails withhardware_timeoutonly when the gear didn't switch as asked (a gear's min or max level clamping the request is reported as where it is). - Not yet: group and broadcast addresses, commissioning (assigning short addresses), scenes, DALI-2 input devices, and vendor USB interfaces (their own protocols).
LoRaWAN, Sigfox and NB-IoT through their network
flowchart LR
dev["LoRaWAN / Sigfox / NB-IoT device"] --> ns["Network server<br/>(TTN, ChirpStack, Sigfox, NB-IoT platform)"]
ns -- "payload formatter decodes" --> hook["POST /v1/integrations/network/{id}/uplink<br/>Bearer integration token"]
hook -- "mapping: field → capability@n.property" --> ingest["Ingest: hello once, then telemetry"]
These devices never reach the broker. Their network server calls a webhook instead.
- Networks → Connect. Pick The Things Stack, ChirpStack, Sigfox or NB-IoT. You get a webhook URL and a token. The token is shown only once.
- On the network server, add a webhook to that URL with the header
Authorization: Bearer <token>. Send uplinks, and for commands also downlink ack, nack and failed messages (TTN) or ack events (ChirpStack). Add a payload formatter so the server decodes the payload.- The Things Stack v3:
uplink_message.decoded_payload. - ChirpStack v4 (HTTP integration, JSON):
object. - Sigfox: a custom JSON callback with
device,seqNumber,timeand the decoded values underdata. - NB-IoT:
deviceId(IMEI),messageId,timeanddata.
- The Things Stack v3:
- Link each device. Add the device to its site from a template, then link its network ID (DevEUI, Sigfox ID or IMEI). Say which decoded field is which reading. Only readings the template declares are offered.
Then, on each uplink:
- The first uplink sends the device's hello, and the device becomes active.
- Each uplink becomes telemetry, so alarms, calculated fields and workflows apply to it as to any device.
- A network server's retry of the same uplink is dropped as a duplicate.
- Decoded fields that you didn't map are ignored.
The webhook answers:
| Answer | Meaning |
|---|---|
| 202 | Accepted, or a duplicate of an uplink already accepted. For downlink events: ack when it settled a command, ignored for progress messages and late acks |
| 401 | Wrong or deleted token |
| 404 | No device linked to that network ID, or an ack for a downlink this integration never sent |
| 422 | Nothing was decoded, or none of the mapped fields are in the payload. The reason is in the answer, so it shows in the network server's webhook log |
Deleting the integration stops its token at once.
Commands as downlinks (The Things Stack and ChirpStack)
Sigfox and NB-IoT integrations carry uplinks only; commands to their devices are refused.
- Networks → Turn on commands. Give the network server's API address and an API key. For TTN, also the application ID and the ID of the webhook from step 2; the key needs the application's write-downlink right. For ChirpStack, use its REST API address. The key is stored sealed and never shown again.
- When linking a device, give the frame for each command its template declares: a port and a hexadecimal payload, up to 51 bytes. Commands with an on/off value get one frame per value. A command left empty is refused (
downlink_unmapped), never guessed.
Then a command goes out as a confirmed downlink, queued until the device's next uplink window:
- When the device acknowledges the frame, the command succeeds, marked assumed: the device received it but cannot report that it acted.
- A nack, a failure or a refusal from the network server fails it.
- TTN learns nothing about the command until the device has sent its first uplink.
- Deadlines: an expired command never goes out. ChirpStack drops a queued frame at the command's deadline itself. For TTN, the platform clears the device's queue once the deadline passes; a frame already on air at that moment cannot be recalled.
- Set command deadlines longer than the device's uplink interval, or every command expires before the device listens.
CoAP and LwM2M devices
flowchart LR
dev["Constrained device<br/>device certificate"] -- "CoAP over DTLS, UDP 5684" --> coap["meryxon-coap connector"]
coap -- "v1/dev/{id}/… (MQTT)" --> ingest["Ingest, as for MQTT devices"]
ingest -. "v1/dev/{id}/cmd" .-> coap
These devices use the same claim code and certificate as MQTT devices. Only the transport differs: CoAP over DTLS on UDP port 5684. The certificate's device ID is the identity.
Plain CoAP:
- Uplinks: POST the usual envelopes to
/v1/hello,/v1/reported,/v1/telemetry,/v1/event,/v1/statusor/v1/cmd/ack. The answer is 2.04. - Commands while connected: observe
/v1/cmd, and each command arrives as a notification. - Commands for sleepy devices:
GET /v1/cmdon waking returns what is waiting. An expired command is never delivered.
LwM2M 1.1 (subset):
- Register: register at
/rdwithep=<device ID>. - What the platform reads:
- The manufacturer, model and firmware from object 3.
- It then observes these objects: temperature (3303), digital input (3200), power measurement (3305), and light or power control (3311, 3312).
- Commands:
switch@1set and toggle write resource 5850 and read it back. - Online status: deregistering, or letting the lifetime run out, marks the device offline.
- Content formats: plain text, TLV, CBOR, SenML JSON and SenML CBOR.
- Firmware (object 5): create a fleet job of kind
firmware.updatefor the device. The platform checks the package's SHA-256 before sending it, and the job succeeds only when the device reports success. - PSK instead of a certificate: issue a key with
POST /v1/devices/{id}/secretsand{"kind":"coap_psk"}. It is shown once. Use the device ID as the PSK identity and the key in hex. Issuing again replaces it; revoking it disconnects the device. - Bootstrap: point the device's bootstrap server at the same address. It is given the LwM2M server account, with its current PSK or its certificate.
- Not yet supported: other objects and DTLS Connection ID.
Support limits for sleepy devices:
- One instance. The connector runs as one replica by default. Commands waiting for a sleeping device are kept in that instance's memory, at most 16 per device, for up to 24 hours.
- A restart drops the waiting commands. They are not run late: each expires at its own deadline and shows as expired, so the person can send it again. A device that connected to an instance that restarted reconnects to the new one.
- Late commands never run. A command past its deadline is acknowledged as expired and never delivered, whether the device was asleep or connected.
- More than one instance needs a shared command queue, which the connector doesn't have yet. Keep
coap.replicasat 1.
EV chargers over OCPP 1.6J and 2.0.1
flowchart LR
ch["Charger<br/>device certificate"] -- "wss://…/ocpp/{device ID}<br/>OCPP 1.6J" --> oc["meryxon-ocpp connector"]
oc -- "v1/dev/{id}/…" --> ingest["Ingest"]
ingest -. "commands" .-> oc
- Add the charger. In site setup, use the template EV charger (OCPP 1.6J). Claim it to get its certificate.
- Configure the charger:
- Central system URL:
wss://<host>:8887/ocpp/<device ID>. - Security profile: 3, with the device certificate as its client certificate. Or profile 2: issue a password with
POST /v1/devices/{id}/secretsand{"kind":"ocpp_basic"}(shown once) and use the device ID as the user name. - Charge point ID: the device ID.
- Protocol: OCPP 1.6J or 2.0.1.
- Central system URL:
What you see:
- Status: the charger's own status (available, charging, faulted…), never a guess.
- Readings: energy (kWh), power (W) and this session's kWh.
- Events: session started and stopped. A fault raises an alarm.
What you can do:
- Start charging and release the cable: both are guarded, so a person confirms each one first.
- Stop charging, on any connector.
- Restart the charger.
- Manage RFID tags: set or clear the list of authorised tags. Until a list is set, the charger's own list decides.
- Limit power: set the charger's maximum from the site's capacity, then per-connector limits below it.
A command is only "done" when the charger shows it happened (charging starts or stops, it reboots, the cable is released). Otherwise it fails at its deadline.
Not supported yet: automatic load balancing across a site's chargers, tariffs, reservations and firmware updates through OCPP.
Support limits:
- More than one instance: each connection of a charger announces an owner generation on the broker (retained,
v1/svc/ocpp/{device}/owner). Only the instance holding the newest connection delivers the charger's commands. An instance whose connection a newer one replaced closes it, so a charger that reconnects to another instance never gets one command twice. - A reconnect during a session: the session keeps running on the charger. Its stop, meter values and status arrive on the new connection. A command in progress on the old connection doesn't succeed until the charger shows its effect, or it fails at its deadline.
- Tested against: the OCPP 1.6J and 2.0.1 messages in the connector's own test fixtures, not yet against a named charger model. Chargers stay untested until one is field-validated.