Tomidix.Dirigera
2.0.1.54
dotnet add package Tomidix.Dirigera --version 2.0.1.54
NuGet\Install-Package Tomidix.Dirigera -Version 2.0.1.54
<PackageReference Include="Tomidix.Dirigera" Version="2.0.1.54" />
<PackageVersion Include="Tomidix.Dirigera" Version="2.0.1.54" />
<PackageReference Include="Tomidix.Dirigera" />
paket add Tomidix.Dirigera --version 2.0.1.54
#r "nuget: Tomidix.Dirigera, 2.0.1.54"
#:package Tomidix.Dirigera@2.0.1.54
#addin nuget:?package=Tomidix.Dirigera&version=2.0.1.54
#tool nuget:?package=Tomidix.Dirigera&version=2.0.1.54
C# Tradfri Library
This is a .NET 10 library to communicate with the IKEA Dirigera Hub (Dirigera) smart home Gateway. Using this library you can, by communicating with the gateway, control devices.
This library is still in development, latest version:
Preview build notice: version
1.1.0-preview.1builds against an unreleasedApiLibscommit (pulled in as a git submodule, see Building from source below) and is not yet pushed to the public NuGet feed. See the CHANGELOG for details.
- Get information on the Dirigera hub and its users
- List and control devices: lights (on/off, dimming, color temperature), outlets, and dimmable lights
- Read sensor data from environment sensors, motion sensors, light sensors and water sensors, including the CO2 attribute
- Subscribe to real-time device updates over the Dirigera websocket (
EventController), with automatic keep-alive ping/pong handling - Automatic retries when changing device attributes
Nuget
1. Usage
Download the NuGet package. You will need:
- hostUrl the IP address of your Dirigera hub (just the IP, e.g.
192.168.0.123, no scheme). - accessToken a token obtained once via the pairing flow below. Store it (e.g. in your app settings) and reuse it on every subsequent connection — pairing again is only needed if the token is lost or revoked.
Pairing (first connection only)
Dirigera requires a PKCE-style pairing flow where you must physically press the action button on the bottom of the hub while the code exchange is in progress:
using Tomidix.NetStandard.Dirigera.Controller;
var controller = new DirigeraController(hostUrl); // e.g. "192.168.0.123"
string codeVerifier = DirigeraController.generateCodeVerifier();
string challenge = DirigeraController.calculateCodeChallenge(codeVerifier);
string dirigeraCode = (await controller.Authorize(challenge)).Code;
// Press the action button on the bottom of the Dirigera hub now,
// then exchange the code for an access token (may need a couple of retries
// while you reach for the button).
string accessToken = (await controller.Pair(dirigeraCode, codeVerifier, "MyApplicationName")).AccessToken;
// Persist accessToken and reuse it from now on, see below.
See TradfriTerminalUI/Program.cs for a complete, interactive reference implementation of this flow.
2. Example
Once you have an access token, reconnect with it directly:
using Tomidix.NetStandard.Dirigera.Controller;
using Tomidix.NetStandard.Dirigera.Model.Devices;
var controller = new DirigeraController(hostUrl, accessToken);
var me = await controller.UserController.GetMe();
var devices = await controller.DeviceController.GetDevices();
foreach (var device in devices)
{
switch (device)
{
case Light light:
await controller.DeviceController.Toggle(light);
await controller.DeviceController.SetLightLevel(light, 75);
break;
case Outlet outlet:
await controller.DeviceController.Toggle(outlet);
break;
case MotionSensor motionSensor:
await controller.DeviceController.SetMotionDetectedDelay(motionSensor, 60);
break;
}
}
// Subscribe to real-time updates (lights turned on/off elsewhere, sensors triggering, etc.)
controller.EventController.OnEventSent += (sender, e) =>
{
Console.WriteLine($"Received event: {e.Event}");
};
await controller.EventController.Connect(CancellationToken.None);
3. Building from source
This project currently depends on an ApiLibs commit that has not been published to NuGet yet, so it is referenced as a git submodule rather than a plain package reference. Clone (or update) the repository with submodules initialized before building:
git submodule update --init --recursive
4. Acknowledgements
This is an implementation based on analysis I found here by ggravlingen and here by vidarlo.
The Dirigera implementation is based on this Java implementation and this Node implementation.
5. Authors
- mjwsteenbergen - Initial work, device/event model, sensor & outlet support
- tomidix - setup of build procedures, nuget package publish
6. Changelog
You can check the changelog here.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- ApiLibs (>= 3.0.0)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.0)
- Newtonsoft.Json (>= 13.0.3)
- RestSharp (>= 114.0.0)
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 | |
|---|---|---|---|
| 2.0.1.54 | 0 | 11/6/2026 | |
| 2.0.1.52 | 0 | 11/6/2026 | |
| 1.1.0-preview.48 | 102 | 8/6/2026 | |
| 1.0.1.46 | 338 | 7/7/2024 | |
| 1.0.1.44 | 247 | 7/7/2024 |