Commit Graph

63 Commits

Author SHA1 Message Date
Paul van Tilburg c070877384
Bump the version to 0.3.0
Check, Test and Lint Using Cargo / Lints (push) Successful in 3m8s Details
Check, Test and Lint Using Cargo / Check (push) Successful in 2m39s Details
2023-04-15 12:16:30 +02:00
Paul van Tilburg 732d4b83f2
Update the changelog 2023-04-15 12:15:40 +02:00
Paul van Tilburg 12a797baa9
Cargo update
Check, Test and Lint Using Cargo / Check (push) Successful in 2m53s Details
Check, Test and Lint Using Cargo / Lints (push) Successful in 3m3s Details
2023-04-14 23:26:07 +02:00
Paul van Tilburg 5586ae4d70
Update build dependecy on the vergen crate to 8.1.1
This change allows for dropping the dependency on the `anyhow` crate.
2023-04-14 23:25:25 +02:00
Paul van Tilburg 59e3b53263
Implement backoff for login/update API calls (closes: #8)
Check, Test and Lint Using Cargo / Check (push) Successful in 3m45s Details
Check, Test and Lint Using Cargo / Lints (push) Successful in 3m35s Details
Start from an interval of 10 seconds, increase with a factor of 2.0 on
each failure up to a maximum of 320 seconds.

This commit also fixes an issue where the update loop would be aborted
if a relogin fails.
2023-04-14 23:02:21 +02:00
Paul van Tilburg f236499125
Fix login errors not being detected 2023-04-14 22:54:54 +02:00
Paul van Tilburg 02a4d1ca9b
Update to Rocket 0.5.0-rc.3
Check Details
Lints Details
2023-03-24 14:38:42 +01:00
Paul van Tilburg 3fff79a2cd
Fix missing build script/git repo during build
Check Details
Lints Details
When building the dependencies, the build script should not be
considered. When building the actual binary, the git repository needs to
be present and the build script should be run.
2023-03-22 15:27:12 +01:00
Paul van Tilburg 9200a10cef
Speed up build by using sparse Cargo index for crates.io 2023-03-22 15:26:45 +01:00
Paul van Tilburg beb49373fb
Bump the version to 0.2.2
Check Details
Lints Details
2023-03-22 15:00:35 +01:00
Paul van Tilburg 99e7e8a68c
Update the changelog 2023-03-22 14:59:18 +01:00
Paul van Tilburg bab9228b0f
Drop unused dependency on the toml crate 2023-03-22 13:38:16 +01:00
Paul van Tilburg 81e82e90da
Cargo update; fixes RUSTSEC-2023-0018 2023-03-22 13:37:56 +01:00
Paul van Tilburg b07bb73da4
Fix clippy issue
Check Details
Lints Details
2023-03-21 12:10:52 +01:00
Paul van Tilburg 58759d5309
Add Gitea Actions workflow for cargo
Check Details
Lints Details
2023-03-21 11:53:05 +01:00
Paul van Tilburg b1764b7fe3
Use 7 chars for the git SHA 2023-01-29 15:44:29 +01:00
Paul van Tilburg 7c704b69ed Merge pull request 'Print the version on lift off and add version endpoint' (#10) from 6-print-version-add-endpoint into main
Reviewed-on: #10
2023-01-29 15:37:14 +01:00
Paul van Tilburg 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
Paul van Tilburg 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
Paul van Tilburg 5cbc3a04fc
Print the version on lift off 2023-01-16 21:18:20 +01:00
Paul van Tilburg 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
Paul van Tilburg 8d892d8619
Tweak documentation (to look like the rest) 2023-01-16 21:05:15 +01:00
Paul van Tilburg 35209b6303
Bump the version to 0.2.1 2023-01-16 20:16:30 +01:00
Paul van Tilburg 6707928e37
Update the changelog 2023-01-16 20:15:54 +01:00
Paul van Tilburg e6b0357670
Add serde from rocket; drop depend on serde 2023-01-16 20:07:56 +01:00
Paul van Tilburg 365b847313
Use stderr and a different emoji for error log messages 2023-01-16 20:03:16 +01:00
Paul van Tilburg 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
Paul van Tilburg 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
Paul van Tilburg 93e8295c96
Small formatting and error message fixes 2023-01-15 16:44:45 +01:00
Paul van Tilburg 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
Paul van Tilburg 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
Paul van Tilburg 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
Paul van Tilburg ef13f7e4f2
Update documentation about Hoymiles poll interval 2023-01-15 14:16:11 +01:00
Paul van Tilburg 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
Paul van Tilburg 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
Paul van Tilburg 18b52cd422
Small simplification; remove already solved TODO 2023-01-15 12:26:20 +01:00
Paul van Tilburg 70b117d11d
Cargo update 2023-01-14 15:55:48 +01:00
Paul van Tilburg 2b5a64b6b0
FIx some formatting 2023-01-14 15:54:29 +01:00
Paul van Tilburg 01416ee136
Reduce poll interval for Hoymiles to 5 minutes 2023-01-14 13:03:26 +01:00
Paul van Tilburg 536b1564b9
Also set the state class in HA sensors example 2023-01-13 23:22:41 +01:00
Paul van Tilburg 4088c37cd2
Bump the version to 0.2.0 2023-01-13 19:47:14 +01:00
Paul van Tilburg 17491fad78
Update the changelog 2023-01-13 19:33:09 +01:00
Paul van Tilburg 745edea875
Clarify config necessary for exposing container port
If Rocket is not configured to listen on 0.0.0.0:8000, exposing port
8000 on the inside to a chosen port (2399 by default), will not work.
2023-01-13 11:57:24 +01:00
Paul van Tilburg f6a3820961
Fix typo in Docker commands 2023-01-11 21:59:47 +01:00
Paul van Tilburg 5733a6440c
Fix (example) port in HA example 2023-01-11 21:58:33 +01:00
Paul van Tilburg 11d82c4ae4
Add a changelog 2023-01-11 21:55:04 +01:00
Paul van Tilburg 1c2fc62805
Add documentation for how to use with Home Assistant 2023-01-10 17:13:52 +01:00
Paul van Tilburg 4bdaa3bdac
Switch the example port to 2399 2023-01-10 17:00:20 +01:00
Paul van Tilburg 69f34e3243
Add Debian packaging via cargo-deb (closes: #4)
* Add the required metadata to `Cargo.toml`
* Add a systemd service unit file
* Use `Rocket.toml.example` as the default configuration
2023-01-10 16:59:20 +01:00
Paul van Tilburg a0cb3dccae
Document the Docker support 2023-01-10 16:29:32 +01:00