Skip to content

jpmikkers/Baksteen.Net.LIRC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Baksteen.Net.LIRC

This library enables your .NET application to send and receive infrared remote control commands. This means it can control other devices via IR commands, or have your application be controlled by an IR remote.

It works by connecting to a local (via unix domain socket) or remote (via tcp-ip) LIRC daemon, implementing the protocol described at https://lirc.org/html/lircd.html . The LIRC daemon itself typically runs on a cheap single board computer (e.g. a raspberry pi) that can send/receive IR signals with a little bit of hardware.

Some usecases could be:

  • create IR controlled robot using csharp/dotnet.
  • create a multiroom IR repeater
  • create an universal remote control application
  • hook up 'dumb' climate control into a custom home automation system

LIRCTest

The project includes a user interface built using AvaloniaUI, so it will run on Linux and Windows (and probably Apple Mac). It displays all the available remotes and buttons of a LIRC daemon and allows you to test sending and receiving IR commands.

Screen.Recording.2024-07-02.011313.mp4

Library usage

    using System.Net;
    using Baksteen.Net.LIRC;

    // create and connect client
    await using var client = await LIRCClient.Connect(
        new UnixDomainSocketEndPoint("/var/run/lirc/lircd"),
        new LIRCClientSettings
        {
            // hook up event to receive remote control commands
            OnLIRCEventAsync = async ev =>
            {
                Console.WriteLine($"event: {ev}");
                await Task.CompletedTask;
            }       
        }
    );

    // alternatively: to connect to remote LIRC daemon over TCP
    // ... new IPEndPoint(IPAddress.Parse("192.168.1.220"), 8765))

    // list available remote controls
    var remoteControls = await client.ListRemoteControls();

    foreach(var remoteControl in remoteControls)
    {
        Console.WriteLine(remoteControl);
    }

    // list available remote control keys for a specific remote
    var remoteControlKeys = await client.ListRemoteControlKeys("samsung");

    foreach(var remoteControlKey in remoteControlKeys)
    {
        Console.WriteLine(remoteControlKey);
    }

    // send IR command, no repeats
    await client.SendOnce("samsung", "POWER_ON" ,0);

How to set up LIRC hardware and software on linux

To set up LIRC on linux on raspberry pi, I used the following guides and sites:

Supported IR remote controls configuration files (.lircd.conf) can be found here: https://lirc-remotes.sourceforge.net/remotes-table.html