Aggregation reporter: select sensors by asset, name and unit - #2525
Open
Ahmad-Wahid wants to merge 4 commits into
Open
Aggregation reporter: select sensors by asset, name and unit#2525Ahmad-Wahid wants to merge 4 commits into
Ahmad-Wahid wants to merge 4 commits into
Conversation
Context: - Issue #2520: a site often wants one aggregated signal (all its PV, say), which so far meant naming every sensor in the report parameters by hand. Change: - The config gains `asset`, `sensors`, `sensor_name_pattern` and `sensor_units`, which select the sensors to aggregate; `asset` covers an asset and its offspring. - Values are converted to the unit of the output sensor, and read at its resolution, so sensors recording in different units and at different resolutions can be aggregated; `convert_units` turns the conversion off. - The output sensor is left out of the aggregation, so a report can be recorded on a sensor sitting below the very asset being aggregated. - `input_sensors` reports the selected sensors too, so the data source stays accountable. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
…lection Context: - Issue #2520 adds sensor selection, unit conversion and resampling to the AggregatorReporter, none of which the existing tests reach. Change: - Add a site fixture whose PV sensors sit on a child and a grandchild asset, record in kW and MW, and report at quarter-hourly and hourly resolutions, with a previous report already on the sensor the aggregate is recorded on. - Cover selection by asset, by sensor list, by name pattern and by units, the unit conversion and its `convert_units` switch, the refusal to aggregate a temperature onto a power sensor, an empty selection, an unparsable pattern, and the selection landing on the report's data source. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Context: - Issue #2520 lets the AggregatorReporter select its own sensors, which the reporting feature page did not describe. Change: - Describe the `asset`, `sensors`, `sensor_name_pattern` and `sensor_units` config fields, the conversion to the output sensor's unit and resolution, and the exclusion of the output sensor. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Context: - PR #2525 lets the AggregatorReporter aggregate everything below an asset. Change: - Add a New features entry naming the asset, the narrowing filters and the conversion to the output sensor's unit and resolution. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Documentation build overview
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A site usually wants its sensors as one aggregated signal — all the PV on site, so it can be
forecast and used in flex scheduling. Until now the
AggregatorReportercould do that only if everysensor was named by hand in the report parameters, which does not survive an inverter being added.
The reporter now selects its own sensors, through four new config fields:
asset— aggregate the sensors of this asset and of all of its offspring, so pointing at a site asset covers everything below it.sensors— aggregate these sensors, listed by ID.sensor_name_pattern— keep only the sensors whose name matches this regular expression.sensor_units— keep only the sensors recording in one of these units, or in a unit measuring the same quantity, so["MW"]also keeps a sensor recording inkW, but not one recording inMWh.Sensors named in the
inputparameters still work, and are read as described there; the selectedsensors are added to them.
inputis therefore no longer required in the parameters — a selection inthe config is enough, and a reporter that selects nothing at all says so, rather than failing later
inside Pandas.
Units and resolutions are reconciled with the output sensor. A discovered sensor cannot be
hand-checked, so values are converted to the unit of the output sensor and read at its resolution.
That is what makes a roof recording 100 kW in quarter-hourly events and a carport recording 0.2 MW in
hourly events add up to 0.3 MW on an hourly MW sensor. Passing a
resolutionparameter still winsover the output sensor's,
convert_units: falseaggregates the raw values, a sensor without a unit isnever converted (an empty unit says nothing about what its values mean, so it draws a warning), and a
sensor whose quantity the output sensor cannot express — a temperature onto a power sensor — is
reported as an error instead of being silently added up.
The output sensor is left out of the aggregation. A report is often recorded on a sensor of the
very asset being aggregated, and reading it back in would fold each run's own previous output into the
next one.
Accountability. The selection lives in the config, not in the parameters, so it is recorded on
the reporter's data source alongside the method and weights, and a changed selection yields a new data
source.
input_sensorsreports the selected sensors too, so an automation validating what a reporterreads sees the same sensors the reporter will read.
documentation/changelog.rstHow to test
Eight tests are added, on a fixture whose PV sensors sit on a child and a grandchild asset, record in
kW and MW at quarter-hourly and hourly resolutions, and whose output sensor already holds a previous
report of 99 MW.
Each was verified to fail with the code it covers disabled — the breaks used were: dropping the
name-pattern filter, dropping the units filter, including the output sensor, skipping the unit
conversion, ignoring
convert_units, not defaulting the resolution to the output sensor's, droppingthe empty-selection error, not overriding
input_sensors, ignoring thesensorslist, not walkingasset.offspring, skipping the regex validation, and takingassetas a plain int rather than anasset. Every new test went red under at least one of them, and the whole set is green with the code in
place.
The 15 pre-existing aggregator tests are untouched and still pass, as do the reporting, schema, CLI
and API report-trigger suites.
Further improvements
Two items of #2520 depend on PRs that have not landed yet, so they are noted rather than done here:
config, which is exactly what Reports as jobs and as automations #2297 pins on a report automation's data source, and
input_sensorsresolves the selected sensors so the output-scope check has something to check. Worth re-testing
end to end once Reports as jobs and as automations #2297 merges.
site-aggregatetemplate carrying this reporter, anasset/sensor_name_patternconfig and the recommended rolling window would fit Prepared report templates #2300's shape directly,and is left to that PR.
sensor_unitsmatches on dimension rather than on the exact spelling, which is what makes it usefulnext to the unit conversion; a caller wanting an exact-spelling filter would need a further option.
Related items
Closes #2520.
Sign-off
🤖 Generated with Claude Code