Multi-Bus Gateway

Open-source protocol gateway

One gateway for Modbus, MQTT and OPC UA.

Read meters, inverters, batteries and heat pumps over Modbus, HTTP or MQTT, or listen without transmitting on CAN. Route their data to SCADA, Home Assistant and InfluxDB, or serve it as a virtual Modbus meter.

Keep your equipment. Run one Docker container, from Raspberry Pi to server.

  • AGPL-3.0 open source
  • Docker · amd64 + arm64
  • ≈130 MB RAM · reference setup
  • Raspberry Pi to server
  • English · Română

Explore protocols and supported devices →

Gateway in daily use since July 2026. It grew out of a Janitza monitor running since March 2026. At the grid connection, a Janitza UMG 512-PRO supplies virtual meters for Victron GX and Fronius. The installation also connects four Fronius inverters with power-limit rules, a Seplos battery bank in listen-only mode and a Samsung heat pump over remote RS-485.

How it works

Every device is described by a template. The gateway polls it, names every value the same way on every device, checks it, and routes it — each device with its own outputs.

Reads

  • Modbus TCP
  • Modbus RTU RS-485, local or over the network
  • Modbus ASCII · UDP
  • RTU listen-only tap
  • CAN listen-only, SocketCAN
  • Seplos V2 BMS protocol, read-only
  • HTTP / JSON Fronius Solar API, Shelly, Tasmota…
  • MQTT Zigbee2MQTT, ESPHome, BLE…
Multi-Bus Gateway
  • Device templates · 31 bundled
  • Canonical names and units
  • Calculated values
  • Freshness and quality on every value
  • Protective edge rules, commands, sequences
  • Gated writes with dead-man leases

Serves

  • MQTT + Home Assistant discovery, and control: commands come back the same way
  • InfluxDB store-and-forward, Grafana
  • OPC UA server for SCADA and HMI
  • Virtual Modbus meters EM24, Fronius SM, SunSpec
  • REST push · JSON
  • Prometheus metrics and alerts
  • Alerts (Pro) Telegram, SMS, e-mail, push
Explore the architecture and control layers

Where it sits

The gateway moves data and executes writes safely. Deciding what the plant should do — optimisation and policy — belongs to the layer above it. The gateway keeps a small edge layer of strict protective rules: the ones that must keep working when the layer above is down.

  1. Supervisor

    Node-RED · Home Assistant · an EMS · SCADA

    Optimisation, tariffs, forecasts, the battery strategy. Your choice, and replaceable.

  2. Multi-Bus Gateway

    acquisition · normalisation · outputs · safe writes · edge protection

    Reads and names every value, and serves it to MQTT, Home Assistant, InfluxDB, OPC UA and REST. Every write is guarded: write-locked by default, one command lane per wire, leases that revert, limits from the template, an audit of every write. Protective rules stay at the edge: over-voltage derating, an export cap at the connection point.

  3. Devices

    meters · inverters · BMS · Victron GX · drives…

    The equipment you already have, on the buses it already uses.

  • Priority 0: the gateway's protective rules. Strict, at the edge. Placed in the safety layer, nothing from outside can pause them.
  • Priority 1: the supervisor. On a setting no rule drives, it has full control, through the same safe writes.
  • Both on one setting. The rules set the envelope and the supervisor optimises inside it. A direct command on a setting a protective rule holds is refused, with the rule's name. The supervisor's own value, as a force on a rule of its own, meets the referee: on a channel combined by minimum, such as the inverters' power limit, it asks for 100 %, over-voltage holds 70 %, and 70 % is written.

What it does today

Everything below ships in the open-source gateway.

Acquisition

Read Modbus TCP, RTU, ASCII and UDP, with batched reads, retries and shared serial buses. Configure polling from 50 ms to 24 h without restarting. The Seplos V2 BMS protocol is also supported, read-only.

Device templates

Portable register maps, with a browser editor, CSV/YAML import and scan recognition. Bundled templates cover meters, inverters, batteries and drives; each records its source and how far it has been verified.

Virtual meters

Serve one source or combine several as a Carlo Gavazzi EM24, Fronius Smart Meter or SunSpec meter. Missing data is never silently served as zero: choose failure, a sentinel value or holding the last value for a bounded time. An optional quality block exposes status on the same Modbus connection.

OPC UA server

Expose devices to SCADA and HMI with stable node IDs, data quality and read timestamps. Encrypted access uses accounts or service tokens; setpoints and methods follow the same safeguards as every other command. For FUXA, UaExpert, Ignition or a Weintek panel.

MQTT, Home Assistant, InfluxDB

Publish to MQTT with per-device QoS, retain and TLS settings. Home Assistant discovers devices and exposes writable registers as number and select entities. InfluxDB uses a disk-backed buffer during outages and periodically refreshes unchanged values.

Safe commands and writes

Writes start locked. Template limits, read-back checks and equipment protections apply to commands from rules, API, MQTT and OPC UA. With a lease and safe value configured, expiry requests a return to that value; failed reversions are retried and logged. Every write is audited.

Protection stays in the gateway

Listen-only RTU and CAN read an existing bus without application writes. Safety-layer rules constrain commands from other writers; new rules start in shadow, without writes, until armed. The gateway can run local schedules; site-wide optimisation belongs to your supervisor — Node-RED, Home Assistant, an EMS or SCADA.

Examples from the template catalog

