Skip to content

Commit

Permalink
refactor: add READMEs to individual projects
Browse files Browse the repository at this point in the history
  • Loading branch information
rars committed Apr 23, 2024
1 parent 8b8def7 commit 872f025
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
10 changes: 10 additions & 0 deletions N3rgy.Api.Cli/N3rgy.Api.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
<ToolCommandName>n3rgy</ToolCommandName>
<PackageOutputPath>./nupkg</PackageOutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup>
<Description>.NET CLI for querying n3rgy API (https://www.n3rgy.com/)</Description>
<Authors>Richard Russell</Authors>
<Copyright>2024 Richard Russell</Copyright>
<RepositoryUrl>https://github.com/rars/n3rgy-dotnet</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
Expand All @@ -23,6 +32,7 @@

<ItemGroup>
<ProjectReference Include="..\N3rgy.Api.Client\N3rgy.Api.Client.csproj" />
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<PropertyGroup>
Expand Down
25 changes: 25 additions & 0 deletions N3rgy.Api.Cli/README.md
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
```
5 changes: 5 additions & 0 deletions N3rgy.Api.Client/N3rgy.Api.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -23,6 +24,10 @@
</PackageReference>
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<PropertyGroup>
<CodeAnalysisRuleSet>../StyleCop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
Expand Down
25 changes: 25 additions & 0 deletions N3rgy.Api.Client/README.md
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);
```
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,14 @@ Set the `N3RGY__APIKEY` environment variable to your In Home Display (IHD) MAC a
```
set N3RGY__APIKEY="0123456789ABCDEF"
```

## CLI

You can retrieve consumption and tariff data using the commands below. Note that you can substitute `gas` for `electricity`:
```
n3rgy electricity consumption --start-date 2024-04-20 --end-date 2024-04-24 --output-file electricity_consumption.csv
```

```
n3rgy electricity tariff --start-date 2024-04-20 --end-date 2024-04-24 --output-file electricity_tariff.csv
```

0 comments on commit 872f025

Please sign in to comment.