Commit Graph

29 Commits

Author SHA1 Message Date
b07bb73da4
Fix clippy issue
All checks were successful
Check
Lints
2023-03-21 12:10:52 +01:00
b1764b7fe3
Use 7 chars for the git SHA 2023-01-29 15:44:29 +01:00
04e28a33c3
Add a /version API endpoint
* Introduce the `VersionInfo` struct, build from the vergen environment
  variables
* Add the `version` handler to construct and return the version info
* Update the README
2023-01-29 15:29:32 +01:00
de1ad37b95
Use the vergen crate to generate version information
* Add depend on the `vergen` crate (only use the `build` and `git`
  features)
* Add the build script `build.rs` to setup the environment variables
  from the build system
* Update the printed version information to use these environment
  variables
2023-01-29 15:22:47 +01:00
5cbc3a04fc
Print the version on lift off 2023-01-16 21:18:20 +01:00
ca116351db
Implement error catchers for all requests (closes: #5)
* Introduce an error JSON output
* Return error JSON output if the status data is not there (yet)
* Introduce a default catcher to return error JSON output in all other
  unsupported/unhandled cases
* Update the documentation
2023-01-16 21:08:03 +01:00
8d892d8619
Tweak documentation (to look like the rest) 2023-01-16 21:05:15 +01:00
e6b0357670
Add serde from rocket; drop depend on serde 2023-01-16 20:07:56 +01:00
365b847313
Use stderr and a different emoji for error log messages 2023-01-16 20:03:16 +01:00
e1d70e8a59
Catch and raise when API response data cannot be deserialized
* Introduce a `StringOrObject::Value` variant that captures the
  undeserializable JSON value
* Generate an error with the undeserializable JSON value when
  deserialization is attempted
2023-01-16 20:00:53 +01:00
e268a6ebca
Detect when API (login) responses are not correct
* Introduce the `Error::Response` variant so services can raise errors
  if the API response are not valid but a relogin will not help
* Indicate that a login failed for status (error) code 1
* Indicate that an API request failed and relogin is necessary for
  status code 1 or 100
* Raise an error on any non-zero status code otherwise with the message
2023-01-16 19:57:05 +01:00
93e8295c96
Small formatting and error message fixes 2023-01-15 16:44:45 +01:00
1d35b88aba
Set a cookie to configure the API language
It will be Simplified Chinese (`zh_cn`) otherwise.
2023-01-15 16:34:40 +01:00
ddcb375345
Introduce an error type for services
As a result, services don't always have to provide a `reqwest::Error`
but also return other errors. The error variant `Error::NotAuthorized`
in particular specifies that requests are not or no longer allowed and a
login should be (re)attempted. This way, services can indicate that it
is in this state and not have to provided a 403 status code
`reqwest::Error` to show this.

Add a depend on the `thiserror` crate for this.
2023-01-15 16:31:37 +01:00
e0151c3cde
Set last updated field to what is returned by API
In Hoymiles, the date of the last update is part of the API response.
Parse it and use that in `Status` instead of the timestamp provided by
the update loop.

Add a depend on the `chrono` crate for this.
2023-01-15 14:48:24 +01:00
ef13f7e4f2
Update documentation about Hoymiles poll interval 2023-01-15 14:16:11 +01:00
d787c8b3ab
Fix issue in Hoymiles where total energy decreases
Sometimes it can be that `today_eq` is reset when the day switches but
it has not been added to `total_eq` yet. The `total_eq` should always be
non-decreasing, so return the last known value until this is corrected
(this most suredly happens during the night).

Also, allow for `login` and `update` to mutate the state of the service
to be able to update things like the last known total produced energy
value.
2023-01-15 13:41:40 +01:00
5a2889a0f2
Improve deserialization for Hoymiles
* Also deserialize the status (error) code and message
* Handle `data` fields having the value `""` in API responses if there
  is an error
* Add missing documentation for API struct fields
2023-01-15 13:23:34 +01:00
18b52cd422
Small simplification; remove already solved TODO 2023-01-15 12:26:20 +01:00
2b5a64b6b0
FIx some formatting 2023-01-14 15:54:29 +01:00
01416ee136
Reduce poll interval for Hoymiles to 5 minutes 2023-01-14 13:03:26 +01:00
669c9285ad
Update code styling to follow Hoymiles service 2023-01-10 15:51:53 +01:00
b1dfea651f
Add first version of the Hoymiles service 2023-01-10 15:38:24 +01:00
2883f52249
Switch to floats for the current power and total energy fields 2023-01-10 15:37:38 +01:00
093d062dd4
Enable more lints 2023-01-09 21:40:04 +01:00
55c3b91bbd
Split off a library crate 2023-01-09 21:39:11 +01:00
3690647c76 Add service-specific configuration
Switch to a section/table for the service to make it easier.
2023-01-09 21:25:35 +01:00
87394f9fb9 Add service implementation; split off My Autarco support 2023-01-09 21:23:43 +01:00
5bf7f5d8de Initial import into Git
This project is based on [Autarco
Scraper](https://git.luon.net/paul/autarco-scraper) but will support
multiple services, not just My Autarco.
2023-01-08 15:39:14 +01:00