homebridge-syntex-dynamic-platform
Advanced tools
Comparing version 1.0.0-b3 to 1.0.0-b4
@@ -7,3 +7,8 @@ module.exports = class BaseService | ||
this.name = serviceConfig.name; | ||
this.letters = typeToLetter(serviceConfig.type) + serviceConfig.subtype; | ||
this.serviceType = serviceType; | ||
homebridgeAccessory.context = {}; // To Store Variables in Homebridge | ||
var service = homebridgeAccessory.getServiceById(serviceType, serviceConfig.subtype); | ||
@@ -24,3 +29,21 @@ | ||
} | ||
} | ||
} | ||
getService() | ||
{ | ||
return homebridgeAccessory.getServiceById(this.serviceType, this.letters[1]); | ||
} | ||
} | ||
var types = ['contact', 'motion', 'temperature', 'humidity', 'rain', 'light', 'occupancy', 'smoke', 'airquality', 'rgb', 'switch', 'relais', 'statelessswitch', 'outlet']; | ||
var letters = ['A', 'B', 'C', 'D', 'E', 'F', '0', '1', '2', '3', '4', '5', '6', '7']; | ||
function letterToType(letter) | ||
{ | ||
return types[letters.indexOf(letter.toUpperCase())]; | ||
} | ||
function typeToLetter(type) | ||
{ | ||
return letters[types.indexOf(type.toLowerCase())]; | ||
} |
const BaseService = require('./base'); | ||
let Service; | ||
let Characteristic; | ||
@@ -10,3 +9,2 @@ | ||
{ | ||
Service = manager.platform.api.hap.Service; | ||
Characteristic = manager.platform.api.hap.Characteristic; | ||
@@ -16,5 +14,3 @@ | ||
this.letters = '3' + serviceConfig.subtype; | ||
homebridgeAccessory.getServiceById(Service.Lightbulb, serviceConfig.subtype).getCharacteristic(Characteristic.On).on('get', this.getState.bind(this)).on('set', this.setState.bind(this)); | ||
this.getService().getCharacteristic(Characteristic.On).on('get', this.getState.bind(this)).on('set', this.setState.bind(this)); | ||
} | ||
@@ -21,0 +17,0 @@ |
const BaseService = require('./base'); | ||
let Service; | ||
let Characteristic; | ||
@@ -10,3 +9,2 @@ | ||
{ | ||
Service = manager.platform.api.hap.Service; | ||
Characteristic = manager.platform.api.hap.Characteristic; | ||
@@ -16,5 +14,3 @@ | ||
this.letters = '7' + serviceConfig.subtype; | ||
homebridgeAccessory.getServiceById(Service.Outlet, serviceConfig.subtype).getCharacteristic(Characteristic.On).on('get', this.getState.bind(this)).on('set', this.setState.bind(this)); | ||
this.getService().getCharacteristic(Characteristic.On).on('get', this.getState.bind(this)).on('set', this.setState.bind(this)); | ||
} | ||
@@ -21,0 +17,0 @@ |
const BaseService = require('./base'); | ||
let Service; | ||
let Characteristic; | ||
@@ -10,3 +9,2 @@ | ||
{ | ||
Service = manager.platform.api.hap.Service; | ||
Characteristic = manager.platform.api.hap.Characteristic; | ||
@@ -16,5 +14,3 @@ | ||
this.letters = '4' + serviceConfig.subtype; | ||
homebridgeAccessory.getServiceById(Service.Switch, serviceConfig.subtype).getCharacteristic(Characteristic.On).on('get', this.getState.bind(this)).on('set', this.setState.bind(this)); | ||
this.getService().getCharacteristic(Characteristic.On).on('get', this.getState.bind(this)).on('set', this.setState.bind(this)); | ||
} | ||
@@ -21,0 +17,0 @@ |
@@ -40,26 +40,7 @@ const OutletService = require('./outlet'); | ||
{ | ||
var accessoryService = Service.AccessoryInformation; | ||
if(deviceConfig.services[i] == 'rgb') | ||
{ | ||
accessoryService = Service.Lightbulb; | ||
} | ||
else if(deviceConfig.services[i] == 'switch') | ||
{ | ||
accessoryService = Service.Switch; | ||
} | ||
else if(deviceConfig.services[i] == 'outlet') | ||
{ | ||
accessoryService = Service.Outlet; | ||
} | ||
else if(deviceConfig.services[i] == 'fan') | ||
{ | ||
accessoryService = Service.Fanv2; | ||
} | ||
this.addService(accessoryService, deviceConfig.services[i]); | ||
this.addService(deviceConfig.services[i]); | ||
} | ||
} | ||
addService(serviceType, config) | ||
addService(config) | ||
{ | ||
@@ -78,3 +59,3 @@ var type = config; | ||
this.setService(serviceType, config, this.subtypes[type]); | ||
this.setService(config, this.subtypes[type]); | ||
@@ -84,3 +65,3 @@ this.subtypes[type]++; | ||
setService(serviceType, config, subtype) | ||
setService(config, subtype) | ||
{ | ||
@@ -141,15 +122,2 @@ var name = this.name; | ||
} | ||
} | ||
var types = ['contact', 'motion', 'temperature', 'humidity', 'rain', 'light', 'occupancy', 'smoke', 'airquality', 'rgb', 'switch', 'relais', 'statelessswitch', 'outlet']; | ||
var letters = ['A', 'B', 'C', 'D', 'E', 'F', '0', '1', '2', '3', '4', '5', '6', '7']; | ||
function letterToType(letter) | ||
{ | ||
return types[letters.indexOf(letter.toUpperCase())]; | ||
} | ||
function typeToLetter(type) | ||
{ | ||
return letters[types.indexOf(type.toLowerCase())]; | ||
} |
{ | ||
"name": "homebridge-syntex-dynamic-platform", | ||
"version": "1.0.0-b3", | ||
"version": "1.0.0-b4", | ||
"description": "A Dynamic Platform Accessory", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,6 +17,7 @@ const UniversalAccessory = require('./accessories/universal'); | ||
if(!config || !config.options) | ||
if(!config) | ||
{ | ||
this.logger.debug('Keine Config gefunden, das Plugin wird deaktiviert!') | ||
//return; | ||
this.logger.debug('Keine Config gefunden, das Plugin wird deaktiviert!'); | ||
return; | ||
} | ||
@@ -44,3 +45,3 @@ | ||
var devices = [{id : 'acc1', name : 'Accessory 1', services : ['outlet', 'outlet', 'outlet', 'outlet', 'outlet']}, | ||
var devices = [{id : 'acc1', name : 'Accessory 1', services : [{ type : 'outlet', name : 'Outlet 1' }, { type : 'outlet', name : 'Outlet 2' }, { type : 'outlet', name : 'Outlet 3' }, { type : 'outlet', name : 'Outlet 4' }, { type : 'outlet', name : 'Outlet 5' }]}, | ||
{id : 'acc2', name : 'Accessory 2', services : ['rgb', 'switch']}]; | ||
@@ -69,2 +70,3 @@ | ||
let deviceAccessory = new UniversalAccessory(homebridgeAccessory, device, { platform : this, logger : this.logger }); | ||
this.accessories.set(uuid, deviceAccessory.homebridgeAccessory); | ||
@@ -71,0 +73,0 @@ } |
@@ -5,4 +5,17 @@ # Homebridge SynTex Dynamic Platform | ||
# Installation | ||
## Installation | ||
1. Install homebridge using: `sudo npm install -g homebridge` | ||
2. Install this plugin using: `sudo npm install -g homebridge-dynamic-platform` | ||
2. Install this plugin using: `sudo npm install -g homebridge-syntex-dynamic-platform` | ||
## Example Config | ||
**Info:** If the directory for the storage can't be created you have to do it by yourself and give it full write permissions! | ||
- `sudo chown -R homebridge ./SynTex/` ( *permissions only for homebridge* ) | ||
- `sudo chmod 777 -R homebridge ./SynTex/` ( *permissions for many processes* ) | ||
``` | ||
{ | ||
"platform": "SynTexDynamicPlatform", | ||
"log_directory": "./SynTex/log" | ||
} | ||
``` |
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
20
17946
10
449