homebridge-misfit-bolt
Advanced tools
Comparing version 0.1.2 to 0.1.3
"use strict"; | ||
const _bind = require('lodash').bind, | ||
superagent = require('superagent'), | ||
const debug = require('debug')(require('../package').name), | ||
superagent = require('superagent-cache')(), | ||
get = superagent.get, | ||
put = superagent.put; | ||
patch = superagent.patch; | ||
@@ -12,16 +12,18 @@ var Service, Characteristic; | ||
constructor(config, log) { | ||
constructor(config) { | ||
this.id = config.id; | ||
this.name = config.name; | ||
this.baseUrl = config.baseUrl; | ||
this.log = log; | ||
} | ||
url(property) { | ||
return `${this.baseUrl}/${property}`; | ||
getServices() { | ||
return [ | ||
this.lightbulbService(), | ||
this.informationService() | ||
]; | ||
} | ||
getServices() { | ||
lightbulbService() { | ||
const service = new Service.Lightbulb(this.name); | ||
const wrap = (characteristic, property) => { | ||
@@ -32,3 +34,3 @@ const responseHandler = (callback) => { | ||
if (res && res[property]) { | ||
body = res[property] | ||
body = res[property]; | ||
} | ||
@@ -40,11 +42,11 @@ callback(err, body); | ||
const getter = (callback) => { | ||
this.log(`Get Bolt#${this.id} ${property}`); | ||
get(this.url(property)).end(responseHandler(callback)); | ||
debug(`Get Bolt#${this.id} ${property}`); | ||
get(this.baseUrl).end(responseHandler(callback)); | ||
}; | ||
const setter = (value, callback) => { | ||
this.log(`Set Bolt#${this.id} ${property} with ${value}`); | ||
debug(`Set Bolt#${this.id} ${property} with ${value}`); | ||
var body = {}; | ||
body[property] = value; | ||
put(this.url(property)) | ||
patch(this.baseUrl) | ||
.send(body) | ||
@@ -64,5 +66,17 @@ .end(responseHandler(callback)); | ||
return [service]; | ||
return service; | ||
} | ||
informationService() { | ||
const service = new Service.AccessoryInformation(); | ||
service | ||
.setCharacteristic(Characteristic.Manufacturer, 'MISFIT') | ||
.setCharacteristic(Characteristic.Model, 'BOLT') | ||
.setCharacteristic(Characteristic.SerialNumber, 'unknown') | ||
.setCharacteristic(Characteristic.Name, this.name); | ||
return service; | ||
} | ||
} | ||
@@ -69,0 +83,0 @@ |
@@ -17,3 +17,3 @@ "use strict"; | ||
this.config.accessories.forEach((config) => { | ||
var accessory = new MisfitBoltAccessory(config, this.log); | ||
var accessory = new MisfitBoltAccessory(config); | ||
accessories.push(accessory); | ||
@@ -20,0 +20,0 @@ }); |
{ | ||
"name": "homebridge-misfit-bolt", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Misfit Bolt plugin for homebridge", | ||
@@ -23,3 +23,3 @@ "keywords": [ | ||
"scripts": { | ||
"lint": "./node_modules/.bin/jshint *.js", | ||
"lint": "./node_modules/.bin/jshint *.js lib/*.js", | ||
"patch-release": "npm version patch && npm publish && git push --follow-tags", | ||
@@ -37,8 +37,7 @@ "minor-release": "npm version minor && npm publish && git push --follow-tags", | ||
"debug": "^2.2.0", | ||
"lodash": "^4.13.1", | ||
"superagent": "^2.0.0" | ||
"superagent-cache": "^1.6.0" | ||
}, | ||
"devDependencies": { | ||
"jshint": "^2.8.0" | ||
"jshint": "^2.9.2" | ||
} | ||
} |
@@ -44,3 +44,3 @@ # homebridge-misfit-bolt | ||
will become in your config: | ||
will become in your config (assuming the service `misfit-bolt-http` runs locally on port `3000`): | ||
@@ -50,3 +50,4 @@ ```json | ||
"id": "20338f8afaac", | ||
"name": "Bolt" | ||
"name": "Bolt", | ||
"baseUrl": "http://localhost:3000/20338f8afaac" | ||
} | ||
@@ -53,0 +54,0 @@ |
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
6615
2
97
73
+ Addedsuperagent-cache@^1.6.0
+ Addedasync@0.9.2(transitive)
+ Addedcache-service-cache-module@1.2.6(transitive)
+ Addedcombined-stream@0.0.7(transitive)
+ Addedcomponent-emitter@1.2.1(transitive)
+ Addedcookiejar@2.0.6(transitive)
+ Addeddelayed-stream@0.0.5(transitive)
+ Addedextend@3.0.0(transitive)
+ Addedform-data@0.2.0(transitive)
+ Addedformidable@1.0.17(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedmime@1.3.4(transitive)
+ Addedmime-db@1.12.0(transitive)
+ Addedmime-types@2.0.14(transitive)
+ Addedqs@2.3.3(transitive)
+ Addedreadable-stream@1.0.27-1(transitive)
+ Addedreduce-component@1.0.1(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedsuperagent@1.7.2(transitive)
+ Addedsuperagent-cache@1.7.2(transitive)
- Removedlodash@^4.13.1
- Removedsuperagent@^2.0.0
- Removedasync@1.5.2(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedcookiejar@2.1.4(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedextend@3.0.2(transitive)
- Removedform-data@1.0.0-rc4(transitive)
- Removedformidable@1.2.6(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhasown@2.0.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedlodash@4.17.21(transitive)
- Removedmime@1.6.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedqs@6.13.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedside-channel@1.0.6(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedsuperagent@2.3.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)