Janitza UMG 512-PRO, Carlo Gavazzi EM24, Eastron, ABB, Schneider iEM3000, Fronius SunSpec / Solar API / Smart Meter, Huawei SUN2000 with its meter and LUNA2000 battery, Victron GX, Seplos V2 and V3 (V3 via RTU tap or MQTT), Pylontech-protocol CAN, Delta VFD-EL, Samsung through the MIM-B19N / MIM-B19NT interface, Zigbee2MQTT and Tasmota. A single-phase Deye hybrid template is read-only. Check the catalog for the specific model, available writes and verification notes.

Check device compatibility →
Explore all technical capabilities

Command delivery on shared buses

Writes share one queue per wire, so a slow device delays only its own bus. A newer value for the same setting replaces a pending one; commands that are too old are dropped before they reach the equipment.

RS-485 over the network

Bridges on the Devices page: our serial bridge on a Raspberry Pi, a transparent converter (Waveshare, USR, Elfin) or a Modbus TCP gateway. Scan a bus, see how busy it is, move a device between bridges.

Listen without transmitting

The RTU tap decodes a bus that already has a master — a BMS master pack, a vendor datalogger — without ever sending a byte. Requests and responses paired, writes watched. CAN too, listen-only: the interface's own listen-only flag is checked and shown, and frames are decoded from the template — first map, the Pylontech BMS → inverter link. A bus a device listens on is never transmitted on: tests and scans there are refused. CAN hardware listen-only mode must be configured on the host; the gateway reports its state.

Add a device, checked first

Choose the model, then the connection, asked in order: port, where the bus is, Master or Listen-only, protocol, line, address. On a bus with other devices the line is the bus's and the next free address is offered; serial ports are picked from a list that says which are free. Check reads what the device would publish before anything is saved — reads only. Many units on one bus: scan for them, or listen for the addresses a master polls, and create them in one batch.

One menu, one Edit, an Undo

Every action on a device sits in one ⋯ menu; one that does not apply now says why instead of disappearing. One Edit dialog with one Save: it lists the changes before → after, asks for a review when a change matters on the bus, and never overwrites an edit made elsewhere in the meantime. A delete ends with Undo, for 10 seconds; deleted devices come back through Restore, which says beforehand what cannot come back as it was.

Edge rules and sequences

Protection and simple automations at the edge: the ones that must keep working when the layer above is down. They come first and bound what a supervisor may do; optimisation belongs to the supervisor. Steps, conditions with hysteresis, trim (follow a signal into a band), schedules. Timers, minimum run and stop, starts per hour, counters. Several writers on one target meet a referee with layers. Sequences across devices with undo. New rules run in shadow first: they decide, and write nothing until you arm them. Every decision goes to InfluxDB and MQTT, ready to chart. On our plant, over-voltage protection on four inverters runs armed.

One installation, several sources

An installation gathers units read several ways — Solar API and SunSpec, Modbus and MQTT — with a precedence per field, failover when a source stops answering, and group totals.

Calculated values

A safe expression engine with previous values, rates, time of day and cross-device references. Results flow to every output like measured values.

Commissioning tools

Discovery wizard (network scan, unit IDs, SunSpec walk, MQTT browse, Fronius, ESPHome). Frame-level bus monitor, the register probe for byte and word order, payload samples.

Configuration you can trust

A snapshot on every change, diff and rollback, a last-known-good boot, backups with secrets stripped by default, deleted devices restorable.

Security

Login with admin, operator and viewer roles, passkeys, service tokens, an audit trail, an IP allowlist, HTTPS and reverse-proxy support. Trusted-LAN by default, hardened when you need it.

Observability

Prometheus metrics, a status page with error causes, a persisted event log, infrastructure alerts over MQTT and webhooks, and a power-quality event recorder for Janitza meters.

A look inside

Three inverters and the site behind one datalogger: what it produces now, every unit's health, how it is read and where it publishes.

Examples from real installations

A Victron GX that needs an EM24

One meter at the grid connection measures everything. The gateway serves it again as the Carlo Gavazzi EM24 the Victron ESS expects. If the source goes stale the virtual meter goes silent, so the GX's own fail-safe takes over instead of acting on a frozen value.

Over-voltage: cut the inverters in steps

The real rules on the plant: one per inverter, each watching its own three phase voltages and asking for less power in four steps, down to 50 %, holding until the voltage is back under 248 V. Armed since 20 October 2026, after weeks in shadow next to the Node-RED controller they replaced, matching its steps within seconds on real over-voltage days.

See the rule
- id: ov-u1                         # one per inverter: ov-u1 … ov-u4
  target: { device: pv-u1, command: power_limit }
  mode: armed                       # weeks in shadow first, compared with the old controller
  layer: safety                     # recommended: a protection, an outside command cannot pause it
  kind: steps
  signal: "max(pv-u1.voltage_l1_n, pv-u1.voltage_l2_n, pv-u1.voltage_l3_n)"
  signal_valid: { min: 100, max: 350, max_step: 10 }   # night zeros, glitches
  steps:
    - { at: 250.0, value: 80, label: Warning }
    - { at: 251.0, value: 70, label: Moderate }
    - { at: 252.5, value: 60, label: Severe }
    - { at: 253.0, value: 50, label: Emergency, fast: true }
  release_below: 248.0
  normal: { value: 100 }
  params: { revert_s: 0, ramp_s: 10 }
  timing: { every_s: 2, debounce: 3, min_interval_s: 30, reassert_s: 120 }
  stale_after_s: 90
  on_stale: hold                    # at night the voltages read 0: keep, never curtail a sleeping inverter
  on_disable: safe                  # disarmed: back to 100 %

SCADA over OPC UA

The open-source FUXA SCADA is provisioned from the gateway in one command, and a check compares every tag with the gateway: 1199 of 1199 match, also after the gateway restarts.

More examples from the installation

A battery bank, heard and never disturbed

The bus already has a master. The gateway only listens, pairs each request with its response and publishes every pack — without a single frame of its own on the wire.

A heat pump in another building

The RS-485 bus is far from the server. A small bridge next to it carries the bus over the LAN; the gateway sets its baud and parity, and the devices follow the bridge if it moves to another address.

Control from Node-RED or Home Assistant, over MQTT

Every command a template declares listens on its own topic. A value sent to fronius-u1/cmd/power_limit meets the same gates as a click in the gateway: writes allowed, MQTT writes allowed, a broker with a login, the template's bounds, the equipment's protection. The answer comes back with the value before and after and how long it took; a request outside the bounds is refused, with the reason. In Home Assistant the registers behind the commands appear as number and select entities, executed through the same command.

Editions

The gateway is open source. The Pro edition adds the modules a critical installation needs, and the people who stand behind it.

Community

Free · AGPL-3.0

  • Everything on this page under “What it does today”
  • Every protocol, output, template and rule
  • Docker images for amd64 and arm64
  • Documentation, manual in English and Romanian
  • Issues and discussions on GitHub
Get it on GitHub

Pro

Price on request

Everything in Community, plus:

  • High availability — active and standby gateways with a shared client address. Currently in testing.
  • Alerts and notifications — rules on any value, Telegram, SMS through an LTE router, e-mail, push and webhooks; throttling, quiet hours, acknowledgement and an audit trail.
  • ESP nodes — flash and manage ESP32/ESP8266 boards from the browser, behind the gateway's login.
  • MCP server for AI assistants coming soon — let an assistant such as Claude read the plant's live values and history, and propose changes as a dry run you approve.
  • Support — a direct line to the people who build it, with agreed response times.
  • Implementation — site assessment, device templates, commissioning, protective rules, SCADA integration and documentation for your installation.
Ask for an offer

Run it on your own hardware

Docker with Compose v2. The stack brings the gateway, an MQTT broker, InfluxDB and Grafana; use only the gateway if you have your own.

mkdir multi-bus-gateway && cd multi-bus-gateway
curl -fsSLO https://raw.githubusercontent.com/sm26449/multi-bus-gateway/main/docker-compose.yml
curl -fsSL  https://raw.githubusercontent.com/sm26449/multi-bus-gateway/main/.env.example -o .env
mkdir -p mosquitto/config && curl -fsSL https://raw.githubusercontent.com/sm26449/multi-bus-gateway/main/mosquitto/config/mosquitto.conf -o mosquitto/config/mosquitto.conf
# edit .env: set the four required secrets
docker compose pull && docker compose up -d
docker compose logs multi-bus-gateway | grep -A3 'FIRST RUN'   # the admin password, once
# → http://localhost:8080

Explore the use cases

Recipes for problems we hear about. Every one uses what the gateway already has — devices, rules, MQTT, outputs — and every number in them is yours to change.

Browse practical integration recipes

The supervisor plans, the gateway executes safely Logic-tested · not run on a plant

A pool pump on a Delta VFD-EL drive. The supervisor — Node-RED, Home Assistant or an EMS — decides the speed and sends 35 Hz every minute, under a 120 s lease. If it stops sending, the lease expires and the gateway writes 0 Hz by itself. At night a pool-quiet rule in the safety layer holds 0 Hz, and an outside command is refused with the rule's name. The drive's minimum stop time holds for every writer: the supervisor, the rules, a click in the gateway.

Who owns what. This is priority 0 and priority 1 on one setting. Priority 0, the gateway: the night stop, the lease that reverts and the drive's protection. Priority 1, the supervisor: the speed, whenever no protection has an opinion. Never two writers at once: at night the rule writes, in the day the supervisor does.

Note. An armed rule owns its channel even while it has no opinion, so the supervisor sends override_s with its command. That pauses the channel's rules for that long, except the safety ones; without it the command is refused.

In the test. The gateway's own API, a simulated drive: 35 Hz refused without override_s, accepted with it; no renewal for 120 s, and the lease wrote 0 Hz; a restart right after, refused by the minimum stop time; at 23:05, refused with pool-quiet's name.

See the rule
# config.yaml: the drive's command, with a lease that reverts
devices:
  - id: vfd1
    template: delta_vfd_el
    commands:
      - { name: run_at, faces: { api: true, mqtt: true, ha: false }, lease_s: 120, safe: { value: 0 } }

# rules.yaml: priority 0, the protection stays in the gateway
rules:
  - id: pool-quiet
    target: { device: vfd1, command: run_at }
    kind: condition
    layer: safety               # a protection: an outside command cannot pause it
    when: 'between("22:00", "07:00")'
    then: { params: { value: 0 } }
    else: null                  # in the day: no opinion, the supervisor sets the speed
    timing: { every_s: 10, debounce: 1, min_interval_s: 0, reassert_s: 120 }

# priority 1, the supervisor, every 60 s:
#   …/vfd1/cmd/run_at  {"value": 35, "override_s": 300}
# no renewal for 120 s: the lease writes the safe value, 0 Hz

Export limiting with a configurable cap

The grid connection allows 45 kW of export. A trim rule watches the headroom and adjusts the inverters' power limit. The cap can also arrive over MQTT from a grid operator or supervisor. On a real four-inverter plant, a seven-minute test with a 20 kW cap and export varying from 10 to 46 kW under clouds recorded an 18 kW mean and a 21.2 kW maximum; all 33 commands were answered. The cap is a control target: short overshoots are possible.

See the rules
# 1 · keep the export under 45 kW
- id: export-cap
  target: { endpoint: pv, group: inverters, command: power_limit }
  kind: trim
  layer: safety     # a protection: a supervisor's command cannot pause it
  # the room left under the cap, in W (export reads negative on this meter):
  #   exporting 40 kW → 45000 − 40000 =  5000 W of room
  #   exporting 47 kW → 45000 − 47000 = −2000 W: over the cap
  signal: "45000 + umg512.power_active_total"
  signal_unit: W under the cap
  below: 0          # over 45 kW: lower the inverters' limit
  above: 3000       # under 42 kW: raise it back (a 3 kW margin, so it does not hunt)
  step: 10          # % per adjustment, at most
  gain: 0.002       # % per W past the threshold: 5 kW over → 10 %
  min: 0
  max: 100
  params: { revert_s: 300 }   # the inverter's own timer: back to 100 % if the gateway stops…
  timing: { every_s: 5, debounce: 2, min_interval_s: 15, reassert_s: 120 }   # …refreshed every 2 min
  stale_after_s: 30
  on_stale: hold    # meter lost: keep the last limit
  on_disable: safe  # disarmed: back to 100 %
  # four inverters on one Fronius datamanager: ~5 s a write, so 15 s between
  # adjustments keeps it under the ~26 writes a minute it can take

# the cap from MQTT instead of fixed — an MQTT device `site` with
# export_cap_kw on site/limits/export (the grid operator, an EMS, Node-RED):
#   signal: "site.export_cap_kw * 1000 + umg512.power_active_total"

# 2 · with the over-voltage rule on the same inverters: the template's
#   channel "power" combines with min — the lower limit is the one written

Never waste a kWh: the batteries before the cap Recipe · not run on our plant

The ESS's own grid-point loop does the fast part. Set its grid setpoint to export at most the cap minus a margin — 44 kW for a 45 kW cap — and the battery absorbs whatever would go over. When the battery is full, or already charging at its maximum, the export rises, and the gateway's export-cap rule trims the inverters at 45 kW. The two thresholds give the order. Set it only while production nears the cap: an ESS holding an export setpoint also discharges the battery to reach it.

Who owns the battery setpoint. Best, the supervisor — Node-RED or an EMS — through the Victron GX template's ess_setpoint command, under a lease, with the export cap kept in the gateway as the backstop. With no supervisor, a gateway rule can own it. Never both: one writer per setting.

Why not on our plant. There the battery is already commanded by another control layer: Node-RED today, an EMS next. The export cap is tested; this recipe is not.

Surplus into the battery first Recipe · not run on our plant

Under 95 % SOC the ESS holds a grid setpoint of 0 W: self-consumption, the battery takes the whole surplus and nothing is exported. Once the battery is at 95 % and the surplus — what charges the battery plus what is exported — tops 46 kW, a rule sets an export setpoint of 44 kW under the 45 kW cap. The battery then takes only what goes over 44 kW and keeps its last room for the peaks; the export cap trims the inverters at 45 kW. Back to 0 W under 90 % or under 44 kW of surplus: an ESS holding an export setpoint discharges the battery to reach it, so the setpoint stands only while the sun covers it.

Who owns the setpoint. Best, the supervisor, which knows the forecast, through the Victron GX template's ess_setpoint command. With no supervisor, this rule. Never both: one writer per setting.

See the rule
- id: battery-first
  target: { device: victron-gx, command: ess_setpoint }
  kind: condition
  layer: optimize
  # surplus = what charges the battery + what is exported, in W
  #   (battery_power: + charging; power_grid: + import)
  when: "victron-gx.soc >= 95 and victron-gx.battery_power - victron-gx.power_grid > 46000"
  release: "victron-gx.soc < 90 or victron-gx.battery_power - victron-gx.power_grid < 44000"
  then: { params: { value: -44000 } }   # export 44 kW; the battery takes what is over it
  else: { params: { value: 0 } }        # self-consumption: the battery takes it all
  timing: { every_s: 10, debounce: 3, min_interval_s: 60 }   # a setting in the GX's flash
  stale_after_s: 60
  on_stale: 0          # GX values lost: back to self-consumption
  on_disable: safe     # the GX binding's safe value: { value: 0 }

Negative prices: keep it home Recipe · not run on our plant

While the price is at or under zero, every exported kWh costs money and every stored one is free. A rule holds the ESS grid setpoint at 0 W, so the surplus goes into the battery. Once the battery is full the export rises, and a second rule trims the inverters until it is near zero, letting them back up as soon as the battery or the loads take more. The price arrives over MQTT, from the supervisor or a price feed. No price: the setpoint stays at 0 W and the inverters go back to full power under the 45 kW cap. Without a battery, see negative electricity prices below.

Who owns it. The supervisor, when it plans against tomorrow's prices. With no supervisor, these rules. The trim shares the inverters' power limit with the export cap, and the lower limit is the one written.

See the rules
# 1 · price at or under 0: setpoint 0, the surplus charges the battery
- id: price-keep-home
  target: { device: victron-gx, command: ess_setpoint }
  kind: condition
  layer: schedule      # above battery-first (optimize) on the same setpoint
  when: "market.price_eur_mwh <= 0"     # an MQTT device: the supervisor or a price feed
  then: { params: { value: 0 } }
  else: null           # a price above 0: no opinion
  timing: { every_s: 30, debounce: 1, min_interval_s: 60 }
  stale_after_s: 3600

# 2 · battery full: trim the inverters to (nearly) zero export
- id: price-zero-export
  target: { endpoint: pv, group: inverters, command: power_limit }
  kind: trim
  layer: optimize
  # the grid power while the price is at or under 0 (export reads negative), else 0
  signal: "umg512.power_active_total if market.price_eur_mwh <= 0 else 0"
  signal_unit: W at the grid
  below: -1000      # exporting over 1 kW: lower the limit
  above: -200       # under 200 W (the battery or the loads take more): raise it
  step: 10
  gain: 0.005       # % per W past the threshold: 2 kW → 10 %
  min: 0
  max: 100
  params: { revert_s: 300 }
  timing: { every_s: 5, debounce: 1, min_interval_s: 15, reassert_s: 120 }
  stale_after_s: 3600
  on_stale: 100     # no price: full power, the 45 kW cap decides

Cold battery, gentle charge Recipe · not run on our plant

Lithium cells must not be charged hard while they are cold. The BMS reports its coldest cell to the Victron GX, and the gateway reads it from the GX's battery component. Under 5 °C a rule lowers the system's maximum charge current to 20 A; over 10 °C it gives back the site's usual limit. The gap between the two keeps it from switching back and forth. No temperature: it stays at 20 A. The BMS's own limits still hold; this one comes on top, earlier and gentler.

Who owns it. The gateway: it is a protection, in the safety layer, so a supervisor's command cannot lift it. The supervisor leaves this setting alone and plans with the others, such as the charge power.

See the rule
- id: cold-charge
  target: { device: victron-gx, command: max_charge_current }
  kind: condition
  layer: safety        # a protection: no outside command lifts it
  when: "victron-gx-battery-512.min_cell_temp < 5"      # the coldest cell, from the BMS
  release: "victron-gx-battery-512.min_cell_temp > 10"
  then: { params: { value: 20 } }      # A, for the whole system (DVCC on)
  else: { params: { value: -1 } }      # the site's usual limit (-1: none)
  timing: { every_s: 30, debounce: 3, min_interval_s: 60 }
  stale_after_s: 300
  on_stale: 20         # no temperature: stay gentle

A pump that uses exactly the solar surplus

The rule nudges the drive's frequency up while power is exported and down while it is imported, between 10:00 and 16:00. A second rule tops up the day: if the sun gave the pump less than four hours, it runs from 17:00 until it has. The drive's own protection holds every writer: a minimum stop of 5 s and at most 30 starts an hour.

See the rules
# 1 · follow the solar surplus, 10:00–16:00
- id: vfd-surplus
  target: { device: vfd1, command: run_at }   # Delta VFD-EL: 0 Hz = stop
  kind: trim
  layer: optimize
  signal: '-site-meter.power_active_total if between("10:00", "16:00") else 0'
  above: 500        # exporting more than 500 W: faster
  below: 100        # under 100 W (or importing): slower
  step: 2           # Hz per adjustment
  min: 15
  max: 50
  start: 15
  off_value: 0
  timing: { every_s: 5, debounce: 2, min_interval_s: 10, reassert_s: 0 }
  stale_after_s: 60
  on_stale: safe    # meter lost: stop

# 2 · top up the day if the sun did not do it
- id: vfd-quota
  target: { device: vfd1, command: run_at }
  kind: condition
  layer: schedule   # above optimize: wins while it has an opinion
  # the hours of both rules count: it stops once the day has had four
  when: 'between("17:00", "20:00") and run_today_h("vfd-surplus") + run_today_h("vfd-quota") < 4'
  then: { params: { value: 30 } }
  else: null        # otherwise: no opinion

# the drive's protection comes from its template (channel "motor"):
# min stop 5 s, at most 30 starts an hour — for every writer

The hot-water tank stores the solar surplus as heat Logic-tested · not run on a plant

A Samsung heat pump heats the domestic hot water. Once the plant has exported more than 2.5 kW for ten minutes in a row, a rule raises the tank's set point from 48 to 60 °C: the sun pays for the extra heat. Once it has imported more than 300 W for ten minutes, the set point goes back to 48 °C. The ten minutes (for_s), at most one change every half hour (min_interval_s) and the band between the two thresholds keep it from flapping: a passing cloud changes nothing. No meter data: 48 °C.

Who owns it. It is optimisation, not protection, so it sits in the optimize layer. Best, the supervisor owns dhw_set at priority 1, and then this rule is not armed. With no supervisor, this rule. Never both: one writer per setting.

In the test. 60 °C at 700 s, ten minutes after the export settled; a short dip earlier started the count again, and 150 W of import changed nothing. Back to 48 °C at 2500 s, after ten minutes of import and the half-hour pace.

