Skip to content

Prepared report templates - #2300

Merged
Flix6x merged 239 commits into
mainfrom
feat/2288-report-templates
Nov 30, 2026
Merged

Flix6x merged 239 commits into
mainfrom
feat/2288-report-templates

Conversation

@Flix6x

@Flix6x Flix6x commented Jul 11, 2026 •

Copy link
Copy Markdown
Member

Description

Defining a report means writing reporter configuration, and writing it from nothing is the step that
stops people defining reports at all. FlexMeasures now ships prepared report templates: a reporter
class, a complete configuration and a parameters skeleton, ready to fill in and run.

Nine templates, packaged under flexmeasures/data/templates/reports/ and shipped in the wheel.
energy-costs uses the ProfitOrLossReporter to report energy costs over the reporting window, from
a power or energy sensor and a consumption price sensor, as positive values. self-consumption uses
the PandasReporter to report the share of produced energy consumed on-site, from a production and a
consumption sensor: the elementwise minimum of the two, averaged per reporting period, over average
production. aggregate-sensors uses the AggregatorReporter to sum several power or energy sensors
into one total, event by event, with weights shown commented out so that subtracting a sensor, such as
an EV charger, is a one-line edit. daily-energy totals a single sensor per day: it reads its input as
energy, so a power sensor is totalled just as correctly as an energy sensor, and converts the result to
the output sensor's unit. clipped-values copies a sensor's values, pulling anything outside a valid
range to the nearest bound. valid-range leaves anything outside the range out instead, so a faulty
reading leaves a gap rather than a plausible-looking value. dynamic-tariff adds the energy tax and a
supplier surcharge to the day-ahead price, and then the VAT. meter-readings-to-flow turns the readings
of a cumulative meter into the flow per interval, leaving out implausible flows, such as the negative one
a reset meter gives. regularise puts irregular readings on a regular 15-minute grid, interpolating in
time between the readings around each grid point.

The first five are the templates named in discussion #2203. The other four come from the reports we
actually run, which the first five did not cover: the dynamic tariff is by far the most data any
reporter writes, and validating, differencing and regularising meter data is most of the rest.
building-consumption is renamed to aggregate-sensors, as it is the aggregation template, which its
name hid.

Each template is complete except for the sensors — and, in three cases, for values that are not
sensors: clipped-values and valid-range leave the bounds of the valid range as placeholders in their
config, and meter-readings-to-flow the bounds of a plausible flow, because no default range is
meaningful. Placeholders are found wherever they sit, in the config as much as in the parameters, so an
unfilled bound is refused exactly like an unfilled sensor id. Every template also carries a recommended
rolling window, which is what makes a template useful to a recurring report rather than only a
one-off: the previous day (start-offset: -1D,DB, end-offset: DB) for most, the next day for
dynamic-tariff, the previous day plus one reading for meter-readings-to-flow (so the last interval of
the day has the reading at its end), and the four hours either side of each hourly run for
regularise, so a recent grid point is interpolated again once the readings after it are in.

Discovering them. flexmeasures show report-templates lists the templates with their reporter and
description; --name prints one in full, as commented YAML, ready to redirect to a file and edit.

Using them. --template on flexmeasures add report and on
flexmeasures add automation --type reporting loads the template's reporter, configuration and
parameters as defaults:

flexmeasures show report-templates --name self-consumption > my-report.yml
# fill in the FILL_IN sensor ids, then:
flexmeasures add automation --asset 3 --name "Daily self-consumption" \
  --cron "0 1 * * *" --type reporting --template self-consumption --parameters my-report.yml

What the user writes always wins, at a deliberate granularity. An explicit --reporter is kept
over the template's. Top-level keys of a --config or --parameters file override the template's.
Timing fields — start, end and the offsets, whether in the parameters file or given as CLI
options — replace the template's recommended window as a group, so a half-overridden window can
never be assembled out of two different intentions.

Placeholders left unfilled abort with a validation error naming the exact fields still holding
FILL_IN, rather than failing later inside the reporter with something less legible. Combining
--template with --source is refused, since the data source already determines the reporter and its
configuration, and --template on a non-report automation is refused too.

  • Added changelog item in documentation/cli/change_log.rst

How to test

See the manual test walkthrough in the PR comments.

pytest flexmeasures/cli/tests/test_report_templates.py

Seventeen tests. Every template's configuration, and its filled-in parameter skeleton, is validated
against the reporter it names, so a template that drifts from that reporter fails here rather than in a
user's terminal. One test walks every packaged template, checking that its reporter exists, that it
recommends a rolling window rather than a fixed period, and that it leaves every input and output sensor
to the user, so a tenth template is covered the moment it is added. Seven tests pin the numbers the
templates produce: the site total is twice the value each input sensor holds, and nothing once one of
the two is weighted -1; 2 kW over 24 hours lands as 0.048 MWh on an MWh output sensor (covering both the
unit conversion and the daily sum); 0, 1, 2, 3 clipped to [1, 2] gives 1, 1, 2, 2, while valid-range
keeps only the 1 and the 2; a day-ahead price of 100 EUR/MWh with 50 tax, 10 surcharge and 21% VAT gives
193.6, with the daily tax and VAT read at the price's 15-minute resolution; meter readings 10, 11, 13, 12,
14 give flows of 1, 2 and 2, at the start of each interval, leaving out the -1 of a meter running
backwards; and readings at 00:05, 00:20 and 00:50 are interpolated onto 00:00, 00:15, 00:30 and 00:45.
show report-templates is checked to list all nine templates and to print valid YAML for each. The
end-to-end test fills in self-consumption's sensors, creates the automation, runs it, and checks the
stored daily self-consumption shares. The error paths are covered too: unfilled placeholders, an unknown
template, --template on a non-report automation, --template combined with --source, and an
override file that is not a mapping. One test pins what self-consumption means with no production at
all, which is undefined rather than zero.

aggregate-sensors leaves the resolution to the AggregatorReporter, which converts each input to the
output sensor's unit and resamples it to the output sensor's resolution before summing. An earlier
version stated PT15M, which contradicted any output sensor recording at another resolution.

Further improvements

  • Peak demand, CO2 emissions, self-sufficiency and a ratio kept within bounds (such as a COP) are obvious
    next candidates, and cheap to add now that the shape is settled.
  • self-consumption, daily-energy and regularise state the resolution they resample to (1D,
    15min), and ask you to edit it to match the output sensor's.
  • Templates are packaged with FlexMeasures. Letting a plugin contribute its own would follow the same
    discovery path, and is not attempted here.
  • The templates were verified to be present in the built wheel — hatchling ships everything under the
    flexmeasures package — so no MANIFEST or package-data change was needed.
  • Filling in a template is CLI-only for now. A UI dialog that picks a template and fills its placeholders through sensor search is tracked in Fill in a report template from the UI, picking its sensors through search #2642.

Related items

Part of the automations story #2334, and of #2288. Answers the templates part of discussion #2203.
closes #2934

Flix6x and others added 22 commits July 11, 2026 15:06
Automations are recurring tasks (for now: computing forecasts) defined per
asset. The recurrence is defined by a cron string, and the work to be done
is defined by a data generator (linked through a data source) together with
the parameters to call it with.

Includes a migration for the new table, and new dependencies on croniter
(cron matching/validation) and cron-descriptor (natural-language recurrence
descriptions).

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
- `flexmeasures add automation` creates an automation (active by default),
  validating the forecast parameters with the forecast parameter schema and
  storing the forecaster config on a data source.
- `flexmeasures edit automation` edits the name, recurrence (cron string)
  or activation status.
- `flexmeasures delete automation` deletes an automation.
- All three record their events in the asset's audit log.
- `flexmeasures jobs run-automations` queues jobs for all automations due
  this minute (to be run once per minute, e.g. via cron), with a Redis-based
  guard against duplicate runs within the same minute.

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Data generators can now be told how their queued jobs got triggered (via the
CLI, the API or an automation), and the train-predict pipeline stores this
on the jobs as meta data. The asset's status page shows it in a new
'Created Via' column of the jobs table.

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
GET /api/v3_0/assets/<id>/automations lists the automations defined on an
asset (without generator and parameters details). GET
/api/v3_0/assets/<id>/automations/<automation_id> additionally provides the
parameters, data generator info and counts of recently created jobs per job
status. Both are documented in the OpenAPI specs.

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
/assets/<id>/automations shows the asset's automations in a tabbed view
(schedules and reports tabs are prepared but deactivated), with per-row
details (parameters, data generator, job counts) loaded asynchronously into
a modal. The page is linked in the breadcrumbs dropdown and links to the
status page, where recent jobs are listed.

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
CI runners have no locale set (POSIX), which made cron-descriptor render
'At 06:00' while dev environments with an en_US-style locale rendered
'At 06:00 AM'. Request 24-hour format explicitly so the description is
deterministic across environments.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pxkeq64jtENY7fiWjwUsVS
- Escape automation names (and other user-controlled strings) in the
  Automations page and the status page's jobs table, closing two stored
  HTML/script injection sinks.
- Wipe parameter state on the (possibly shared) cached data generator before
  each automation run, so automations sharing a generator data source don't
  pollute each other's runs.
