Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

homebridge-misfit-bolt

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homebridge-misfit-bolt - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

44

lib/accessory.js
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc