-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add READMEs to individual projects
- Loading branch information
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.NET CLI client for retrieving n3rgy consumer data. | ||
|
||
## Installation | ||
|
||
Set the `N3RGY__APIKEY` environment variable to your In Home Display (IHD) MAC address (without hyphens). This acts as the security key for the n3rgy API, e.g. | ||
|
||
```bash | ||
set N3RGY__APIKEY="0123456789ABCDEF" | ||
``` | ||
|
||
## CLI | ||
|
||
You can retrieve consumption and tariff data using the commands below. Note that you can substitute `gas` for `electricity`: | ||
```bash | ||
n3rgy electricity consumption --start-date 2024-04-20 --end-date 2024-04-24 --output-file electricity_consumption.csv | ||
``` | ||
or | ||
```bash | ||
n3rgy electricity tariff --start-date 2024-04-20 --end-date 2024-04-24 --output-file electricity_tariff.csv | ||
``` | ||
|
||
Display inline help: | ||
```bash | ||
n3rgy --help | ||
``` |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.NET n3rgy client for retrieving data. | ||
|
||
```cs | ||
using N3rgy.Api.Client; | ||
using N3rgy.Api.Client.Authorization; | ||
|
||
// ... | ||
string GetApiKey(IServiceProvider serviceProvider) | ||
{ | ||
// Retrieve your API key from configuration: | ||
IConfiguration configuration = serviceProvider.GetRequiredService<IConfiguration>(); | ||
string? apiKey = configuration.GetValue<string>("N3RGY:APIKEY"); | ||
|
||
// validate api key is set | ||
return apiKey; | ||
} | ||
|
||
services.AddSingleton<IN3rgyAuthorizationProvider>(sp => new StaticN3rgyAuthorizationProvider(GetApiKey(sp))); | ||
services.AddSingleton<IConsumerClient>(sp => new ConsumerClient(sp.GetRequiredService<IN3rgyAuthorizationProvider>())); | ||
|
||
// You can then use the IConsumerClient to retrieve gas or electricity data: | ||
await _consumerClient.GetGasConsumption(dateRange); | ||
``` |
This file contains 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