https://github.com/solarnetwork/sn-agg-query
Small node utility to export SolarNetwork data as CSV, aggregated by date.
https://github.com/solarnetwork/sn-agg-query
Last synced: about 1 year ago
JSON representation
Small node utility to export SolarNetwork data as CSV, aggregated by date.
- Host: GitHub
- URL: https://github.com/solarnetwork/sn-agg-query
- Owner: SolarNetwork
- License: apache-2.0
- Created: 2016-05-05T23:32:41.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-08-02T02:11:41.000Z (almost 9 years ago)
- Last Synced: 2025-03-02T01:07:49.770Z (over 1 year ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SolarNetwork Aggregate Query Tool
This is a small node utility that can export SolarNetwork data as CSV,
aggregated by date. The tool will query SolarNetwork for data based
on the provided arguments, and then combine all result rows that
occur on the same date into a single aggregate sum result for that
date.
For example, if a raw query were to return data like
```csv
created,nodeId,sourceId,wattHours
"2017-01-01 00:00:00.000Z",123,"A",1000.0
"2017-01-01 00:00:00.000Z",123,"B",555.0
```
this tool would combine those two rows because they have the same
`created` value into a single row like this:
```csv
created,nodeId,wattHours
"2017-01-01 00:00:00.000Z",123,1555.0
```
Notice the `wattHours` value is the aggregate sum of the two raw
records.
# Usage
```
Usage: node sn-agg-query.js [OPTION] [query]
Combine query results by date, adding their values together.
Alternatively, can output the raw data without aggregation.
-r, --raw output raw, unaggregated results
-n, --node=ID the node ID
-p, --source=ID+ a source ID (can be provided more than once)
-s, --start=DATE the starting date, as yyyy-MM-dd HH:mm
-e, --end=DATE the ending date, as yyyy-MM-dd HH:mm
-a, --aggregation=AGG the aggregate level, e.g. Hour
-h, --help show this help
```
Note that multiple `source` arguments may be provided, for example
node sn-agg-query.js --node=123 --source=A --source=B ...
# Development
This tool was created as a demonstration of using the [SolarNetwork API
Core][core] and [SolarNetwork Datum Loader][loader] packages.
[core]: https://github.com/SolarNetwork/sn-api-core-js
[loader]: https://github.com/SolarNetwork/sn-datum-loader-js