Homebridge IR Blaster

Homebridge IR Blaster

I have recently got into home automation, but I did not want to replace all of my home equipment with OEM approved and certified devices. It seems like a waste of perfectly good equipment and some things can't be bought in any case that are compatible. So I turned to homebridge.
Homebridge is a framework written in NodeJS that provides a server compatible with Apple's homekit that users can write custom plugins to interface with literally anything that can be controlled by a computer.
The server itself presents itself as a bridge device as, used by manufacturer's product ecosystems to expose control of their products to homekit devices. A homekit bridge in a sense acts like a router to these devices. Devices are exposed on the bridge in two ways:

  1. Accessory
  2. Platform

An accessory is a single device with a single set of controls. In the Home app the controls associated with it may only be assigned to a single room. For example a smart thermostat.
A platform is conceptially multiple accessories that will have their own controls. This for example could be smart lights that occupy different rooms.

function irblast(log, config, api) {
    let platform = this;

    this.log = log;
    this.config = config;
    this.accessories = {};

    lirc.on('connect', () => {
        lirc.send('VERSION').then(res => {
            log("LIRC Version" + res);
        });
    });

    var remotes = lirc.list().then( (remotes) => {
        remotes.forEach((remote, index) => {
            //platform.log(remote);
            platform.addAccessory(remote);
        });
    });

    if(api) {
        this.api = api;

        this.api.on('didFinishLaunching', function() {}.bind(this));
    }
}