Meryxon docs

Calculated fields

A calculated field derives a value from a device's readings as they arrive, such as load in kW, energy used today or how long a door has been open. Each value is stored as an ordinary reading named calc@1.<key>, so charts, queries and alert rules use it like any other property.

flowchart LR
    r["Reading arrives"] --> s["Stored"] --> f["Each matching field"] --> v["calc@1.key stored with the reading"] --> a["Alert rules and charts"]

Kinds

Kind Example Notes
Expression round(meter.energy@1.watts / 1000, 2) + - * /, brackets, numbers, min, max, abs, round(x, digits). Inputs older than maxAgeSeconds (one hour by default) give no value rather than a stale one
Window maximum of meter.energy@1.watts over the last hour sum, avg, min, max, count, delta over 1h, 24h, 7d, today, this_week or this_month
Time in state seconds switch@1.on was on today Counts from the last value before the window

today, this_week (from Monday) and this_month start at midnight in the site's time zone, or in the timeZone you set on the field.

Rules

API

POST /v1/calculated-fields with a calculated-field.v1 document (contracts/schemas/calculated-field.v1.schema.json). For example:

{ "name": "Load in kW", "key": "load_kw", "unit": "kW", "scope": { "siteIds": ["site_…"] },
  "definition": { "type": "expression", "expression": "round(meter.energy@1.watts / 1000, 2)" } }

An alert rule on calc@1.load_kw works like any other alert rule.