See the rule
- id: hp-dhw-solar
  target: { device: samsung-dvm, command: dhw_set }
  kind: condition
  layer: optimize
  when: "grid.power_active_total < -2500"    # exporting over 2.5 kW (export reads negative)
  release: "grid.power_active_total > 300"    # importing over 300 W
  then: { params: { value: 60 } }             # °C: the sun pays for the extra heat
  else: { params: { value: 48 } }             # °C: the everyday set point
  timing: { every_s: 10, debounce: 3, for_s: 600, min_interval_s: 1800, reassert_s: 3600 }
  stale_after_s: 120
  on_stale: 48                                # no meter data: the everyday set point

After an outage: shed at once, bring the loads back one at a time Logic-tested · not run on a plant

When the grid goes, the ESS carries the house on the battery, and the heat pump must not run on it. A safety rule switches the heat pump off as soon as a phase falls under 180 V, or when the grid meter falls silent: a meter powered by the grid dies with it, so the rule fails closed. When the grid is back, a sequence restarts the loads in order: it waits for the voltage to hold for two minutes, starts the heat pump, waits out its inrush, checks that the import leaves room, starts the pool pump and checks that it really draws. If a step fails, it runs its undo steps: here, the pool pump back to 0 Hz.

What starts the sequence. Not a rule: a rule cannot start a sequence. The supervisor or an HMI starts it over MQTT when the grid is back, or the operator does from the Rules page.

Who owns what. Priority 0, the gateway: the shed rule, in the safety layer, which nothing from outside pauses. Priority 1, the supervisor: when to bring the loads back. The sequence's commands meet every gate of a command, and a safety rule that holds a device stops it at that step.

In the test. The meter silent: the heat pump off 16 s after its last reading; 150 V: off at the second reading. The sequence ran through; with a pump that drew nothing it stopped the pump again; with no grid after 120 s it aborted.

See the rule and the sequence
# rules.yaml · priority 0: shed at once
- id: outage-shed-hp
  target: { device: samsung-dvm, command: power }
  kind: condition
  layer: safety
  when: "min(grid.voltage_l1_n, grid.voltage_l2_n, grid.voltage_l3_n) < 180"
  then: { params: { value: 0 } }
  else: null                    # grid back: no opinion
  timing: { every_s: 2, debounce: 2, min_interval_s: 0, reassert_s: 60 }
  stale_after_s: 15
  on_stale: 0                   # the meter dies with the grid: shed while blind
# sequences.yaml · started on mbg/sequences/restart-after-outage/run
id: restart-after-outage
max_duration_s: 1800
steps:
  - wait_until: 'min(grid.voltage_l1_n, grid.voltage_l2_n, grid.voltage_l3_n) > 207'
    timeout_s: 120
  - wait_s: 120                                # the grid has to stay
  - check: 'min(grid.voltage_l1_n, grid.voltage_l2_n, grid.voltage_l3_n) > 207'
  - command: { device: samsung-dvm, name: power, params: { value: 1 } }
  - wait_s: 180                                # the compressor's inrush
  - check: 'grid.power_active_total < 30000'   # room left under a 40 kW contract
  - command: { device: vfd1, name: run_at, params: { value: 30 } }
  - wait_s: 15
  - check: 'vfd1.output_current > 0.5'         # the pump really draws
on_abort:
  - command: { device: vfd1, name: run_at, params: { value: 0 } }

Frost protection over the quiet hours Logic-tested · not run on a plant

At night pool-quiet holds the pool pump at 0 Hz. Below 2 °C outside, a second safety rule runs it at 20 Hz anyway: slow, enough to keep the water moving in the pipes. Its priority, 95, is above the quiet hours' 90, so it wins the channel. Above 4 °C it has no opinion again, and the quiet hours take the channel back. The temperature comes from a Zigbee sensor over MQTT (zigbee2mqtt), added as an MQTT device outdoor; if it falls silent, the rule keeps what it was doing.

Who owns it. Priority 0, the gateway: two protections on one setting, ordered by their priority inside the safety layer. Nothing from outside pauses either. The supervisor sets the speed whenever neither has an opinion.

In the test, at 02:00. 0 Hz until three readings under 2 °C, then 20 Hz; back to 0 Hz after three readings over 4 °C.

See the rule
# pool-quiet (above): safety, 0 Hz from 22:00 to 07:00, priority 90
- id: pool-frost
  target: { device: vfd1, command: run_at }
  kind: condition
  layer: safety
  priority: 95                      # above the quiet hours (90)
  when: "outdoor.temperature < 2"   # an MQTT device: a Zigbee sensor via zigbee2mqtt
  release: "outdoor.temperature > 4"
  then: { params: { value: 20 } }   # Hz: slow, keeps the water moving
  else: null                        # warmer: no opinion
  timing: { every_s: 30, debounce: 3, min_interval_s: 0, reassert_s: 300 }
  stale_after_s: 900                # the sensor reports every few minutes
  on_stale: hold

Peak demand: the compressor in steps, not on/off Logic-tested · not run on a plant

The connection is contracted for 40 kW of import. Instead of switching the heat pump off, a rule limits its compressor by how far the import is from the contract: 80 % from 4 kW under it, 60 % from 2 kW under, and 50 % the moment it goes over, without waiting. Under 32 kW, 8 kW below the contract, it takes the limit off. The contract is read from the grid meter's attributes, so one number serves every rule. No meter data: no limit, and the unit protects itself.

Who owns it. Priority 0, the gateway: the contracted import is a hard limit, so the rule sits in the safety layer. The supervisor plans the comfort with the heat pump's other settings; compressor_limit is the rule's.

