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
                    
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="Tomidix.Dirigera" Version="2.0.1.54" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tomidix.Dirigera" Version="2.0.1.54" />
                    
Directory.Packages.props
<PackageReference Include="Tomidix.Dirigera" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Tomidix.Dirigera --version 2.0.1.54
                    
#r "nuget: Tomidix.Dirigera, 2.0.1.54"
                    
#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.
#:package Tomidix.Dirigera@2.0.1.54
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Tomidix.Dirigera&version=2.0.1.54
                    
Install as a Cake Addin
#tool nuget:?package=Tomidix.Dirigera&version=2.0.1.54
                    
Install as a Cake Tool

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.

GitHub last commit NuGet downloads

This library is still in development, latest version:

NuGet downloads

Preview build notice: version 1.1.0-preview.1 builds against an unreleased ApiLibs commit (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

Tomidix.Dirigera

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 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. 
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
2.0.1.54 0 11/6/2026
2.0.1.52 0 11/6/2026 2.0.1.52 is deprecated because it is no longer maintained.
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