Controlling LIRC From the Web

In this post I will cover how to create a web interface + API for LIRC, the Linux Infrared Remote Control project. I will be using NodeJS and a RaspberryPi in this post, but the ideas generalize to other languages and hardware. This post will serve as Part 3 of my open source universal remote project posts. If you haven’t had an opportunity to read the first two posts, I suggest checking out Universal remote experiments (Part 1) and Setting up LIRC on the RaspberryPi (Part 2) before proceeding. You may also want to read Installing NodeJS on your RaspberryPi, where I cover installing NodeJS.

If you’re completely new to the RaspberryPi and want to learn more I wrote a RaspberryPi Quickstart post which covers everything from purchasing the parts to configuring the WiFi. Check that out if you’re new to the RaspberryPi ecosystem.

With that out of the way, let’s get started!Controlling LIRC From the Web

Why a web interface + API?

LIRC is an awesome open source project that handles all of the low level requirements of sending and receiving Infrared commands from a Linux computer. It’s well documented, well supported, and thanks to the work of the open source community there is now a lirc_rpi driver included in the latest version of RaspbianOS. This means that, as long as you’re running a RaspberryPi with the latest OS and firmware, LIRC can interface with the RaspberryPi GPIO pins. Fantastic.

Once you have LIRC installed and configured (which I cover in my Setting up LIRC on the RaspberryPi post), you can use LIRC executables like irsend and irrecord to send and record IR commands for all your IR devices – right from the command line! This is great fun, but not very user friendly.

I wanted a way to control LIRC from the web. I wanted a web application that enabled me to interact with LIRC from any web connected device. If I had that, I could create a mobile web app for my phone, a regular web app for a desktop, and a RESTful API for web services. The API would give me a way to connect LIRC with any external web service – opening the door for future integrations. All I needed to do was find a way to call LIRC commands from within a web application.

Which brings us to the meat of this post. Getting NodeJS and LIRC to talk.

Getting LIRC and NodeJS to talk

To make LIRC usable from the web I needed a client library in a language I could build a web application in. The client library would provide some way to make calls from the web application to LIRC. This would give me the building blocks I needed to build a web application. The usual web languages include PHP, Python, Ruby, and NodeJS.

For this project I chose to work in NodeJS. If you would prefer to implement a web application in a different language, I found two existing LIRC client libraries. Sadly, neither seem maintained. I found lircr for Ruby and pyLirc for Python.

Since I could not find an existing NodeJS LIRC client library, and the existing libraries I did find were not up to date, I built my own. I created lirc_node, a lightweight NodeJS client library that interfaces with LIRC. v0.0.1 of lirc_node only supports irsend. This allows you to send IR commands to devices that LIRC knows about.

Before trying to install and use lirc_node make sure you have completed these steps:

  • Purchased, setup, and configured a RaspberryPi to join a network
  • Wired up an IR LED and an IR Receiver to your RaspberryPi
  • Installed and configured LIRC to interface with your IR LED and IR Receiver
  • Programmed LIRC to understand your remote controls
  • Installed NodeJS on your RaspberryPi

If you have not completed all of those steps scroll back to the top of this post and check out my earlier posts. I have written detailed step by step guides to get you through each of those steps.

All caught up? Great! We’re ready to install a basic web application for LIRC.Controlling LIRC From the Web Schematic

Creating a NodeJS web application using lirc_node and lirc_web

The easiest way to setup a NodeJS web application using lirc_node is to use v0.0.1 of lirc_web, a sample NodeJS application I wrote as a proof of concept for lirc_node. This web application is extremely basic, and only proves that lirc_node works. I have plans to grow this application with additional functionality and an improved interface. You may also use the basic API included in this web application to connect your universal remote with services like Tasker or IFTTT.

January 17th 2015 Update: lirc_web is now at v0.0.8 and contains bugfixes and additional functionality. The user interface has been improved since v0.0.1, as well.

 

For more detail: Controlling LIRC From the Web

Scroll to Top
Scroll to Top
Read previous post:
Raspberry Pi B+ Getting Started Guide

This is a tutorial on getting started with raspberry pi b+ model.If you like it please vote and follow Step...

Close