In the test. 80 % at 36.8 kW, 50 % at once at 41 kW, the limit off again at 31 kW.

See the rule
- id: hp-peak
  target: { device: samsung-dvm, command: compressor_limit }
  kind: steps
  layer: safety
  # kW over the contract (the grid meter's attribute grid_connection.max_import_kw)
  signal: 'grid.power_active_total / 1000 - attr("grid", "grid_connection", "max_import_kw")'
  signal_valid: { min: -500, max: 500, max_step: 60 }
  steps:
    - { at: -4, value: 80, label: Near the limit }
    - { at: -2, value: 60, label: At the limit }
    - { at: 0,  value: 50, label: Over the limit, fast: true }   # no debounce, no wait
  release_below: -8
  normal: { value: 0 }    # 0 = no limit; say it: with null the last limit stays
  timing: { every_s: 5, debounce: 3, min_interval_s: 30, reassert_s: 0 }
  stale_after_s: 60
  on_stale: 0             # no meter data: no limit, the unit protects itself

Negative electricity prices: stop paying to export

When the day-ahead price drops below zero, every exported kWh costs money. Read the price from your supplier's or the exchange's API as an HTTP/JSON device (or from an EMS over MQTT) and curtail the inverters while it is negative. No price, or a stale one: full power, so a broken API never stops production. This is the simple, fail-safe version at the edge; planning against tomorrow's prices belongs to the supervisor. With a battery, fill it first: keep it home.

HTTP/JSON input · condition rule · inverter group · fail-safe on stale data

See the rule
- id: negative-price
  target: { endpoint: pv, group: inverters, command: power_limit }
  kind: condition
  when: "market.price_eur_mwh < 0"     # an HTTP/JSON or MQTT device
  then: { params: { value: 0 } }
  else: { params: { value: 100 } }
  timing: { every_s: 30, debounce: 2, min_interval_s: 300 }
  stale_after_s: 3600
  on_stale: 100                        # no price: full power

Peak shaving: keep the import under the connection limit

A site with a 40 kW import contract and a heat pump, chargers or a compressor. When the grid meter shows more than 40 kW, the heat pump pauses until the import falls back under 32 kW. As a safety layer it wins over schedules and comfort rules, and the minimum interval protects the compressor.

grid meter · condition with release · layers · minimum interval

See the rule
- id: import-cap
  target: { device: heat-pump, command: power }
  kind: condition
  layer: safety                        # wins over schedules and comfort rules
  when: "grid.power_active_total > 40000"
  release: "grid.power_active_total < 32000"
  then: { params: { value: 0 } }
  else: null                           # otherwise: let the other rules decide
  timing: { every_s: 5, debounce: 3, min_interval_s: 300 }

Grid code: over-frequency derating

Above 50.2 Hz the inverters reduce their power in steps, down to 30 % at 51 Hz, and come back only under 50.1 Hz. Readings outside 45–55 Hz or jumping more than 1 Hz are ignored as glitches. The same pattern protects a real plant from over-voltage.

steps rule · signal validation · dead band · inverter group

See the rule
- id: of-derate
  target: { endpoint: pv, group: inverters, command: power_limit }
  kind: steps
  signal: "grid.frequency"
  signal_valid: { min: 45, max: 55, max_step: 1 }
  steps:
    - { at: 50.2, value: 90 }
    - { at: 50.5, value: 60 }
    - { at: 51.0, value: 30, fast: true }
  release_below: 50.1
  normal: { value: 100 }
  on_stale: 100

A pumping station on a tank level

A level transmitter read through a Modbus I/O module, a pump on a frequency drive. The pump starts under 30 % and stops over 80 %, with a minimum run and stop time and at most 6 starts an hour. If the level reading is lost the pump stops, and the drive's fault code becomes an alarm.

Modbus I/O · drive template · condition with release · timers · alarms

See the rule
- id: tank
  target: { device: pump-drive, command: run_at }
  kind: condition
  when: "tank.level_pct < 30"
  release: "tank.level_pct > 80"
  then: { params: { value: 45 } }      # Hz
  else: { params: { value: 0 } }
  timing: { every_s: 5, debounce: 2, min_on_s: 300, min_off_s: 120,
            max_starts_per_h: 6 }
  stale_after_s: 30
  on_stale: safe                       # level lost: stop

Night tariff, weekends, and “run it for an hour now”

A boiler or a pump on a weekly schedule: on at 23:00 on the night tariff, off at 06:00, a different window at the weekend. The operator's “run for an hour now” button on an HMI or in Node-RED is a force on the same rule over MQTT: after the hour it goes back to the schedule by itself.

schedule rule · force over MQTT · timezone-aware

See the rule
- id: boiler-week
  target: { device: boiler, command: power }
  kind: schedule
  schedule:
    - { days: Mon-Fri, at: "23:00", value: 1 }   # night tariff
    - { days: Tue-Sat, at: "06:00", value: 0 }   # the morning after each night
    - { days: "Sat,Sun", at: "13:00", value: 1, label: weekend }
    - { days: "Sat,Sun", at: "17:00", value: 0 }
  off_value: 0
# run it for an hour now, from an HMI or Node-RED:
#   mbg/rules/boiler-week/set  {"force": {"value": 1, "seconds": 3600}}

Battery full and exporting hard

