Skip to content

A C# library for accessing basic information from flickelectric.co.nz

License

Notifications You must be signed in to change notification settings

optical/FlickElectricSharp

Repository files navigation

FlickElectricSharp Build Status Build status NuGet Package

A simple, unofficial .NET client for accessing current FlickElectric prices, along with historic data

Installation

Available on Nuget

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

About

A C# library for accessing basic information from flickelectric.co.nz

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages