Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/optical/flickelectricsharp
A C# library for accessing basic information from flickelectric.co.nz
https://github.com/optical/flickelectricsharp
api csharp dotnet dotnetcore flick flickelectric
Last synced: 24 days ago
JSON representation
A C# library for accessing basic information from flickelectric.co.nz
- Host: GitHub
- URL: https://github.com/optical/flickelectricsharp
- Owner: optical
- License: mit
- Created: 2018-05-15T10:21:30.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-14T02:45:12.000Z (over 6 years ago)
- Last Synced: 2024-12-14T10:16:57.716Z (about 1 month ago)
- Topics: api, csharp, dotnet, dotnetcore, flick, flickelectric
- Language: C#
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# FlickElectricSharp [![Build Status](https://travis-ci.org/optical/FlickElectricSharp.svg?branch=master)](https://travis-ci.org/optical/FlickElectricSharp) [![Build status](https://ci.appveyor.com/api/projects/status/9x0eoknwn9tywgua?svg=true)](https://ci.appveyor.com/project/optical/flickelectricsharp) [![NuGet Package](https://img.shields.io/nuget/v/FlickElectricSharp.svg)](https://www.nuget.org/packages/FlickElectricSharp/)
A simple, unofficial .NET client for accessing current [FlickElectric](https://flickelectric.co.nz) prices, along with historic data
## Installation
Available on [Nuget](https://www.nuget.org/packages/FlickElectricSharp/)
```
Install-Package FlickElectricSharp -Version 0.2.0
```## Usage
There are 2 main classes for accessing the Flick API's. One corresponds to their web api for exporting historic usage data, while the other uses their Android APP api to poll for current and predicted future pricing.See the Flick2Influx project for an example application which queries the API and stores the results in InfluxDB.
### FlickAndroidClient
Provides access to the current flick prices```
var client = new FlickAndroidClient("username", "password");
// Get our user details
var userInfo = await client.GetUserInfo();// Get current + forecast prices
var forecastPrices = await client.GetPriceForecast(userInfo.AuthorizedDataContexts.SupplyNodes[0]);// Of all the forecasts, choose the current one.
var currentPredictedPrice = forecastPrices.Prices.MinBy(price => price.StartsAt);// Details about how much the spot price is, along with retailer fees, line fees, etc that make up the total price
foreach (var priceComponent in currentPredictedPrice.Components) {
Console.WriteLine($"Component {priceComponent.ChargeSetter}_{priceComponent.ChargeMethod}: {priceComponent.Value}");
}// Simply output the total price
Console.WriteLine($"Total price: currentPredictedPrice.Price.Value")
```### FlickWebClient
Provides access to your historic usage data, via the flick website.
```
var client = new FlickWebClient("username", "password");// Historic usage only, no pricing
var powerUsageData = await client.GetPowerUsage(DateTime.Now - Timespan.FromDays(7), DateTime.Now - TimeSpan.FromDays(1));foreach (var bucket in powerUsageData) {
Console.WriteLine($"ICP Number: {bucket.IcpNumber");
Console.WriteLine($"Meter Serial Number: {bucket.MeterSerialNumber");
Console.WriteLine($"ChannelNumber: {bucket.ChannelNumber");
Console.WriteLine($"StartedAt: {bucket.StartedAt");
Console.WriteLine($"EndedAt: {bucket.EndedAt");
Console.WriteLine($"Value: {bucket.Value");
Console.WriteLine($"UnitCode: {bucket.UnitCode");
Console.WriteLine($"Status: {bucket.Status");
}var pricesAndUsage = await client.FetchDetailedUsageForDay(DateTime.Now.AddDays(-3));
foreach (var usageBucket in pricesAndUsage) {
Console.WriteLine($"Between {usageBucket.Start}-{usageBucket.End} the price of power was {usageBucket.Price} and you used {usageBucket.Units}kWh");
}```
## Disclaimer
Access to this data is via Flicks public API's used by its Android App and Website. They're likely to break whenever a significant update is made by Flick. This library rough around the edges and not production ready, but you may find it useful for hobbyist projects