Utility resources
Track energy and resource consumption and estimate cost. Users map numeric device properties to named meters, then configure tariff plans whose formulas are evaluated against historical telemetry. Supported types: electricity, gas, water, sewage, and heat (modelled, not surfaced).
This is an estimate. It does not reproduce an invoice.
Out of scope
| Excluded | Reason |
|---|---|
| Provider tariff import, invoice import, invoice matching | The product is global; no country-specific providers or catalogues are modelled. |
| VAT, tax, gross/net handling | Every price a user enters is used as the effective calculation price, whatever it represents. |
| Photovoltaic, net billing, feed-in, dynamic market-price feeds | Not supported. |
| CO₂ estimation, anomaly detection, budgeting, alerts, optimisation suggestions | Not supported. |
| Holiday calendars | Day-of-week and date-range rules cover the need. |
Meters
A meter binds one device property to a named measurement point, carrying a utility type, a unit, a measurement kind, an optional room, an optional parent, an include-in-calculations toggle, and notes.
When the property is a canonical capability of the device, the meter is a scanned reference of the device model
(utility-meter findings, visible with utility.view; see Devices): a removed capability, a changed
kind, a changed unit or a retired device raises a finding that links to the meter's editor. Saving or deleting a meter
runs the scan.
| Measurement kind | Device reports | Usage derived by |
|---|---|---|
| Cumulative counter | A running total | CounterUse: each step between consecutive readings, the last reading at or before the window start as baseline, belongs to the bucket of the later reading and windows and buckets are (from, to]; a fall to under half the previous reading is a reset and the new reading counts as use, a smaller fall (or exactly half) counts none |
| Delta usage | Consumption since the last sample | Summing deltas |
| Instantaneous power | Current power | Integrating power over time |
Meters form a hierarchy. A main meter has no parent; with a main meter and children configured, the dashboard
shows unassigned usage as main minus children. An electricity main meter with children, included in calculations, is also the home's current
draw and Used today: a main meter whose device reports counts as itself, one whose device does not counts the
devices of the meters directly behind it, and the sum of every device is used only when nothing under the main meters
reports (see requirements). A meter with no children is not a main meter, so
put the plug meters behind the mains meter. On the main meter's device only the property the meter reads is counted
when the device carries it. GET api/utility/meters/main-devices names those devices, the property each main meter
reads and the devices behind it, with devices.view only and within the caller's device access. A save that would put a meter behind itself or behind one of its own
sub-meters is refused with 400.
| Rule | Detail |
|---|---|
| The recognised unit set is closed | Short symbols plus the canonical capability-catalog spellings. Energy normalises to kilowatt-hours, volume to cubic metres. Anything else raises an unsupported-conversion flag and the meter reports zero. |
| A cumulative meter's per-bucket usage includes the last sample before the bucket start as an anchor | Without it, bucket sums undercount against the whole-window total and single-sample buckets read zero. |
| A power meter's reading is interpolated to every range and bucket edge, from the last reading before the range and the first one after it | Without it, the time between a bucket's last reading and the next bucket's first is integrated by nobody, and a plug that reports only on change shows empty hours while it draws power. |
| A whole-home main meter is configured deliberately | Infrastructure devices behind smart plugs do not add up to a home. |
| A meter behind a counted meter is not counted again | Usage is summed over the counted meters of a scope: the selected meters without one whose parent, or any meter further up its chain, is selected with the same utility type. A water meter under an electricity meter is therefore counted in the water row. The rule applies within each scope: the whole selection for the widget's total (estimatedTotalCost), its time series and a preview, and each row on its own in a breakdown, so a room holding only sub-meters shows their use and a breakdown by meter shows every picked meter, while the total counts the home once. The sub-meters still count towards the whole-home coverage. A preview by device, by room or of the whole home counts the meters included in calculations whose utility type is the tariff's; a preview of one picked meter counts that meter. |
| A tariff is priced once per scope | The widget evaluates the tariff once for each row and once for the total over the row's or the selection's meters of the tariff's type, as a preview does. A measured-usage variable mapped to a meter resolves among every selected meter of that scope, sub-meters included, so ev * ev_rate with ev mapped to a charger behind the main meter prices the charger. The time series without a time-of-day value spreads the total variable cost over the buckets by the counted meters' use. |
| Usage is computed in the host, not in SQL | The window calculation and CounterUse read the samples and compute in C#; the SQL forms measured several times slower. |
Tariffs
A tariff plan has a utility type, name, currency, billing-period start day, and either simple components or an advanced formula.
| Component type | Applied |
|---|---|
PerUsage |
Rate × consumption |
PerScheduledUsage |
Rate that varies by time of day — see scheduled coefficients |
FixedPerDay / FixedPerMonth / FixedPerBillingPeriod |
Once per day / month / billing period; a range that covers only part of one is charged that part's share |
An advanced tariff stores two expressions, and the split is the point: the variable-cost expression is
evaluated once per time bucket when a scheduled coefficient is active, and the fixed-cost expression exactly
once per billing period the range overlaps, weighted by the share of that period's local days the range covers. In
the fixed expression days_in_period and elapsed_days are both the whole period's local days, so a monthly fee
counts once per whole period and a daily fee written as daily_fee * days_in_period counts once per day of the range.
With one combined expression a monthly standing charge would be multiplied by the bucket count. Simple component
mode achieves the same split through the component type.
Any term not proportional to measured usage belongs in the fixed expression. Nothing validates this at save time. Every variable detected in either expression must be mapped before the tariff is usable, to a constant, a measured usage (linked to a meter), a scheduled coefficient, or a billing-period value such as days in period.
| Variable kind (shown as) | Value comes from |
|---|---|
Constant (Fixed value) |
The value typed in. |
MeasuredUsage (Measured usage) |
The meter picked in the variable dialog, stored as {"meterId": "<id>"}. "Every meter in the report" stores no mapping: the variable is the summed usage of the counted meters of the scope (see the meter rules above), on every evaluation path, time-of-day per-unit components included. A mapping that names a meter outside the scope, or no meter at all, counts as 0 with a warning on every path; the dialog shows a mapping that names no meter as "Unreadable mapping" and a mapping to a deleted meter as "A deleted meter". |
ScheduledCoefficient (Time-of-day value) |
Its rules, falling back to the default value. |
BillingPeriodValue (Billing period value) |
The variable's name: days_in_period or elapsed_days. Any other name counts as 0. In the variable expression they are the local days of the range and the local days from the start of the billing period that holds the range's end to that end; in the fixed expression both are the whole billing period's days. |
A per-unit component picks existing variables: its usage from the measured-usage variables, and its rate from the fixed-value variables (per unit used) or the time-of-day values and fixed-value variables (per unit used, by time of day, where a fixed value is priced as usage × value). Its dialog offers those, requires both, and says to add them first when the plan has none. A variable already stored on the component stays offered when the evaluator still prices it in that role, so editing only the name never drops it; by time of day, a usage that is not a measured usage is priced at 0 and is refused.
variable: usage_kwh * energy_rate + usage_kwh * distribution_rate
fixed: fixed_fee + subscription_fee
gas billed in energy from a volume meter:
variable: usage_m3 * conversion_factor * gas_rate + usage_m3 * conversion_factor * distribution_rate
The gas volume-to-energy conversion factor is an ordinary user-configurable constant. Reeve ships no default, suggests no national value and fetches none, because it varies by gas composition and supplier. If the meter already reports energy, drop the factor entirely. Sewage has three configuration modes: equal to water, a separate meter, or water minus an excluded meter such as garden irrigation.
Formula language
A small recursive-descent parser evaluates the expression against the tariff's variables. It is separate from
workflow scripting, so a field ordinary users type into exposes no scripting surface. Allowed: + - * / ( ) and min, max, round, ceil, floor, abs. Not allowed: loops, user-defined
functions, any scripting engine, reflection, database access, external calls. Evaluation is purely functional — same
expression, same variables, same schedule, same result, no I/O. Division by zero surfaces as a data-quality warning,
not an exception.
Scheduled coefficients
A scheduled coefficient is a variable whose value depends on time of day, day of week and an optional date range. This is how time-of-use tariffs are expressed.
| Rule field | Meaning |
|---|---|
| Start / end time | The window. An end earlier than the start crosses midnight. |
| Days of week | Bitmask of the days the rule applies to. |
| Value | The coefficient for that window. |
| Priority | Highest matching priority wins; equal priorities raise a validation warning. |
| Valid from / to | Optional date range, for seasonal rules. |
Every scheduled coefficient needs a default value: no matching rule and no default fails the calculation. The evaluation range is split at every schedule-change boundary so each bucket uses the correct rate. Fixed cost is applied once per billing period, never per bucket.
Times of day, days of week and validity dates are read on the wall clock of the home's time zone, as are day, week and
month buckets, billing periods (which start at local midnight of the start day) and the months a monthly fixed cost
counts. A rule from 22:00 to 06:00 therefore covers the same local hours in winter and in summer, and a day bucket on a
daylight-saving change is 23 or 25 hours long. Each day, week or month bucket starts at the same local time as the first
one, counted from it, so a start moved out of a gap returns to its time the next day and a month bucket that started on
the 31st starts on the last day of a shorter month and on the 31st again after it. A wall-clock time that a change skips
moves forward by the length of the gap (02:30 on a spring-forward night becomes 03:30, a skipped midnight becomes
01:00); one that a change repeats falls on its first occurrence. The evaluation range of a time-of-day value is also
split at every local midnight, so a weekday-only rule that runs past midnight stops at the end of its day.
days_in_period, elapsed_days and a daily fixed cost count local calendar days, so a 23- or 25-hour day counts as
one. A home without a time zone is evaluated in UTC; one whose time zone this host cannot resolve is evaluated in UTC
too and logs utility.time_zone_unresolved (at most every 15 minutes per zone). The dashboard utility widget takes its
current and previous month or billing cycle, the end of today and its chart's day labels from the home's time zone, and
from UTC when the home has none or the browser cannot resolve it, so it agrees with the server except for a zone the
browser knows and the server does not. A billing cycle with a tariff plan starts on the plan's billing day, the one the
server bills by; the widget's own start day applies only without a plan. Its end-of-period projection reads the period
up to the end of today and adds the fixed cost of the rest of the period (asked from the server for tomorrow to the
period end), the variable cost the trend of the closed buckets gives every bucket left until the period ends, and for a
bucket still open today (today's day, or today's remaining hours) what the trend gives it beyond its cost so far. The
trend is fitted on closed buckets only, and buckets step by calendar hour, day, week or month in the home's time zone,
so a day with a clock change is one bucket.
Preview and data quality
Manual preview takes typed values per variable — and per time window when a scheduled coefficient is involved — evaluates the plan's formula and shows the variable, fixed and total cost. It needs a formula, so the plan page offers it only for a formula plan and says so while none is saved. It deliberately does not ask for an expected invoice amount and shows no match, difference or tolerance status. Historical preview takes a tariff, a scope (a meter, a device, a room or the whole home) and a date range, loads real telemetry, evaluates the plan in either mode, and shows the usage and the estimate with all quality flags. The plan page runs it for the whole home over the days it asks for, counted in the home's time zone, so a simple-components plan is previewed this way. When no meter of the plan's utility in the scope counts in calculations, the preview says so in a warning and reports no unit.
| Flag | Meaning |
|---|---|
Ok |
Nothing detected |
CounterResetDetected |
A cumulative counter fell to under half its previous reading; the new reading was counted as use since the reset |
SparseSamples |
A gap exceeds twice the expected interval |
MissingSamples |
No samples for part of the range |
PartialEstimate |
Power integration ran with incomplete coverage |
UnsupportedConversion |
The source unit cannot be normalised |
With a whole-home main meter the dashboard shows main, measured, unassigned (main minus measured) and a coverage percentage. Without one it shows only the sum of selected meters, behind a partial-scope banner, and shows no unassigned figure.
The Utilities dashboard widget shows costs in the bound tariff's currency, or the home's when it has no tariff, and
as plain numbers when neither has one. Its currency field is an optional override that only labels the amounts, since
nothing is converted. A stored USD is not applied over a tariff or home in another currency.
A new tariff plan starts in the home's currency, and with none set the currency field starts empty and must be filled; no currency is assumed.
API
Read, preview and aggregation endpoints require the utility-view permission; create, update and delete require utility-manage. Meter data is filtered by per-device hidden overrides and the base view permission, not by device time windows.
| Resource | Endpoints |
|---|---|
| Meters | GET/POST api/utility/meters, GET/PUT/DELETE api/utility/meters/{id}, GET api/utility/meters/available-properties, GET api/utility/meters/main-devices (with devices.view) |
| Tariff plans | GET/POST api/utility/tariffs, GET/PUT/DELETE api/utility/tariffs/{id}, POST api/utility/tariffs/{id}/duplicate |
| Variables and rules | GET api/utility/tariffs/{id}/variables, PUT api/utility/tariffs/{id}/variables (create), PUT/DELETE …/variables/{varId}, POST …/variables/{varId}/rules, PUT/DELETE …/variables/{varId}/rules/{ruleId} |
| Formula and components | GET/PUT api/utility/tariffs/{id}/formula, POST api/utility/tariffs/validate-formula, GET/POST api/utility/tariffs/{id}/components, PUT/DELETE …/components/{compId} |
| Preview | POST api/utility/preview/manual, POST api/utility/preview/historical |
| Aggregation | POST api/utility/aggregation |
An aggregation or historical preview range must be non-empty and at most 1,830 days long (a little over the five years the hourly aggregate keeps), with or without a granularity; a longer, empty or reversed range is refused with 400. Aggregation is also capped at one hundred thousand buckets per request. A request whose client goes away stops at the next bucket or tariff-schedule window instead of running to the end.
History older than a meter's oldest raw reading (raw telemetry is kept 90 days by default, the hourly aggregate five years) is read from the hourly aggregate, for every meter kind. A meter whose raw readings in the range number more than 200,000 (counted from the hourly aggregate) is read from the aggregate for the whole range, and only the part before the first and after the last aggregated hour is read raw. Either way, an aggregated hour stands for:
| Meter kind | One aggregated UTC hour | At a range, bucket or tariff boundary inside the hour |
|---|---|---|
| Cumulative counter | Its highest reading, taken at the end of the hour | The hour's use goes wholly to the side the hour ends in |
| Delta usage | The sum of its deltas | The whole sum goes to the side the hour ends in |
| Instantaneous power | Its average, held as constant power over the hour | Each side gets the energy of its share of the hour |
The aggregate's average is per reading, not weighted by time, so a sensor that reports irregularly within an hour, or once near its end, weighs that hour by those readings. A counter reset inside an hour is not seen as a reset: the hour's highest reading comes from before the reset, and the fall to the next hour's reading is treated like any other fall between two readings (more than half is a reset, less is counted as no use).
Traps
| Symptom | Cause and fix |
|---|---|
| A meter reads zero forever | Its unit string is outside the recognised set and cannot be normalised. |
| Bucket sums do not add up to the whole-window total | The anchor sample before the bucket start is missing from the query. |
| A monthly standing charge appears multiplied | A fixed term was written into the variable expression. Nothing validates this at save. |
| The calculation fails outright | A scheduled coefficient has no default and no rule matched. |
| Two rates fight over the same moment | Two rules share a priority. The validation warning names them. |
| The dashboard shows only part of the home's consumption | No whole-home main meter is configured, so no unassigned figure is invented. |
| The estimate differs from the invoice | Expected. Sampling gaps, counter resets, rounding, billing-day alignment, unmetered devices, taxes and provider surcharges all diverge. Use this to find major consumers and trends, not to reproduce line items. |
Metering details
- A WholeHome percentage exists only when a hierarchical main meter exists.
- An unmapped tariff variable means per-meter pricing; a mapping that names an absent meter keeps its warning.
- Unsatisfiable validity windows are rejected.
- Asking explicitly for a missing tariff plan answers 404.
- Unit spellings live in one table shared by consumption and the device-model scan, which folds
m³andµg/m³superscripts. - Reads go to the read replica when one is configured.