Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View fredericbarthelet's full-sized avatar

Frédéric Barthelet fredericbarthelet

View GitHub Profile
const request = require(‘request’);
const url = require(‘url’);
function mySwitch(log, config) {
 this.log = log;
 this.getUrl = url.parse(config[‘getUrl’]);
 this.postUrl = url.parse(config[‘postUrl’]);
}
mySwitch.prototype = {
getSwitchOnCharacteristic: function (next) {
 const me = this;
mySwitch.prototype = {
 getServices: function () {
 let informationService = new Service.AccessoryInformation();
 informationService
 .setCharacteristic(Characteristic.Manufacturer, “My switch manufacturer”)
 .setCharacteristic(Characteristic.Model, “My switch model”)
 .setCharacteristic(Characteristic.SerialNumber, “123–456–789”);
let switchService = new Service.Switch(“My switch”);
 switchService
 .getCharacteristic(Characteristic.On)
const Service, Characteristic;
module.exports = function (homebridge) {
 Service = homebridge.hap.Service;
 Characteristic = homebridge.hap.Characteristic;
 homebridge.registerAccessory(“switch-plugin”, “MyAwesomeSwitch”, mySwitch);
};