Rewrite electricity-logger to use an sqlite3 database

This commit is contained in:
2022-06-25 22:17:46 +02:00
parent 458d824dc8
commit 5b09b06bcf
62 changed files with 5937 additions and 3 deletions

42
docs/SOLAR_API.md Normal file
View File

@@ -0,0 +1,42 @@
# The solar-server REST API
This project depends on the `pistache` HTTP framework, see their [website](http://pistache.io/) for more info.
## Endpoints
All endpoints respond in JSON. Examples can be found in the Examples section. Dates are always in ISO format, meaning they take the shape of `year-month-day` with leading zeroes for month and day. Example: `2019-01-11` is the eleventh day of January, 2019.
- `/day?start=[yyyy-MM-dd]` This tells the server what date to serve all the collected records from the specified day.
- `/day?start=[yyyy-MM-dd]&stop=[yyyy-MM-dd]` This tells the server what date to serve the highest recorded kilowatt hour collected for each day in the specified date range. Stop date is inclusive.
- `/month?&start=[yyyy-mm]&stop=[yyyy-mm]` This returns the total kilowatthours generated for a given month. The stop month is inclusive.
## Example Response
All times are always in UTC. For these examples the current date is 25 December, 2019.
### /day?start=2019-02-15
Will give you as many objects as there are recorded values for the 15th of Febuary, 2019. Ordered from earliest to latest.
```json
[
{
"time": 1550226776,
"watt": 1456,
"kwh": 14.53
},
{
"time": 1550226834,
"watt": 1456,
"kwh": 14.54
},
...
]
```
### /month?start=2019-06&stop=2019-06
Will give you a total kilowatt hours generated for the month July, 2019. The time component is the first day of the month at 00:00 (midnight) UTC. For multiple months the result is ordered earliest to latest.
```json
[
{
"time": 1559347200,
"watt": 0,
"kwh": 451.64
}
]