LightwaveRFLinkPlusSharp 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package LightwaveRFLinkPlusSharp --version 1.0.1
NuGet\Install-Package LightwaveRFLinkPlusSharp -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LightwaveRFLinkPlusSharp" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LightwaveRFLinkPlusSharp --version 1.0.1
#r "nuget: LightwaveRFLinkPlusSharp, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install LightwaveRFLinkPlusSharp as a Cake Addin
#addin nuget:?package=LightwaveRFLinkPlusSharp&version=1.0.1

// Install LightwaveRFLinkPlusSharp as a Cake Tool
#tool nuget:?package=LightwaveRFLinkPlusSharp&version=1.0.1

LightwaveRFLinkPlusSharp

A C# binding for the LightwaveRF LinkPlus API

In order to connect to the Lightwave API you must provide a bearer ID and an initial refresh token. You can get these from https://my.lightwaverf.com > Settings > API. (The bearer ID is the long string labelled "Basic" for some reason.) During use of the API, further refresh tokens will be provided which will be handled for you automatically. If you stop being able to access the API at any point, however, you will have to request a new refresh token from the Lightwave site and provide it in this constructor.

To start using the API, first create an instance of it:

LightwaveAPI api = new LightwaveAPI("INSERT BEARER TOKEN HERE", "INSERT INITIAL REFRESH TOKEN HERE");

You can then get a list of devices present in the LinkPlus' first "structure" using the method below. This is a helper method for if your LinkPlus ecosystem only has a single structure; if you have more than one, use GetStructuresAsync and GetDevicesAsync(string) instead. See https://linkpluspublicapi.docs.apiary.io/#introduction/structure for more details about Structures.

Device[] devices = await api.GetDevicesInFirstStructureAsync();

This provides a list of devices and their features: the "switch" feature, for example, is used to control whether a device is currently switched on or not. At this stage, however, we only know what features each device supports, not the current value of each feature. We can get all the values for a device's features using PopulateFeatureValuesAsync:

Console.WriteLine($"{devices.Count()} devices discovered:");
foreach (var discoveredDevice in devices)
{
	Console.WriteLine($"\t{discoveredDevice.Name}");

	await api.PopulateFeatureValuesAsync(discoveredDevice);

	foreach (var deviceFeature in discoveredDevice.Features)
	{
		Console.WriteLine($"\t\t{deviceFeature}");
	}
}

We can also get the details for a particular device by name:

Device device = devices.First(x => x.Name == "INSERT DEVICE NAME HERE");

And then read the current value of a device's particular feature by getting the ID of the feature and then querying its value. For example, to get the value of a device's "switch" feature:

string featureId = device.GetFeatureId("switch");
int featureValue = await api.GetFeatureValueAsync(featureId);

For a lot of the feature types, however, there are helper properties that get the feature ID for you. The above query can therefore be simplified to just:

int featureValue = await api.GetFeatureValueAsync(device.SwitchFeatureId);

Note that for the older Connect devices, the LinkPlus may not know the current state if the last state change was not triggered by the app or the API, as Connect devices do not support 2-way communication. Therefore, if the device is currently switched on it may still return a value of 0

In order to change the value of a device's feature, use SetFeatureValue. For example, to turn the device on:

await api.SetFeatureValueAsync(device.SwitchFeatureId, toggledValue);

Note for some features, there are also typed helper methods for getting and setting states, for example:

bool on = await api.GetSwitchStateAsync(device);
await api.SetSwitchStateAsync(device, !on);
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.2 1,280 7/27/2020
1.1.1 641 4/4/2020
1.1.0 547 3/30/2020
1.0.5 475 2/20/2020
1.0.4 530 2/16/2020
1.0.3 512 10/9/2019
1.0.2 450 10/8/2019
1.0.1 478 10/8/2019
1.0.0 478 10/8/2019

Fixed icon