Skip to content

Client implementation for parts of the Blue Riiot pool sensor API

Notifications You must be signed in to change notification settings

LordMike/MBW.Client.BlueRiiotApi

Repository files navigation

MBW.Client.BlueRiiotAPI

Generic Build Nuget

Reverse engineered client library for Blue Riiots pool API.

Basic usage

var bc = new BlueClientBuilder()
    .UseUsernamePassword("user", "pass")
    .Build();

var pools = await bc.GetSwimmingPools();

Using an HTTP Client Factory

var bc = new BlueClientBuilder()
    .UseHttpClientFactory(myFactory)
    ...

Using an HTTP proxy

var bc = new BlueClientBuilder()
    // Add a special HttpClient to control the proxy
    .UseHttpClient(new HttpClient(new SocketsHttpHandler
    {
        // Set a proxy if available. Suggestion: Fiddler.
        Proxy = new WebProxy(new Uri("http://127.0.0.1:8888"))
    }))
    ...

Using Microsoft DI

services
    // Note: the AddHttpClient() call is not necessary, but it is possibly to again configure the client here
    .AddHttpClient("blueriiot")
    .AddBlueRiiot((provider, builder) =>
    {
        IHttpClientFactory httpFactory = provider.GetRequiredService<IHttpClientFactory>();

        // Set required options on the BlueClientBuilder
        builder
            .UseUsernamePassword(config.Username, config.Password)
            // Only necessary if a special HttpClientFactory name is needed
            .UseHttpClientFactory(httpFactory, "blueriiot"); 
    })

// Usage
var bc = serviceProvider.GetService<BlueClient>();
var pools = await bc.GetSwimmingPools();

Note on logging

The library uses Microsofts logging extensions. It is possible to log all requests (and responses), by enabling Trace logging for MBW.Client.BlueRiiotApi.BlueClient.

services.AddLogging(builder =>
{
    builder.AddFilter("MBW.Client.BlueRiiotApi.BlueClient", LogLevel.Trace);
});

About

Client implementation for parts of the Blue Riiot pool sensor API

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages