UNPKG

thing-it-device-blueid

Version:

[thing-it-node] Device Plugin for BlueID products.

110 lines (100 loc) 2.18 kB
module.exports = { metadata: { family: "blueIdDoor", plugin: "blueIdDoor", label: "BlueID Door Control", tangible: true, discoverable: true, state: [{ id: "unlock", label: "Unlock", type: { id: "boolean" } }, { id: "signedIn", label: "Signed In", type: { id: "boolean" } }], actorTypes: [], sensorTypes: [], services: [{ id: "unlockDoor", label: "Unlock Door" }], configuration: [{ id: "simulated", label: "Simulated", type: { id: "boolean" } }, { id: "location", label: "Location", type: { id: "string" } }, { id: "user", label: "User", type: { id: "string" } }, { id: "pwd", label: "Password", type: { id: "string" } }, { id: "doorId", label: "Door ID", type: { id: "string" } }] }, create: function (device) { return new BlueId(); } }; var q = require('q'); var client; /** * */ function BlueId() { /** * Initialize on start up */ BlueId.prototype.start = function () { var deferred = q.defer(); // Initialize state values this.state = { signedIn: false, doorId: 0, unlock: 0 }; this.logDebug("BlueId state: ", this.state); this.logDebug("BlueId configuration: ", this.configuration); this.logLevel = "debug"; // this.publishStateChange(); deferred.resolve(); return deferred.promise; }; } /** * */ BlueId.prototype.setState = function (state) { this.state = state; this.publishStateChange(); }; /** * */ BlueId.prototype.getState = function () { return this.state; };