New: the AI firewall watches every module and explains each incident in plain words. See how it works

Flow cookbook

Ten flows to build: deadband filter, meter consumption, silent-sensor watchdog, forwarding, status keys, alarm mail and SMS, night mode and more.

Each recipe names the blocks, their settings and where to wire them. Recipes 1 to 5 and 8 to 9 go into a root flow on the IoT host (the tenant-wide root or a profile root); insert them on the telemetry output of the Message type switch, before or after Save telemetry as stated. Test every change with Test before you deploy. See The flow editor.

1. Store a value only when it changes enough

A level sensor reports every 10 seconds, but a change under 0.5 cm does not matter.

Message type ─telemetry→ Only changes → Save telemetry
  • Only changes: property msg.payload.level_cm, mode deadband, value 0.5, first on. Key: leave the default (one memory per device).
  • Records without level_cm should still be saved: put a Switch first (property msg.payload.level_cm, rule nempty), send its rule output through Only changes and its otherwise output straight to Save telemetry.

This reduces stored points, not counted messages. To reduce messages, change the device’s reporting. See Message quota and usage.

2. Consumption from a meter that can restart

A water meter sends a growing volume_m3; after a power loss it restarts from 0.

Message type ─telemetry→ Delta ─out→ Save telemetry
                              └other→ Save telemetry
  • Delta: input msg.payload.volume_m3, output msg.payload.volume_delta_m3, on_negative zero, seed latest, round 3.

For hourly or daily consumption you can also chart the raw counter with the increase aggregate. See Derived values.

3. Alarm when a sensor goes silent

Raise a warning when a device stops sending temperature for 15 minutes, clear it when it reports again.

Message type ─telemetry→ Switch (msg.payload.temperature nempty) → Watchdog ─timeout→ Raise alarm
                                                                     └ok→ Clear alarm
  • Watchdog: ms 15 min, key msg.originator (default), repeat off.
  • Raise alarm: alarm temperature_silent, severity warning, text No temperature for 15 minutes.
  • Clear alarm: alarm temperature_silent.
  • Keep the Switch‘s output also wired to Save telemetry, or wire the watchdog branch beside it.

A watchdog starts watching a device at its first message after the deploy. For devices that are completely offline, also use an offline alarm rule. See Offline alarms.

4. Forward every reading to your server

Save telemetry → HTTP request

  1. Create an HTTP endpoint connection to https://ingest.example.com with bearer authentication. See Connections and secrets.

  2. HTTP request: method POST, path /readings, body template, template_format json, template:
    {"device": {{ msg.metadata.deviceName }}, "ts": {{ msg.metadata.recordTs }}, "values": {{ msg.payload }}}

  3. late send, so a backlog after an outage is forwarded too.

  4. Wire the request’s error output to a System log block (text forward failed: {{ msg.error.code }}).

Wiring after Save telemetry forwards only what was stored. For many devices, put a Batch (count 50) and a Join (auto, array) before the request to send groups.

5. A status key for site views and charts

Site views colour rooms by a status key. Store one derived from the temperature:

Message type ─telemetry→ Switch (msg.payload.temperature nempty) → Calculate → Save telemetry
  • Calculate: target msg.payload.status, expr msg.payload.temperature > 8 ? 2 : (msg.payload.temperature > 6 ? 1 : 0).

Site views read 2 as critical and 1 as warning. As a number, status also charts and aggregates. See Site views.

6. Mail and SMS an on-call address when an alarm opens

A flow (not a root) on the IoT host:

Device message (types: alarm) → Switch (msg.metadata.alarm.transition) ─created→ Rate limit → Notify
  • Device message: types alarm (tick it by name), profiles: the ones you care about.
  • Switch: property msg.metadata.alarm.transition, rule eq created.
  • Rate limit: n 5, per_ms 1 h, mode drop, key msg.topic (one limit for all).
  • Notify: recipients address oncall@example.com, phone +905551112233, and role ADMIN (in-app and push); title {{ msg.payload.title }}; text Alarm on {{ msg.payload.deviceName }}: {{ msg.payload.title }} ({{ msg.payload.severity }}); urgency critical.

Roles reach members in the app, by push and in chat apps; only address and phone rows get mail and SMS. See Alarm, command and notify blocks.

7. Night mode

Two flows on any host switch a third flow (“Night actions”) on at 22:00 and off at 06:00.

  • Flow A: Schedule (daily, 22:00, every day, tz Europe/Istanbul) → Enable or disable a flow (flow: Night actions, state enable).
  • Flow B: Schedule (daily, 06:00) → Enable or disable a flow (state disable).

Both need the typed confirmation at deploy. At most 6 switches a minute per organisation.

8. Switch a pump between two levels

Start a fill pump below 30 % and stop it above 80 %. Between the two levels nothing is sent, so the pump does not chatter.

Save telemetry → Switch (property msg.payload.level_pct)
                    ─rule 1: lt 30→ Not repeated → Send command pump.set {"on": true}
                    ─rule 2: gt 80→ Not repeated → Send command pump.set {"on": false}
  • Switch: property msg.payload.level_pct, rules lt 30 (Name low) and gt 80 (Name high), stop_first on. A record without the key goes to otherwise and is ignored.
  • Each Not repeated: period 10 min, so the command is sent once and repeated at most every 10 minutes while the level stays out of the band.
  • Send command: the profile’s pump.set command with params {"on": true} or {"on": false}.

Commands from flows are limited to 30 a minute per device, and a late message sends nothing. For operator-facing control with Manual and Auto modes, the Rules card is often the better tool: see Rules card: actions.

9. Decode a binary payload

A device sends 4 bytes: a signed temperature × 10 and an unsigned humidity. It arrives as raw (base64).

Switch (msg.payload.raw nempty) → Change → Base64 (decode) → Hex (encode) → Bytes (decode) → Save telemetry
  • Change: set msg.payload to the path msg.payload.raw.
  • Bytes fields: temperature offset 0 i16 scale 0.1; humidity offset 2 u16.

See Data transform blocks.

10. Take readings from another system by webhook

An outside system posts JSON to Hermetry, and the flow forwards it.

  • Webhook trigger: auth hmac, parse json, reply accepted. Copy the address and secret from the Webhooks dialog.
  • Then Switch on msg.payload.type, Change to reshape, and an action: Notify, Webhook, MQTT out, or Set variable.

By default a webhook’s message is about the organisation, not a device, so Save telemetry refuses it. To feed device readings from another system, let it send them as the device over MQTT or the device HTTP API. See Device HTTP API.