Once the battery is at 98 % and the site exports more than 5 kW, there is nowhere left to put the energy cheaply. The inverters are curtailed to 60 % until either condition goes away, with 30 seconds of agreement before each change and at most one change every two minutes.

BMS + grid meter · condition rule · debounce

See the rule
- id: full-and-exporting
  target: { endpoint: pv, group: inverters, command: power_limit }
  kind: condition
  when: "battery.soc >= 98 and grid.power_active_total < -5000"
  then: { params: { value: 60 } }
  else: { params: { value: 100 } }
  timing: { every_s: 5, debounce: 6, min_interval_s: 120 }
  on_stale: hold

A factory SCADA, without new meters

Compressors, energy meters and drives already sit on RS-485 lines across the plant. Bridges carry the lines over the LAN, templates name every value the same way, and the SCADA reads everything over OPC UA, with quality and read time. The same values go to InfluxDB and Grafana for the energy team.

RS-485 bridges · templates · OPC UA · InfluxDB

Industrial meters in Home Assistant

A Modbus energy meter, an inverter and a few Zigbee sensors appear in Home Assistant by themselves, through MQTT discovery, each as its own device with stable names. Settings the template allows writing, such as a power limit, become number and select entities.

MQTT · Home Assistant discovery · write entities

A cold room that must not warm up

A temperature sensor over MQTT (Zigbee or BLE) and a calculated flag, “too warm” over 8 °C, declared as an alarm that must hold for ten minutes. Then it becomes an alert: the alerts service sends it to the on-call phone by SMS and Telegram, at night as well, and pages again by SMS if nobody acknowledges it within 15 minutes.

MQTT sensor · calculated value · alarm with a hold time · alerts service (Pro)

Pro

High availability in testing

For installations that cannot go without their data: two gateways on the same devices, one active and one standby. Part of the Pro edition; tested on a bench, the tests on real hardware are under way.

Explore high availability and Pro modules
  • Two links, double confirmation. A heartbeat on a dedicated RS-485 and on TCP; the standby takes over only when both are silent — or its partner's gateway reports itself down — and the bus is quiet.
  • The standby never puts a frame on the wire. It listens to the bus, holds a copy of the state and the configuration, and refuses every write.
  • One address. Clients (SCADA, virtual meters, the page) follow the active through keepalived or HAProxy, with the same OPC UA certificate.
  • You decide. Off, monitor with alerts, or automatic — only after a take-over test you run on your own pair.

An alarm that reaches the right people Pro

The heat pump reports error E101. The gateway raises the alarm its template declares once it has held for the alarm's hold time — here 30 seconds, so a blip never wakes anyone. The alerts service routes it: throttled, outside quiet hours, to Telegram, an SMS through the site's LTE router and e-mail; if nobody acknowledges a critical one within 15 minutes, it pages again by SMS. It says when the error clears. In production with 67 rules.

Product roadmap

What we are building next. Tell us which one your site needs first — it moves up the list.

View delivered features and planned integrations
  • CAN communicationActive CAN communication and transmission are planned. The current release receives and decodes frames in listen-only mode.
  • CAN, listen-only Ready · 3.98Reads a CAN bus without ever transmitting on it, decoded from the template; the first map is the Pylontech BMS → inverter link most batteries speak.
  • Victron GX Ready · 3.92Reads the system, its batteries and its sensors over MQTT, each a device of its own, and offers its ESS settings as guarded commands — grid setpoint, charge current and power, inverter power, feed-in, minimum SOC — for a supervisor, or a rule, to set.
  • A battery bank on BMS-CANPresent a battery bank to Victron or Deye inverters over their BMS-CAN protocol, from the values the gateway already has.
  • OPC UA client for PLCsFeed a soft PLC (OpenPLC, CODESYS) with live values and read its outputs back as a device — logic in the PLC, the buses in the gateway.
  • MCP for AI assistantsAn assistant such as Claude reads live values, history and diagnostics, and proposes changes as a dry run you approve.
  • Siemens S7Read S7-300/400/1200/1500 PLCs directly as a data source, next to Modbus, HTTP and MQTT.
  • IEC 60870-5-104An outstation for PV parks and grid operators: telemetry and set points over the protocol the utility speaks.
  • BACnet/IPServe every value to a building management system as BACnet objects.
  • Profinet IO deviceAppear on a Siemens PLC's Profinet as an IO device, with the buses behind it.
  • M-BusWired heat, water and gas meters as a data source.
  • Point list in and outExport the site's point list to CSV or Excel for the SCADA designer, and import one to configure many devices at once.
  • Commissioning reportA FAT/SAT report from the gateway itself: every point, its value, its quality and when it was checked.
  • Alarms with acknowledgementAlarms an operator acknowledges, kept with who and when, and passed to the SCADA as OPC UA alarms.
  • Security for tendersTLS everywhere, logs to syslog, an IEC 62443 description and a software bill of materials.
  • More devicesMore templates and counting: Siemens PAC, Schneider, ABB, SMA.

Tell us what you need

Contact, support, implementation

Tell us about your installation: what you have, what you need it to do. The message comes straight to us, and we answer by e-mail.

  • Support for a running gateway: version, what happened, what you expected.
  • Implementation for a new site: the devices, the buses, where the data should go.
  • Pro edition high availability, ESP nodes, MCP, support terms.
  • Bugs and ideas for everyone: GitHub issues.

Or write directly: [email protected]

We use what you send only to answer you, and never publish it. Privacy