- Count automation job stats under the forecast target sensor(s) from the
  automation's parameters, which may belong to a different asset.
- Release the per-minute Redis guard when a run fails, so a retry within the
  same minute can still queue jobs.
- Return 404 (as documented) for nonexistent automation ids on the detail
  endpoint, and check permissions on the asset, so automation ids can no
  longer be enumerated across accounts via 403-vs-422 differences.
- Use ondelete=SET NULL for the generator FK: deleting a data source no
  longer silently deletes automations.
- Delegate Automation ACL to the asset's ACL instead of duplicating it.
- Extract the config/parameters assembly shared by `add forecasts` and
  `add automation` into a helper (which no longer drops falsy config values).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Completes the previous commit, whose staged files were dropped by an
interrupted pre-commit run: template escaping, shared-generator state reset,
job stats under target sensors, Redis guard release on failure, 404 for
nonexistent automations, SET NULL generator FK, ACL delegation, and the
shared CLI config/parameters assembly helper.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
The scheduling job creators accept an optional trigger dict (stored as job
meta data), like the forecasting pipeline already does. The API trigger
endpoint records origin API; the CLI and automations follow in the next
commit. The status page's 'Created Via' column picks this up automatically.

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Automations now also support the 'schedules' type:

- `flexmeasures add automation --type schedules` validates the parameters as
  a schedule trigger message (per the AssetTriggerSchema, as accepted by the
  API trigger endpoint, without the asset id). The schedule 'start' may be
  omitted, in which case each run schedules from the run time (floored to the
  message's resolution, if given) — a fixed start draws a warning.
- The runner dispatches schedules automations to the same job creators as the
  API trigger endpoint (sequential or simultaneous), recording trigger meta
  data (origin automation) on the queued jobs; `flexmeasures add schedule
  --as-job` now records origin CLI.
- Job stats for schedules automations are counted from the scheduling job
  cache (asset-level wrap-up jobs and per-sensor device jobs).
- The UI automations page's Schedules tab is now enabled, with automations
  filtered by type per tab.

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
- New endpoints on assets: POST /automations (create, validating parameters
  by automation type), PATCH /automations/<id> (name, cron string, activation
  status) and DELETE /automations/<id>. Managing automations requires the
  same principals that may delete the asset (account admins and consultants).
- The UI automations page gets a 'New automation' modal and per-row
  (de)activate and delete actions, shown to users with management rights.
- Creation, update and deletion logic (incl. audit log records) moved into
  the automations service, shared by the CLI commands and the API endpoints.

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
- Activate the reporting queue (it was prepared but commented out), including
  worker help texts and queue cleanup.
- Reporters accept as_job: a job is queued (with trigger meta data) that
  rebuilds the reporter from its data source, computes the report and saves
  the results to the database.
- `flexmeasures add report --as-job` queues such a job; reporting jobs show
  up in the asset's jobs overview (status page and API).

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Automations can now compute reports on a recurring basis:

- `flexmeasures add automation --type reports --reporter <class>` stores the
  reporter config on a data source (steady across runs, so all report results
  attribute to the same source) and validates the report parameters.
- The report window resolves freshly on each run: 'start-offset'/'end-offset'
  fields (comma-separated Pandas offsets, applied to the run time in the
  first output sensor's timezone) express a rolling window, and without any
  timing fields the window defaults to the last cron period (from the
  previous cron fire time until the run time). Absolute start/end still work,
  but draw a warning.
- The API creation field 'forecaster' is generalized to 'generator' (also
  accepting reporter classes), and the UI's New automation modal gains data
  generator and config fields; the Reports tab is now enabled.

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Each automation run is recorded in Redis; a report automation without timing
fields then reports on the period since its actual last run, falling back to
the last cron period when no last run is known (e.g. on the first run, or
after a Redis flush). This gives gapless coverage even when runs are missed.

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Consolidates the shared automations concept (model, lifecycle, runner
deployment, provenance) into documentation/features/automations.rst, with
the per-feature pages linking to it and keeping only their type-specific
parameter semantics.

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Hosts can now discover and use ready-made report definitions (reporter
class + complete config + parameters skeleton) instead of authoring
YAML from scratch:

- Two templates ship in flexmeasures/data/templates/reports:
  energy-costs (ProfitOrLossReporter) and self-consumption
  (PandasReporter), each with FILL_IN sensor placeholders and a
  recommended rolling reporting window for recurring use.
- `flexmeasures show report-templates` lists them; `--name <name>`
  prints the full YAML (with comments) to pipe to a file.
- `flexmeasures add report` and `flexmeasures add automation --type
  reports` accept `--template <name>`, using the template as defaults
  under any --config/--parameters files and other options (user keys
  win; user-provided timing fields replace the template's window).
- Unfilled placeholders produce a clear validation error listing the
  fields to fill in.

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
@read-the-docs-community

read-the-docs-community Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Flix6x and others added 7 commits July 11, 2026 22:20
- API automation creation now checks that the caller may read every sensor
  referenced in the parameters/config and record data on the sensors the
  automation writes to, closing a cross-account data read/write hole.
- `add report --as-job` implies --save-config (the worker rebuilds the
  reporter from its data source, so jobs without stored config always crashed).
- Report automation parameters are validated with the chosen reporter's own
  parameters schema, not the base schema.
- Invalid start-offset/end-offset strings are rejected at creation instead of
  being silently skipped at run time (which yielded empty report windows).
- run_report_job wipes the shared cached reporter's parameter state, like the
  automation runner already did, so consecutive jobs in one worker process
  don't pollute each other.
- Default report windows now anchor to the end of the last *successfully*
  covered window, recorded by the reporting job upon success — failed jobs no
  longer create permanent reporting gaps, and the enqueue-time minute-rollover
  gap is gone (the recorded anchor is the window end itself).
- The cron-period fallback window is computed in the platform timezone,
  matching how the runner decides when automations fire.
- Job stats for schedules automations also scan flex-model device sensors
  (which may belong to child assets), so failed per-device jobs show up.
- The trigger provenance kwarg is excluded from the job cache hash, so
  identical schedule requests from different origins dedupe again.

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
…essage format

PR #2303 makes click report the validation message rather than the offending
value, which changes the exact wording of this error.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Merge current main, resolve the shared forecasting and documentation changes, regenerate the lockfile, and move the automation migration after the current migration head.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Reject cron expressions with seconds, year fields, or aliases because the automation runner executes once per minute.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Test valid five-field expressions and reject unsupported seconds, year, and alias formats.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Keep the per-minute Redis guard after failures because an attempt may already have queued some forecast jobs.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Flix6x and others added 2 commits September 17, 2026 20:18
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0129WrXeJ5gia2pctFH93BqC
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Discussion #2203 named five report templates worth preparing;
two of them shipped as energy-costs and self-consumption.
This adds the remaining three:

- building-consumption sums several power or energy sensors into one site total,
  and is the first template to use the AggregatorReporter.
- daily-energy totals one sensor per day, reading it as energy,
  so a power sensor can be totalled just as well as an energy sensor.
- clipped-values pulls out-of-range values to the nearest bound,
  and leaves the bounds of the valid range to the user, as a placeholder in its config.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida

Copy link
Copy Markdown
Contributor

Pushed three more templates, so the set is now the five that discussion #2203 named:

  • building-consumption (AggregatorReporter) sums several power or energy sensors into one site total, event by event. It was that discussion's original use case, and the first template to use this reporter at all. Weights are shown commented out, so subtracting on-site production is a one-line edit, and it states its resolution explicitly: the aggregator combines inputs event by event and then stamps the output sensor's resolution on the result, so a mismatch would mislabel data rather than raise.
  • daily-energy (PandasReporter) totals one sensor per day, reading its input as energy, so a kW power sensor totals as correctly as a kWh meter, and converting the result to the output sensor's unit.
  • clipped-values (PandasReporter) pulls out-of-range values to the nearest bound. It is the first template whose placeholders are not all sensor ids — the bounds are left to the user, since no default range is meaningful, and placeholder detection already covers the config, so an unfilled bound is refused like an unfilled sensor.

Ran all five afterwards: 96 summed events from 0 to 125 kW, 0.89625 MWh for 896.25 kWh of kW data, and values clipped to [0, 100] with 120 landing at 100 and -5 at 0. A building-consumption automation due every minute also queued and ran on a worker over the window its offsets resolved to. One test now walks every packaged template, so a sixth is covered the moment someone adds it.

Open question from my side: clipped-values is the weakest of the five a transformation dressed as a report, storing a near-copy of a sensor. Happy to drop it if we would rather the shipped set stayed sharper.

@BelhsanHmida BelhsanHmida self-assigned this Sep 22, 2026
Flix6x and others added 2 commits September 26, 2026 01:09
A report template is still checked before the payload is assembled, which main now splits by automation type.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0129WrXeJ5gia2pctFH93BqC
Signed-off-by: F.N. Claessen <claessen@seita.nl>
@nhoening

Copy link
Copy Markdown
Member

Could a UI dialogue with sensor search also be an item for future work?

@BelhsanHmida

Copy link
Copy Markdown
Contributor

Could a UI dialogue with sensor search also be an item for future work?

Yes good suggestion. I created this issue for it #2642.

Adapt the template tests to main: the fresh-db fixtures are now named setup_dummy_asset_fresh_db and setup_dummy_data_fresh_db, and psycopg 3 needs a datetime, not a string, to compare with event_start.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
It is the aggregation template, which its name hid. Its description now says that it sums, and that a weight of -1 subtracts a sensor. It no longer fixes the resolution at PT15M: the AggregatorReporter already reads at the output sensor's resolution, which PT15M contradicted for any other output.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
The day-ahead price plus the energy tax and a supplier surcharge, with VAT added: the report behind a dynamic supplier tariff. Each run computes the next day, once the day-ahead prices are in.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Where clipped-values pulls a faulty reading to the nearest bound, valid-range drops it, so it leaves a gap rather than a plausible-looking value. That is how hand-written reports validate meter data and ratios such as a COP.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
It turns the readings of a cumulative meter into the flow per interval, recorded at the interval's start, and leaves out flows outside a plausible range, such as the negative one a reset meter gives. Its window ends one reading after midnight, so the last interval of the day is not lost for want of the reading at its end.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
It puts irregular readings on a regular grid, interpolating in time between the readings around each grid point. Like the hand-written regularising reports, it stores the grid values as moments, can write them back onto the input sensor without reading them as readings again, and runs hourly over the four hours either side, so a recent grid point is interpolated again once the readings after it are in.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…ed version

They sat under v1.0.0, which was released without them, and named the automation type reports, which is now reporting.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida
BelhsanHmida requested a review from nhoening November 2, 2026 20:55
@nhoening nhoening added this to the 1.2.0 milestone Nov 2, 2026
BelhsanHmida and others added 4 commits November 2, 2026 23:35
… flow is stored unconverted

Meter sensors record instantaneous readings, so the flow computed from them has a resolution of 0,
which failed the output resolution check against any 15-minute output sensor.
The template now skips that check, as the reports we run do.
Its comments also say that the output sensor needs the meter's unit, such as kWh rather than kW,
since the flow is not converted.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Brings in the transformation allow-list of v1.1.2, which the templates have to respect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3SfN2GwxVNn1ws2ep
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…, and say which price unit energy-costs needs

- daily-energy and self-consumption keep only the most recent belief about each day when resampling:
  meter data has a belief time per value, which made the summing resample fail (NotImplementedError)
  and the averaging one record a partial-day value per belief time. Tested on meter-like data.
- regularise joins the grid with combine_first instead of _append, which the transformation allow-list refuses;
  combine_first keeps a reading on a grid point only once, so the groupby/first step is gone.
- energy-costs asks for a price per the input sensor's energy unit (EUR/kWh for kW or kWh, EUR/MWh for MW or MWh),
  as the ProfitOrLossReporter does not convert between them. Tested with a kW sensor.
- Changelog entry for the templates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3SfN2GwxVNn1ws2ep
Signed-off-by: F.N. Claessen <claessen@seita.nl>
@Flix6x Flix6x added enhancement New feature or request Reporting CLI labels Nov 30, 2026

@Flix6x Flix6x left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second round, after the first review demo of this stack. Everything from that round is now done on this PR:

  • Daily templates on meter data: daily-energy and self-consumption keep only the most recent belief when resampling to a day (keep_only_most_recent_belief: true), as meter data has a belief time per value. On the same data, daily-energy now records one value, 65.8 kWh, from the template as it is. Before, it failed with a NotImplementedError. self-consumption records one share per day; before, it recorded fifty partial ones. test_daily_templates_record_one_value_per_day_on_meter_data pins this.
  • regularise: uses combine_first instead of _append, which the allow-list of v1.1.2 refuses, so its test passes again, in CI too.
  • energy-costs: the template says the price must be per the input sensor's energy unit (EUR/kWh for a sensor in kW or kWh), as the ProfitOrLossReporter doesn't convert. test_energy_costs_template_computes_the_costs_of_a_kw_sensor covers it.
  • Changelog: an entry under v1.2.0. DCO passes.

So this is ready to merge, and goes in first. #2797 then needs this branch merged in. Besides the changelog line, that now also means six conflicting places in asset_automations.html, as this branch brought in main's plugin types and automation dependencies (#2871, #2903 and #2706). That comes on top of the changes requested in the #2797 review.

@Flix6x
Flix6x merged commit 4015e9c into main Nov 30, 2026
11 checks passed
@Flix6x
Flix6x deleted the feat/2288-report-templates branch November 30, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI enhancement New feature or request Reporting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prepared report templates for reports

3 participants