homebridge-syntex-magichome
Advanced tools
Comparing version 1.0.0-b24 to 1.0.0-b25
{ | ||
"name": "homebridge-syntex-magichome", | ||
"version": "1.0.0-b24", | ||
"version": "1.0.0-b25", | ||
"description": "Homebridge Plugin for MagicHome LED Strips with preset scenes", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,70 +0,79 @@ | ||
// | ||
// base.js | ||
// Sahil Chaddha | ||
// | ||
// Created by Sahil Chaddha on 13/08/2018. | ||
// Copyright © 2018 sahilchaddha.com. All rights reserved. | ||
// | ||
const cp = require('child_process'); | ||
const path = require('path'); | ||
const lightAgent = require('../lib/lightAgent'); | ||
const cp = require('child_process') | ||
const path = require('path') | ||
const lightAgent = require('../lib/lightAgent') | ||
const Accessory = class | ||
{ | ||
constructor(config, log, homebridge) | ||
{ | ||
this.homebridge = homebridge; | ||
this.log = log; | ||
this.config = config; | ||
this.name = config.name; | ||
this.services = this.getAccessoryServices(); | ||
const Accessory = class { | ||
constructor(config, log, homebridge) { | ||
this.homebridge = homebridge | ||
this.log = log | ||
this.config = config | ||
this.name = config.name | ||
this.services = this.getAccessoryServices() | ||
this.services.push(this.getInformationService()) | ||
} | ||
this.services.push(this.getInformationService()); | ||
} | ||
identify(callback) { | ||
callback() | ||
} | ||
identify(callback) | ||
{ | ||
callback(); | ||
} | ||
getInformationService() { | ||
var informationService = new this.homebridge.Service.AccessoryInformation() | ||
informationService | ||
.setCharacteristic(this.homebridge.Characteristic.Manufacturer, 'SynTex MagicHome') | ||
.setCharacteristic(this.homebridge.Characteristic.Model, this.getModelName()) | ||
.setCharacteristic(this.homebridge.Characteristic.SerialNumber, this.getSerialNumber()) | ||
return informationService | ||
} | ||
getInformationService() | ||
{ | ||
var informationService = new this.homebridge.Service.AccessoryInformation(); | ||
executeCommand(address, command, callback) { | ||
const exec = cp.exec | ||
const self = this | ||
const cmd = path.join(__dirname, '../flux_led.py ' + lightAgent.getAddress(address) + command) | ||
if (self.homebridge.debug) { | ||
self.log(cmd) | ||
} | ||
exec(cmd, (err, stdOut) => { | ||
if (self.homebridge.debug) { | ||
self.log(stdOut) | ||
} | ||
if (callback) { | ||
callback(err, stdOut) | ||
} | ||
}) | ||
} | ||
informationService.setCharacteristic(this.homebridge.Characteristic.Manufacturer, 'MagicHome') | ||
.setCharacteristic(this.homebridge.Characteristic.Model, this.getModelName()) | ||
.setCharacteristic(this.homebridge.Characteristic.SerialNumber, this.getSerialNumber()); | ||
getAccessoryServices() { | ||
throw new Error('The getSystemServices method must be overridden.') | ||
} | ||
return informationService; | ||
} | ||
getModelName() { | ||
throw new Error('The getModelName method must be overridden.') | ||
} | ||
executeCommand(address, command, callback) | ||
{ | ||
const exec = cp.exec; | ||
const self = this; | ||
const cmd = path.join(__dirname, '../flux_led.py ' + lightAgent.getAddress(address) + command); | ||
getSerialNumber() { | ||
throw new Error('The getSerialNumber method must be overridden.') | ||
} | ||
if(self.homebridge.debug) | ||
{ | ||
self.log(cmd); | ||
} | ||
getServices() { | ||
return this.services | ||
} | ||
exec(cmd, (err, stdOut) => { | ||
if(self.homebridge.debug) | ||
{ | ||
self.log(stdOut); | ||
} | ||
if(callback) | ||
{ | ||
callback(err, stdOut); | ||
} | ||
}); | ||
} | ||
getAccessoryServices() | ||
{ | ||
throw new Error('The getSystemServices method must be overridden.'); | ||
} | ||
getModelName() | ||
{ | ||
throw new Error('The getModelName method must be overridden.'); | ||
} | ||
getSerialNumber() | ||
{ | ||
throw new Error('The getSerialNumber method must be overridden.'); | ||
} | ||
getServices() | ||
{ | ||
return this.services; | ||
} | ||
} | ||
module.exports = Accessory | ||
module.exports = Accessory; |
@@ -1,5 +0,7 @@ | ||
const EventEmitter = require('events') | ||
const EventEmitter = require('events'); | ||
class MyEmitter extends EventEmitter { } | ||
const emitter = new MyEmitter() | ||
module.exports = emitter | ||
class MyEmitter extends EventEmitter {} | ||
const emitter = new MyEmitter(); | ||
module.exports = emitter; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
712
98709