Meryxon docs

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.

  1. In site setup, each device gets a claim code.
  2. 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.
  3. The device receives its certificate and connects to the broker over TLS (port 8883), using that certificate.
  4. It publishes hello, then reports state and telemetry. It receives commands on v1/dev/{id}/cmd and answers on cmd/ack.

Topics and message format: contracts/asyncapi.yaml.

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.

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 }] } }
] }

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.

{ "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"] } }

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.

{ "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" } } }

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.

{ "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" } } }
{ "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" } } }

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.

{ "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" }] } }

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.

{ "device": "dev_…", "transport": { "kind": "mqtt-local", "address": "embedded://0.0.0.0:1883" }, "driver": { "kind": "native", "ref": "zigbee2mqtt" },
  "mapping": { "ieee": "0x00158d0001a2b3c4", "baseTopic": "zigbee2mqtt" } }

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.

{ "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" }] } }

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.

{ "device": "dev_…", "transport": { "kind": "matter", "address": "ws://127.0.0.1:5580/ws" }, "driver": { "kind": "native", "ref": "matter" }, "mapping": { "node": 11, "endpoint": 1 } }

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.

{ "device": "dev_…", "transport": { "kind": "ble", "address": "A4:C1:38:12:34:56" }, "driver": { "kind": "native", "ref": "bthome" }, "mapping": { "timeoutS": 600 } }

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.

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.

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 } ] } } }

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 } ] } } }

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" } ] } } } ] }

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 } ] } } }

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" } ] } } } ] }

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 } ] } } }

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" } ] } } }

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.

{ "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" } ] } }

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 } ] } } }

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 } ] } } }

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" } ] } } }

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" } } }

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 } } }

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.

  1. 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.
  2. 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, time and the decoded values under data.
    • NB-IoT: deviceId (IMEI), messageId, time and data.
  3. 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 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.

Sigfox and NB-IoT integrations carry uplinks only; commands to their devices are refused.

  1. 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.
  2. 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:

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:

LwM2M 1.1 (subset):

Support limits for sleepy devices:

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
  1. Add the charger. In site setup, use the template EV charger (OCPP 1.6J). Claim it to get its certificate.
  2. 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}/secrets and {"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.

What you see:

What you can do:

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: