node-switchbot
Advanced tools
Comparing version 1.0.9-beta.1 to 1.0.9-beta.2
@@ -81,4 +81,2 @@ 'use strict'; | ||
sd = this._parseServiceDataForWoHand(buf); | ||
} else if (model === 'h') { // WoHumi | ||
sd = this._parseServiceDataForWoHumi(buf); | ||
} else if (model === 'T') { // WoSensorTH | ||
@@ -145,22 +143,2 @@ sd = this._parseServiceDataForWoSensorTH(buf); | ||
_parseServiceDataForWoHumi(buf) { | ||
if (buf.length !== 3) { | ||
return null; | ||
} | ||
let byte1 = buf.readUInt8(1); | ||
let byte2 = buf.readUInt8(2); | ||
let mode = (byte1 & 0b10000000) ? true : false; // Whether the light switch Add-on is used or not | ||
let state = (byte1 & 0b01000000) ? true : false; // Whether the switch status is ON or OFF | ||
let data = { | ||
model: 'h', | ||
modelName: 'WoHumi', | ||
mode: mode, | ||
state: state | ||
}; | ||
return data; | ||
} | ||
_parseServiceDataForWoSensorTH(buf) { | ||
@@ -200,6 +178,22 @@ if (buf.length !== 6) { | ||
let data = { | ||
model: 'P', | ||
const byte1 = buf.readUInt8(1); | ||
const byte2 = buf.readUInt8(2); | ||
const byte3 = buf.readUInt8(3); | ||
const byte4 = buf.readUInt8(4); | ||
const byte5 = buf.readUInt8(5); | ||
const motion = byte1 & 0b01000000; // Whether the calibration is completed | ||
const battery = byte2 & 0b01111111; // % | ||
const pir_trigger3 = byte3 & 0b00001111; // | ||
const pir_trigger4 = byte4 & 0b01000000; // | ||
const state = byte5 & 0b01111111; // % | ||
const data = { | ||
model: 's', | ||
modelName: 'WoPresence', | ||
battery: (byte2 & 0b01111111) | ||
motion: motion ? true : false, | ||
battery: battery, | ||
pir_trigger3: pir_trigger3, | ||
pir_trigger4: pir_trigger4, | ||
state: state ? true : false, | ||
}; | ||
@@ -215,6 +209,31 @@ | ||
let data = { | ||
model: 'C', | ||
const byte1 = buf.readUInt8(1); | ||
const byte2 = buf.readUInt8(2); | ||
const byte3 = buf.readUInt8(3); | ||
const byte4 = buf.readUInt8(4); | ||
const byte5 = buf.readUInt8(5); | ||
const byte6 = buf.readUInt8(6); | ||
const byte7 = buf.readUInt8(7); | ||
const byte8 = buf.readUInt8(8); | ||
const motion = byte1 & 0b01000000; // Whether there is motion | ||
const battery = byte2 & 0b01111111; // % | ||
const state = byte3 & 0b01111111; // current state | ||
const pir_trigger4 = byte4 & 0b00001111; // | ||
const pir_trigger5 = byte5 & 0b01000000; // | ||
const hal_trigger6 = byte6 & 0b01111111; // | ||
const hal_trigger7 = byte7 & 0b01111111; // | ||
const act_counter = byte8 & 0b00001111; // | ||
const data = { | ||
model: 'd', | ||
modelName: 'WoContact', | ||
battery: (byte2 & 0b01111111) | ||
motion: motion ? true : false, | ||
battery: battery, | ||
state: state ? true : false, | ||
pir_trigger4: pir_trigger4, | ||
pir_trigger5: pir_trigger5, | ||
hal_trigger6: hal_trigger6, | ||
hal_trigger7: hal_trigger7, | ||
act_counter: act_counter, | ||
}; | ||
@@ -221,0 +240,0 @@ |
@@ -11,3 +11,2 @@ 'use strict'; | ||
const SwitchbotDeviceWoSensorTH = require('./switchbot-device-wosensorth.js'); | ||
const SwitchbotDeviceWoHumi = require('./switchbot-device-wohumi.js'); | ||
@@ -188,5 +187,2 @@ class Switchbot { | ||
break; | ||
case 'Hu': | ||
device = new SwitchbotDeviceWoHumi(peripheral, this.noble); | ||
break; | ||
case 'T': | ||
@@ -193,0 +189,0 @@ device = new SwitchbotDeviceWoSensorTH(peripheral, this.noble); |
{ | ||
"name": "node-switchbot", | ||
"version": "1.0.9-beta.1", | ||
"version": "1.0.9-beta.2", | ||
"description": "The node-switchbot is a Node.js module which allows you to move your Switchbot (Bot)'s arm and Switchbot Curtain(Curtain), also monitor the temperature/humidity from SwitchBot Thermometer & Hygrometer (Meter).", | ||
@@ -5,0 +5,0 @@ "main": "./lib/switchbot.js", |
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
98049
13
1633