Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johndryan/37fd9d8b4f0fd30c945d4b474de9537e to your computer and use it in GitHub Desktop.
Save johndryan/37fd9d8b4f0fd30c945d4b474de9537e to your computer and use it in GitHub Desktop.

RaspberryPi AC Remote using LIRC.md

I bought this Infrared Shield for my Rasberry Pi model B (running Raspian Jessie). I wanted to use it to remotely control my Frigidaire FFRE0833S1 window-mounted AC unit. Here are the steps I undertook to get it up and running.

Frigidaire WF-RG63/CE-EL-3 A/C Remote

Installating LIRC

  1. Install LIRC software (instructions here were slightly outdated)

    sudo apt-get install lirc
    
  2. System-config for LIRC. This had changed since the original instructions I had, this StackExchange post solved it for me. (My transmitter is connected to pin 17, and receiver connected to pin 18 of Raspberry Pi.)

    • Add the following line to /boot/config.txt and reboot.

      dtoverlay=lirc-rpi,gpio_out_pin=17,gpio_in_pin=18.
      
  3. Configure LIRC:

    • Edit the hardware.conf of LRIC to enable the infrared function:

      sudo nano /etc/lirc/hardware.conf
      
    • Modify the following lines (originally I had LIRCD_ARGS="--uinput --listen" but that seemed to break things!):

      LIRCD_ARGS=""
      DRIVER="default"
      DEVICE="/dev/lirc0"
      MODULES="lirc_rpi"
      
  4. Restart LIRC:

    sudo /etc/init.d/lirc stop
    sudo /etc/init.d/lirc start
    

Testing

  1. Stop LIRC software:

    sudo /etc/init.d/lirc stop
    
  2. Run the following command:

    mode2 -d /dev/lirc0
    
  3. Point any remote toward infrared shield and press any key. If we receive any information like the following, it means that the receiver function is normal.

    space 16300
    pulse 95
    space 28794
    pulse 80
    [etc]
    

Configuring for my Frigidaire AC remote

I found a ready-to-go config file here and some helpful instructions on configuring LIRC.

  1. Copy the config file to /etc/lirc/:

    sudo wget -O /etc/lirc/WF-RG63.conf "https://sourceforge.net/p/lirc-remotes/mailman/attachment/1981f5d2-fe75-e9cc-1094-a334a660ac6d%40gmail.com/1/"
    
  2. In /etc/lirc/lircd.conf, include your remote definition file. This will be the only command in the file.

    include "/etc/lirc/WF-RG63.conf"
    
  3. In /etc/lirc/hardware.conf, set REMOTE_LIRCD_CONF to the remote definition file. (I don’t think this does anything, but it doesn’t hurt.)

    REMOTE_LIRCD_CONF="/etc/lirc/WF-RG63.conf"
    
  4. Start lircd and test it with irw. Press a few of the buttons you have trained in the previous section and make sure they show up in irw. For example:

    $ sudo service lirc start
    $ irw
    0000000010af8877 00 KEY_POWER frigid
    0000000010af8877 01 KEY_POWER frigid
    

Control!

Use the following to toggle the AC unit on or off:

irsend SEND_ONCE frigid KEY_POWER

Integrating with homebridge

Homebridge can be installed via these instructions. I needed to upgrade my version, so uninstalled and did a complete reinstall. (I needed to uninstall globally: sudo npm uninstall -g homebridge)

I have homebridge running as a systems service as per this approach.

I used this homebridge plugin: homebridge-programmableswitch, with the following config file (at /var/homebridge/config.json):

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:31",
        "port": 51826,
        "pin": "031-45-154"
    },
    
    "description": "Configuration file for the Ryan apartment",

    "accessories": [
        {
            "accessory": "WeMo",
            "name": "Kitchen Lights",
            "description": "The Table Lights in the Kitchen",
            "wemo_name": "Kitchen Lights"
        },
		{
		    "accessory": "ProgrammableSwitch",
		    "name": "Air Conditioner",
		    "statefull": true,
		    "pythonScriptPath": "/usr/local/lib/node_modules/homebridge-programmableswitch/",
		    "pythonScriptName": "IRremote.py",
		    "minValue": 0,
		    "maxValue": 1,
		    "manufacturer": "Frigidaire",
		    "serialnumber": "WF-RG63",
		    "irCommands": {
				"0": [{
					"remote": "frigid",
					"key": "KEY_POWER"
				}],
				"1": [{
					"remote": "frigid",
					"key": "KEY_POWER"
				}]
		    }
		}
    ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment