## C# Tradfri Library This is a .NET Standard (2.0) library to communicate with the IKEA Trådfri (Tradfri) ZigBee-based Gateway. Using this library you can, by communicating with the gateway, control IKEA lights (including the RGB ones).
This library is still in development, latest version:
Latest Gateway version tested and working - 1.10.43.
Download the nuget package v1.0.0.x+. You will need the following values:
From Gateway version 1.8.25 you can't use original PSK to connect to gateway anymore. You can only use it to create an application secret for your application which you can later reuse with it.
// recommended
// This line should only be called ONCE!!! per applicationName -> you define applicationName as you want
// Gateway generates one appSecret key per applicationName
TradfriAuth appSecret = controller.GenerateAppSecret("GatewaySecret", "ApplicationName");
// You should now save programatically appSecret.PSK value (appsettings) and reuse it
// when connecting to your gateway every other time
controller.ConnectAppKey(appSecret.PSK, "ApplicationName");
GatewayController gatewayController = controller.GatewayController;
var devices = await gatewayController.GetDeviceObjects();
DeviceController deviceController = controller.DeviceController;
await deviceController.SetLight(devices[0], true);
await deviceController.SetColor(devices[0], TradfriColors.SaturatedRed);
// same works for `controller.GroupController`
This is an implementation based on analysis I found here by ggravlingen and here by vidarlo.
Old library is still available as nuget (latest version: 0.3.0.22) and won't be updated anymore. You can still read it's ReadMe if you are using it but we recommend to migrate to newer library as soon as you can.
You can check the changelog here.