diff --git a/CHANGELOG.md b/CHANGELOG.md index fb4aa55c..8e33b0f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,15 @@ All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/) -## [Version 1.6.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.5.0) (2022-10-18) +## [Version 1.6.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.6.1) (2022-10-18) + +## What's Changed + +- Fixed Issue where node-switchbot wouldn't be found. + +**Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.6.0...v1.6.1 + +## [Version 1.6.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.6.0) (2022-10-18) ## What's Changed diff --git a/README.md b/README.md index ef098c3f..757e4c58 100644 --- a/README.md +++ b/README.md @@ -110,9 +110,9 @@ Monitoring the advertising packets, you can find your devices and know the lates ```JavaScript // Load the node-switchbot and get a `Switchbot` constructor object -const Switchbot = require('node-switchbot'); +let Switchbot = require('node-switchbot'); // Create an `Switchbot` object -const switchbot = new Switchbot(); +let switchbot = new Switchbot(); (async () => { // Start to monitor advertisement packets @@ -137,7 +137,7 @@ The [`startScan()`](#startscan-method) and [`wait()`](#Switchbot-wait-method) me ```javascript // Load the node-switchbot and get a `Switchbot` constructor object -const Switchbot = require("node-switchbot"); +let Switchbot = require("node-switchbot"); // Create an `Switchbot` object let switchbot = new Switchbot(); @@ -213,13 +213,13 @@ This sample discovers a Bot (WoHand), then put the Bot's arm down, finally put i ```javascript // Load the node-switchbot and get a `Switchbot` constructor object -const Switchbot = require("node-switchbot"); +let Switchbot = require("node-switchbot"); // Create an `Switchbot` object -const switchbot = new Switchbot(); +let switchbot = new Switchbot(); (async () => { // Find a Bot (WoHand) - const bot_list = await switchbot.discover({ model: "H", quick: true }); + let bot_list = await switchbot.discover({ model: "H", quick: true }); if (bot_list.length === 0) { throw new Error("No device was found."); } @@ -246,13 +246,13 @@ In this code, you can get a [`SwitchbotDeviceWoHand`](#SwitchbotDeviceWoHand-obj In order to use the node-switchbot, you have to load the node-switchbot module as follows: ```JavaScript -const Switchbot = require('node-switchbot'); +let Switchbot = require('node-switchbot'); ``` You can get an `Switchbot` constructor from the code above. Then you have to create an `Switchbot` object from the `Switchbot` constructor as follows: ```javascript -const switchbot = new Switchbot(); +let switchbot = new Switchbot(); ``` The `Switchbot` constructor takes an argument optionally. It must be a hash object containing the properties as follows: @@ -267,11 +267,11 @@ The sample code below shows how to pass a `Nobel` object to the `Switchbot` cons ```JavaScript // Create a Noble object -const noble = require('@abandonware/noble'); +let noble = require('@abandonware/noble'); // Create a Switchbot object -const Switchbot = require('node-switchbot'); -const switchbot = new Switchbot({'noble': noble}); +let Switchbot = require('node-switchbot'); +let switchbot = new Switchbot({'noble': noble}); ``` In the code snippet above, the variable `switchbot` is an `Switchbot` object. The `Switchbot` object has a lot of methods as described in sections below. diff --git a/lib/parameter-checker.js b/lib/parameter-checker.js index 1f30ef72..cbb3f2c6 100644 --- a/lib/parameter-checker.js +++ b/lib/parameter-checker.js @@ -37,7 +37,7 @@ class ParameterChecker { * an `Error` object will be set to `this._error`. * * [Usage] - * const valid = parameterChecker.check(params, { + * let valid = parameterChecker.check(params, { * level: { * required: false, * type: 'integer', @@ -50,7 +50,7 @@ class ParameterChecker { * } * }); * if(!valid) { - * const e = parameterChecker.error.message; + * let e = parameterChecker.error.message; * throw new Error(message); * } * ---------------------------------------------------------------- */ @@ -78,13 +78,13 @@ class ParameterChecker { return false; } - const result = true; - const name_list = Object.keys(rules); + let result = true; + let name_list = Object.keys(rules); - for (const i = 0; i < name_list.length; i++) { - const name = name_list[i]; - const v = obj[name]; - const rule = rules[name]; + for (let i = 0; i < name_list.length; i++) { + let name = name_list[i]; + let v = obj[name]; + let rule = rules[name]; if (!rule) { rule = {}; @@ -458,7 +458,7 @@ class ParameterChecker { } } if (typeof rule.minBytes === "number") { - const blen = Buffer.from(value, "utf8").length; + let blen = Buffer.from(value, "utf8").length; if (blen < rule.minBytes) { this._error = { code: "LENGTH_UNDERFLOW", @@ -475,7 +475,7 @@ class ParameterChecker { } } if (typeof rule.maxBytes === "number") { - const blen = Buffer.from(value, "utf8").length; + let blen = Buffer.from(value, "utf8").length; if (blen > rule.maxBytes) { this._error = { code: "LENGTH_OVERFLOW", diff --git a/lib/switchbot-advertising.js b/lib/switchbot-advertising.js index 56572a44..0a504145 100644 --- a/lib/switchbot-advertising.js +++ b/lib/switchbot-advertising.js @@ -61,16 +61,16 @@ class SwitchbotAdvertising { * device, this method will return `null`. * ---------------------------------------------------------------- */ parse(peripheral, onlog) { - const ad = peripheral.advertisement; + let ad = peripheral.advertisement; if (!ad || !ad.serviceData) { return null; } - const serviceData = ad.serviceData[0] || ad.serviceData; - const manufacturerData = ad.manufacturerData; - const buf = serviceData.data; + let serviceData = ad.serviceData[0] || ad.serviceData; + let manufacturerData = ad.manufacturerData; + let buf = serviceData.data; - const bufIsInvalid = !buf || !Buffer.isBuffer(buf) || buf.length < 3; - const manufacturerDataIsInvalid = + let bufIsInvalid = !buf || !Buffer.isBuffer(buf) || buf.length < 3; + let manufacturerDataIsInvalid = !manufacturerData || !Buffer.isBuffer(manufacturerData) || manufacturerData.length < 3; @@ -79,8 +79,8 @@ class SwitchbotAdvertising { return null; } - const model = buf.slice(0, 1).toString("utf8"); - const sd = null; + let model = buf.slice(0, 1).toString("utf8"); + let sd = null; if (model === "H") { sd = this._parseServiceDataForWoHand(buf, onlog);//WoHand @@ -123,11 +123,11 @@ class SwitchbotAdvertising { } return null; } - const address = peripheral.address || ""; + let address = peripheral.address || ""; if (address === "") { address = peripheral.advertisement.manufacturerData || ""; if (address !== "") { - const str = peripheral.advertisement.manufacturerData + let str = peripheral.advertisement.manufacturerData .toString("hex") .slice(4, 16); address = str.substr(0, 2); @@ -139,7 +139,7 @@ class SwitchbotAdvertising { } else { address = address.replace(/-/g, ":"); } - const data = { + let data = { id: peripheral.id, address: address, rssi: peripheral.rssi, @@ -165,14 +165,14 @@ class SwitchbotAdvertising { } return null; } - const byte1 = buf.readUInt8(1); - const byte2 = buf.readUInt8(2); + let byte1 = buf.readUInt8(1); + let byte2 = buf.readUInt8(2); - const mode = byte1 & 0b10000000 ? true : false; // Whether the light switch Add-on is used or not - const state = byte1 & 0b01000000 ? true : false; // Whether the switch status is ON or OFF - const battery = byte2 & 0b01111111; // % + 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 battery = byte2 & 0b01111111; // % - const data = { + let data = { model: "H", modelName: "WoHand", mode: mode, @@ -192,17 +192,17 @@ class SwitchbotAdvertising { } return null; } - const byte2 = buf.readUInt8(2); - const byte3 = buf.readUInt8(3); - const byte4 = buf.readUInt8(4); - const byte5 = buf.readUInt8(5); - - const temp_sign = byte4 & 0b10000000 ? 1 : -1; - const temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10); - const temp_f = (temp_c * 9 / 5) + 32; + let byte2 = buf.readUInt8(2); + let byte3 = buf.readUInt8(3); + let byte4 = buf.readUInt8(4); + let byte5 = buf.readUInt8(5); + + let temp_sign = byte4 & 0b10000000 ? 1 : -1; + let temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10); + let temp_f = (temp_c * 9 / 5) + 32; temp_f = Math.round(temp_f * 10) / 10; - const data = { + let data = { model: "T", modelName: "WoSensorTH", temperature: { @@ -226,15 +226,15 @@ class SwitchbotAdvertising { } return null; } - const byte1 = buf.readUInt8(1); - const byte4 = buf.readUInt8(4); + let byte1 = buf.readUInt8(1); + let byte4 = buf.readUInt8(4); - const onState = byte1 & 0b10000000 ? true : false; // 1 - on - const autoMode = byte4 & 0b10000000 ? true : false; // 1 - auto - const percentage = byte4 & 0b01111111; // 0-100%, 101/102/103 - Quick gear 1/2/3 + let onState = byte1 & 0b10000000 ? true : false; // 1 - on + let autoMode = byte4 & 0b10000000 ? true : false; // 1 - auto + let percentage = byte4 & 0b01111111; // 0-100%, 101/102/103 - Quick gear 1/2/3 - const data = { + let data = { model: "e", modelName: "WoHumi", onState: onState, @@ -255,20 +255,20 @@ class SwitchbotAdvertising { return null; } - const byte1 = buf.readUInt8(1); - const byte2 = buf.readUInt8(2); - const byte5 = buf.readUInt8(5); + let byte1 = buf.readUInt8(1); + let byte2 = buf.readUInt8(2); + let byte5 = buf.readUInt8(5); - const tested = byte1 & 0b10000000 ? true : false; - const movement = byte1 & 0b01000000 ? true : false; - const battery = byte2 & 0b01111111; - const led = (byte5 & 0b00100000) >> 5; - const iot = (byte5 & 0b00010000) >> 4; - const sense_distance = (byte5 & 0b00001100) >> 2; - const lightLevel = byte5 & 0b00000011; - const is_light = byte5 & 0b00000010 ? true : false; + let tested = byte1 & 0b10000000 ? true : false; + let movement = byte1 & 0b01000000 ? true : false; + let battery = byte2 & 0b01111111; + let led = (byte5 & 0b00100000) >> 5; + let iot = (byte5 & 0b00010000) >> 4; + let sense_distance = (byte5 & 0b00001100) >> 2; + let lightLevel = byte5 & 0b00000011; + let is_light = byte5 & 0b00000010 ? true : false; - const data = { + let data = { model: "s", modelName: "WoMotion", tested: tested, @@ -295,21 +295,21 @@ class SwitchbotAdvertising { return null; } - const byte1 = buf.readUInt8(1); - const byte2 = buf.readUInt8(2); - const byte3 = buf.readUInt8(3); - const byte8 = buf.readUInt8(8); - - const hallState = (byte3 >> 1) & 0b00000011; - const tested = byte1 & 0b10000000; - const movement = byte1 & 0b01000000 ? true : false; // 1 - Movement detected - const battery = byte2 & 0b01111111; // % - const contact_open = byte3 & 0b00000010 == 0b00000010; - const contact_timeout = byte3 & 0b00000100 == 0b00000100; - const lightLevel = byte3 & 0b00000001; - const button_count = byte8 & 0b00001111; - - const data = { + let byte1 = buf.readUInt8(1); + let byte2 = buf.readUInt8(2); + let byte3 = buf.readUInt8(3); + let byte8 = buf.readUInt8(8); + + let hallState = (byte3 >> 1) & 0b00000011; + let tested = byte1 & 0b10000000; + let movement = byte1 & 0b01000000 ? true : false; // 1 - Movement detected + let battery = byte2 & 0b01111111; // % + let contact_open = byte3 & 0b00000010 == 0b00000010; + let contact_timeout = byte3 & 0b00000100 == 0b00000100; + let lightLevel = byte3 & 0b00000001; + let button_count = byte8 & 0b00001111; + + let data = { model: "d", modelName: "WoContact", movement: movement, @@ -339,19 +339,19 @@ class SwitchbotAdvertising { } return null; } - const byte1 = buf.readUInt8(1); - const byte2 = buf.readUInt8(2); - const byte3 = buf.readUInt8(3); - const byte4 = buf.readUInt8(4); - - const calibration = byte1 & 0b01000000 ? true : false; // Whether the calibration is completed - const battery = byte2 & 0b01111111; // % - const inMotion = byte3 & 0b10000000 ? true : false; - const currPosition = byte3 & 0b01111111; // current positon % - const lightLevel = (byte4 >> 4) & 0b00001111; // light sensor level (1-10) - const deviceChain = byte4 & 0b00000111; - - const data = { + let byte1 = buf.readUInt8(1); + let byte2 = buf.readUInt8(2); + let byte3 = buf.readUInt8(3); + let byte4 = buf.readUInt8(4); + + let calibration = byte1 & 0b01000000 ? true : false; // Whether the calibration is completed + let battery = byte2 & 0b01111111; // % + let inMotion = byte3 & 0b10000000 ? true : false; + let currPosition = byte3 & 0b01111111; // current positon % + let lightLevel = (byte4 >> 4) & 0b00001111; // light sensor level (1-10) + let deviceChain = byte4 & 0b00000111; + + let data = { model: "c", modelName: "WoCurtain", calibration: calibration, @@ -374,31 +374,31 @@ class SwitchbotAdvertising { } return null; } - const byte1 = buf.readUInt8(1);//power and light status - const byte2 = buf.readUInt8(2);//bulb brightness - const byte3 = buf.readUInt8(3);//bulb R - const byte4 = buf.readUInt8(4);//bulb G - const byte5 = buf.readUInt8(5);//bulb B - const byte6 = buf.readUInt8(6);//bulb temperature - const byte7 = buf.readUInt8(7); - const byte8 = buf.readUInt8(8); - const byte9 = buf.readUInt8(9); - const byte10 = buf.readUInt8(10);//bulb mode - - const power = byte1; - const red = byte3; - const green = byte4; - const blue = byte5; - const color_temperature = byte6; - const state = byte7 & 0b01111111 ? true : false; - const brightness = byte7 & 0b01111111; - const delay = byte8 & 0b10000000; - const preset = byte8 & 0b00001000; - const color_mode = byte8 & 0b00000111; - const speed = byte9 & 0b01111111; - const loop_index = byte10 & 0b11111110; - - const data = { + let byte1 = buf.readUInt8(1);//power and light status + let byte2 = buf.readUInt8(2);//bulb brightness + let byte3 = buf.readUInt8(3);//bulb R + let byte4 = buf.readUInt8(4);//bulb G + let byte5 = buf.readUInt8(5);//bulb B + let byte6 = buf.readUInt8(6);//bulb temperature + let byte7 = buf.readUInt8(7); + let byte8 = buf.readUInt8(8); + let byte9 = buf.readUInt8(9); + let byte10 = buf.readUInt8(10);//bulb mode + + let power = byte1; + let red = byte3; + let green = byte4; + let blue = byte5; + let color_temperature = byte6; + let state = byte7 & 0b01111111 ? true : false; + let brightness = byte7 & 0b01111111; + let delay = byte8 & 0b10000000; + let preset = byte8 & 0b00001000; + let color_mode = byte8 & 0b00000111; + let speed = byte9 & 0b01111111; + let loop_index = byte10 & 0b11111110; + + let data = { model: "u", modelName: "WoBulb", color_temperature: color_temperature, @@ -427,22 +427,22 @@ class SwitchbotAdvertising { } return null; } - const byte9 = buf.readUInt8(9); // byte9: plug mini state; 0x00=off, 0x80=on - const byte10 = buf.readUInt8(10); // byte10: bit0: 0=no delay,1=delay, bit1:0=no timer, 1=timer; bit2:0=no sync time, 1=sync'ed time - const byte11 = buf.readUInt8(11); // byte11: wifi rssi - const byte12 = buf.readUInt8(12); // byte12: bit7: overload? - const byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value - - const state = byte9 === 0x00 ? "off" : byte9 === 0x80 ? "on" : null; - const delay = !!(byte10 & 0b00000001); - const timer = !!(byte10 & 0b00000010); - const syncUtcTime = !!(byte10 & 0b00000100); - const wifiRssi = byte11; - const overload = !!(byte12 & 0b10000000); - const currentPower = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt + let byte9 = buf.readUInt8(9); // byte9: plug mini state; 0x00=off, 0x80=on + let byte10 = buf.readUInt8(10); // byte10: bit0: 0=no delay,1=delay, bit1:0=no timer, 1=timer; bit2:0=no sync time, 1=sync'ed time + let byte11 = buf.readUInt8(11); // byte11: wifi rssi + let byte12 = buf.readUInt8(12); // byte12: bit7: overload? + let byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value + + let state = byte9 === 0x00 ? "off" : byte9 === 0x80 ? "on" : null; + let delay = !!(byte10 & 0b00000001); + let timer = !!(byte10 & 0b00000010); + let syncUtcTime = !!(byte10 & 0b00000100); + let wifiRssi = byte11; + let overload = !!(byte12 & 0b10000000); + let currentPower = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt // TODO: voltage ??? - const data = { + let data = { model: "g", modelName: "WoPlugMini", state: state, @@ -466,22 +466,22 @@ class SwitchbotAdvertising { } return null; } - const byte9 = buf.readUInt8(9); // byte9: plug mini state; 0x00=off, 0x80=on - const byte10 = buf.readUInt8(10); // byte10: bit0: 0=no delay,1=delay, bit1:0=no timer, 1=timer; bit2:0=no sync time, 1=sync'ed time - const byte11 = buf.readUInt8(11); // byte11: wifi rssi - const byte12 = buf.readUInt8(12); // byte12: bit7: overload? - const byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value - - const state = byte9 === 0x00 ? "off" : byte9 === 0x80 ? "on" : null; - const delay = !!(byte10 & 0b00000001); - const timer = !!(byte10 & 0b00000010); - const syncUtcTime = !!(byte10 & 0b00000100); - const wifiRssi = byte11; - const overload = !!(byte12 & 0b10000000); - const currentPower = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt + let byte9 = buf.readUInt8(9); // byte9: plug mini state; 0x00=off, 0x80=on + let byte10 = buf.readUInt8(10); // byte10: bit0: 0=no delay,1=delay, bit1:0=no timer, 1=timer; bit2:0=no sync time, 1=sync'ed time + let byte11 = buf.readUInt8(11); // byte11: wifi rssi + let byte12 = buf.readUInt8(12); // byte12: bit7: overload? + let byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value + + let state = byte9 === 0x00 ? "off" : byte9 === 0x80 ? "on" : null; + let delay = !!(byte10 & 0b00000001); + let timer = !!(byte10 & 0b00000010); + let syncUtcTime = !!(byte10 & 0b00000100); + let wifiRssi = byte11; + let overload = !!(byte12 & 0b10000000); + let currentPower = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt // TODO: voltage ??? - const data = { + let data = { model: "j", modelName: "WoPlugMini", state: state, @@ -505,13 +505,13 @@ class SwitchbotAdvertising { } return null; } - const byte1 = buf.readUInt8(1); - const byte2 = buf.readUInt8(2); + let byte1 = buf.readUInt8(1); + let byte2 = buf.readUInt8(2); - const movement = (byte1 & 0b01000000) ? true : false; // 1 - Movement detected - const battery = byte2 & 0b01111111; // % + let movement = (byte1 & 0b01000000) ? true : false; // 1 - Movement detected + let battery = byte2 & 0b01111111; // % - const data = { + let data = { model: "o", modelName: "WoSmartLock", battery: battery, @@ -530,17 +530,17 @@ class SwitchbotAdvertising { } return null; } - const byte2 = buf.readUInt8(2); - const byte3 = buf.readUInt8(3); - const byte4 = buf.readUInt8(4); - const byte5 = buf.readUInt8(5); - - const temp_sign = byte4 & 0b10000000 ? 1 : -1; - const temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10); - const temp_f = (temp_c * 9 / 5) + 32; + let byte2 = buf.readUInt8(2); + let byte3 = buf.readUInt8(3); + let byte4 = buf.readUInt8(4); + let byte5 = buf.readUInt8(5); + + let temp_sign = byte4 & 0b10000000 ? 1 : -1; + let temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10); + let temp_f = (temp_c * 9 / 5) + 32; temp_f = Math.round(temp_f * 10) / 10; - const data = { + let data = { model: "i", modelName: "WoSensorTHPlus", temperature: { @@ -565,28 +565,28 @@ class SwitchbotAdvertising { return null; } - const byte1 = buf.readUInt8(1);//power and light status - const byte2 = buf.readUInt8(2);//bulb brightness - const byte3 = buf.readUInt8(3);//bulb R - const byte4 = buf.readUInt8(4);//bulb G - const byte5 = buf.readUInt8(5);//bulb B - const byte7 = buf.readUInt8(7); - const byte8 = buf.readUInt8(8); - const byte9 = buf.readUInt8(9); - const byte10 = buf.readUInt8(10); - - const state = byte7 & 0b10000000 ? true : false; - const brightness = byte7 & 0b01111111; - const red = byte3; - const green = byte4; - const blue = byte5; - const delay = byte8 & 0b10000000; - const preset = byte8 & 0b00001000; - const color_mode = byte8 & 0b00000111; - const speed = byte9 & 0b01111111; - const loop_index = byte10 & 0b11111110; - - const data = { + let byte1 = buf.readUInt8(1);//power and light status + let byte2 = buf.readUInt8(2);//bulb brightness + let byte3 = buf.readUInt8(3);//bulb R + let byte4 = buf.readUInt8(4);//bulb G + let byte5 = buf.readUInt8(5);//bulb B + let byte7 = buf.readUInt8(7); + let byte8 = buf.readUInt8(8); + let byte9 = buf.readUInt8(9); + let byte10 = buf.readUInt8(10); + + let state = byte7 & 0b10000000 ? true : false; + let brightness = byte7 & 0b01111111; + let red = byte3; + let green = byte4; + let blue = byte5; + let delay = byte8 & 0b10000000; + let preset = byte8 & 0b00001000; + let color_mode = byte8 & 0b00000111; + let speed = byte9 & 0b01111111; + let loop_index = byte10 & 0b11111110; + + let data = { model: "r", modelName: "WoStrip", state: state, diff --git a/lib/switchbot-device-wobulb.js b/lib/switchbot-device-wobulb.js index cb0e2a7e..3146709c 100644 --- a/lib/switchbot-device-wobulb.js +++ b/lib/switchbot-device-wobulb.js @@ -1,5 +1,5 @@ "use strict"; -const SwitchbotDevice = require("./switchbot-device.js"); +let SwitchbotDevice = require("./switchbot-device.js"); /** * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/colorbulb.md @@ -16,7 +16,7 @@ class SwitchbotDeviceWoBulb extends SwitchbotDevice { * @private */ _setState(reqByteArray) { - const base = [0x57, 0x0f, 0x47, 0x01]; + let base = [0x57, 0x0f, 0x47, 0x01]; return this._operateBot([].concat(base, reqByteArray)); } @@ -149,15 +149,15 @@ class SwitchbotDeviceWoBulb extends SwitchbotDevice { * @private */ _operateBot(bytes) { - const req_buf = Buffer.from(bytes); + let req_buf = Buffer.from(bytes); return new Promise((resolve, reject) => { this._command(req_buf) .then((res_bytes) => { - const res_buf = Buffer.from(res_bytes); + let res_buf = Buffer.from(res_bytes); if (res_buf.length === 2) { - const code = res_buf.readUInt8(1); + let code = res_buf.readUInt8(1); if (code === 0x00 || code === 0x80) { - const is_on = code === 0x80; + let is_on = code === 0x80; resolve(is_on); } else { reject( diff --git a/lib/switchbot-device-wocontact.js b/lib/switchbot-device-wocontact.js index 63443786..287959ae 100644 --- a/lib/switchbot-device-wocontact.js +++ b/lib/switchbot-device-wocontact.js @@ -1,5 +1,5 @@ "use strict"; -const SwitchbotDevice = require("./switchbot-device.js"); +let SwitchbotDevice = require("./switchbot-device.js"); class SwitchbotDeviceWoContact extends SwitchbotDevice {} diff --git a/lib/switchbot-device-wocurtain.js b/lib/switchbot-device-wocurtain.js index 92ff56c3..727b5170 100644 --- a/lib/switchbot-device-wocurtain.js +++ b/lib/switchbot-device-wocurtain.js @@ -1,5 +1,5 @@ "use strict"; -const SwitchbotDevice = require("./switchbot-device.js"); +let SwitchbotDevice = require("./switchbot-device.js"); class SwitchbotDeviceWoCurtain extends SwitchbotDevice { /* ------------------------------------------------------------------ @@ -93,10 +93,10 @@ class SwitchbotDeviceWoCurtain extends SwitchbotDevice { _operateCurtain(bytes) { return new Promise((resolve, reject) => { - const req_buf = Buffer.from(bytes); + let req_buf = Buffer.from(bytes); this._command(req_buf) .then((res_buf) => { - const code = res_buf.readUInt8(0); + let code = res_buf.readUInt8(0); if (res_buf.length === 3 && code === 0x01) { resolve(); } else { diff --git a/lib/switchbot-device-wohand.js b/lib/switchbot-device-wohand.js index 3cd9378f..891da386 100644 --- a/lib/switchbot-device-wohand.js +++ b/lib/switchbot-device-wohand.js @@ -1,5 +1,5 @@ "use strict"; -const SwitchbotDevice = require("./switchbot-device.js"); +let SwitchbotDevice = require("./switchbot-device.js"); class SwitchbotDeviceWoHand extends SwitchbotDevice { /* ------------------------------------------------------------------ @@ -79,10 +79,10 @@ class SwitchbotDeviceWoHand extends SwitchbotDevice { _operateBot(bytes) { return new Promise((resolve, reject) => { - const req_buf = Buffer.from(bytes); + let req_buf = Buffer.from(bytes); this._command(req_buf) .then((res_buf) => { - const code = res_buf.readUInt8(0); + let code = res_buf.readUInt8(0); if (res_buf.length === 3 && (code === 0x01 || code === 0x05)) { resolve(); } else { diff --git a/lib/switchbot-device-wohumi.js b/lib/switchbot-device-wohumi.js index e7d055bd..82c8d3e9 100644 --- a/lib/switchbot-device-wohumi.js +++ b/lib/switchbot-device-wohumi.js @@ -1,5 +1,5 @@ "use strict"; -const SwitchbotDevice = require("./switchbot-device.js"); +let SwitchbotDevice = require("./switchbot-device.js"); class SwitchbotDeviceWoHumi extends SwitchbotDevice { /* ------------------------------------------------------------------ @@ -79,10 +79,10 @@ class SwitchbotDeviceWoHumi extends SwitchbotDevice { _operateBot(bytes) { return new Promise((resolve, reject) => { - const req_buf = Buffer.from(bytes); + let req_buf = Buffer.from(bytes); this._command(req_buf) .then((res_buf) => { - const code = res_buf.readUInt8(0); + let code = res_buf.readUInt8(0); if (res_buf.length === 3 && (code === 0x01 || code === 0x05)) { resolve(); } else { diff --git a/lib/switchbot-device-woplugmini.js b/lib/switchbot-device-woplugmini.js index 0e91068d..f156c24a 100644 --- a/lib/switchbot-device-woplugmini.js +++ b/lib/switchbot-device-woplugmini.js @@ -1,5 +1,5 @@ "use strict"; -const SwitchbotDevice = require("./switchbot-device.js"); +let SwitchbotDevice = require("./switchbot-device.js"); /** * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/plugmini.md @@ -16,7 +16,7 @@ class SwitchbotDeviceWoPlugMini extends SwitchbotDevice { * @private */ _setState(reqByteArray) { - const base = [0x57, 0x0f, 0x50, 0x01]; + let base = [0x57, 0x0f, 0x50, 0x01]; return this._operateBot([].concat(base, reqByteArray)); } @@ -45,15 +45,15 @@ class SwitchbotDeviceWoPlugMini extends SwitchbotDevice { * @private */ _operateBot(bytes) { - const req_buf = Buffer.from(bytes); + let req_buf = Buffer.from(bytes); return new Promise((resolve, reject) => { this._command(req_buf) .then((res_bytes) => { - const res_buf = Buffer.from(res_bytes); + let res_buf = Buffer.from(res_bytes); if (res_buf.length === 2) { - const code = res_buf.readUInt8(1); + let code = res_buf.readUInt8(1); if (code === 0x00 || code === 0x80) { - const is_on = code === 0x80; + let is_on = code === 0x80; resolve(is_on); } else { reject( diff --git a/lib/switchbot-device-wopresence.js b/lib/switchbot-device-wopresence.js index e5f28ca9..f0cd5779 100644 --- a/lib/switchbot-device-wopresence.js +++ b/lib/switchbot-device-wopresence.js @@ -1,5 +1,5 @@ "use strict"; -const SwitchbotDevice = require("./switchbot-device.js"); +let SwitchbotDevice = require("./switchbot-device.js"); class SwitchbotDeviceWoPresence extends SwitchbotDevice {} diff --git a/lib/switchbot-device-wosensorth.js b/lib/switchbot-device-wosensorth.js index 8f0579a5..340b42f5 100644 --- a/lib/switchbot-device-wosensorth.js +++ b/lib/switchbot-device-wosensorth.js @@ -1,5 +1,5 @@ "use strict"; -const SwitchbotDevice = require("./switchbot-device.js"); +let SwitchbotDevice = require("./switchbot-device.js"); class SwitchbotDeviceWoSensorTH extends SwitchbotDevice {} diff --git a/lib/switchbot-device-wostrip.js b/lib/switchbot-device-wostrip.js index db444e61..37516788 100644 --- a/lib/switchbot-device-wostrip.js +++ b/lib/switchbot-device-wostrip.js @@ -1,5 +1,5 @@ "use strict"; -const SwitchbotDevice = require("./switchbot-device.js"); +let SwitchbotDevice = require("./switchbot-device.js"); /** * @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/colorbulb.md @@ -16,7 +16,7 @@ class SwitchbotDeviceWoStrip extends SwitchbotDevice { * @private */ _setState(reqByteArray) { - const base = [0x57, 0x0f, 0x49, 0x01]; + let base = [0x57, 0x0f, 0x49, 0x01]; return this._operateBot([].concat(base, reqByteArray)); } @@ -143,15 +143,15 @@ class SwitchbotDeviceWoStrip extends SwitchbotDevice { * @private */ _operateBot(bytes) { - const req_buf = Buffer.from(bytes); + let req_buf = Buffer.from(bytes); return new Promise((resolve, reject) => { this._command(req_buf) .then((res_bytes) => { - const res_buf = Buffer.from(res_bytes); + let res_buf = Buffer.from(res_bytes); if (res_buf.length === 2) { - const code = res_buf.readUInt8(1); + let code = res_buf.readUInt8(1); if (code === 0x00 || code === 0x80) { - const is_on = code === 0x80; + let is_on = code === 0x80; resolve(is_on); } else { reject( diff --git a/lib/switchbot-device.js b/lib/switchbot-device.js index a09e38e0..70bb33df 100644 --- a/lib/switchbot-device.js +++ b/lib/switchbot-device.js @@ -1,6 +1,6 @@ "use strict"; -const parameterChecker = require("./parameter-checker.js"); -const switchbotAdvertising = require("./switchbot-advertising.js"); +let parameterChecker = require("./parameter-checker.js"); +let switchbotAdvertising = require("./switchbot-advertising.js"); class SwitchbotDevice { /* ------------------------------------------------------------------ @@ -26,7 +26,7 @@ class SwitchbotDevice { this._COMMAND_TIMEOUT_MSEC = 3000; // Save the device information - const ad = switchbotAdvertising.parse(peripheral); + let ad = switchbotAdvertising.parse(peripheral); this._id = ad.id; this._address = ad.address; this._model = ad.serviceData.model; @@ -105,7 +105,7 @@ class SwitchbotDevice { } // Check the connection state - const state = this.connectionState; + let state = this.connectionState; if (state === "connected") { resolve(); return; @@ -155,7 +155,7 @@ class SwitchbotDevice { _getCharacteristics() { return new Promise((resolve, reject) => { // Set timeout timer - const timer = setTimeout(() => { + let timer = setTimeout(() => { this._ondisconnect_internal = () => {}; timer = null; reject( @@ -179,20 +179,20 @@ class SwitchbotDevice { // Discover services and characteristics (async () => { - const service_list = await this._discoverServices(); + let service_list = await this._discoverServices(); if (!timer) { throw new Error(""); } - const chars = { + let chars = { write: null, notify: null, device: null, }; - for (const service of service_list) { - const char_list = await this._discoverCharacteristics(service); - for (const char of char_list) { + for (let service of service_list) { + let char_list = await this._discoverCharacteristics(service); + for (let char of char_list) { if (char.uuid === this._CHAR_UUID_WRITE) { chars.write = char; } else if (char.uuid === this._CHAR_UUID_NOTIFY) { @@ -230,8 +230,8 @@ class SwitchbotDevice { return; } - const service = null; - for (const s of service_list) { + let service = null; + for (let s of service_list) { if (s.uuid === this._SERV_UUID_PRIMARY) { service = s; break; @@ -260,7 +260,7 @@ class SwitchbotDevice { _subscribe() { return new Promise((resolve, reject) => { - const char = this._chars.notify; + let char = this._chars.notify; if (!char) { reject(new Error("No notify characteristic was found.")); return; @@ -280,7 +280,7 @@ class SwitchbotDevice { _unsubscribe() { return new Promise((resolve) => { - const char = this._chars.notify; + let char = this._chars.notify; if (!char) { resolve(); return; @@ -307,7 +307,7 @@ class SwitchbotDevice { return new Promise((resolve, reject) => { this._was_connected_explicitly = false; // Check the connection state - const state = this._peripheral.state; + let state = this._peripheral.state; if (state === "disconnected") { resolve(); return; @@ -351,7 +351,7 @@ class SwitchbotDevice { * ---------------------------------------------------------------- */ getDeviceName() { return new Promise((resolve, reject) => { - const name = ""; + let name = ""; this._connect() .then(() => { if (!this._chars.device) { @@ -392,7 +392,7 @@ class SwitchbotDevice { setDeviceName(name) { return new Promise((resolve, reject) => { // Check the parameters - const valid = parameterChecker.check( + let valid = parameterChecker.check( { name: name }, { name: { required: true, type: "string", minBytes: 1, maxBytes: 100 }, @@ -404,7 +404,7 @@ class SwitchbotDevice { return; } - const buf = Buffer.from(name, "utf8"); + let buf = Buffer.from(name, "utf8"); this._connect() .then(() => { if (!this._chars.device) { @@ -439,7 +439,7 @@ class SwitchbotDevice { return; } - const res_buf = null; + let res_buf = null; this._connect() .then(() => { @@ -463,7 +463,7 @@ class SwitchbotDevice { _waitCommandResponse() { return new Promise((resolve, reject) => { - const timer = setTimeout(() => { + let timer = setTimeout(() => { timer = null; this._onnotify_internal = () => {}; reject(new Error("COMMAND_TIMEOUT")); @@ -484,7 +484,7 @@ class SwitchbotDevice { _read(char) { return new Promise((resolve, reject) => { // Set a timeout timer - const timer = setTimeout(() => { + let timer = setTimeout(() => { reject("READ_TIMEOUT"); }, this._READ_TIMEOUT_MSEC); @@ -507,7 +507,7 @@ class SwitchbotDevice { _write(char, buf) { return new Promise((resolve, reject) => { // Set a timeout timer - const timer = setTimeout(() => { + let timer = setTimeout(() => { reject("WRITE_TIMEOUT"); }, this._WRITE_TIMEOUT_MSEC); diff --git a/lib/switchbot.js b/lib/switchbot.js index 474872ff..96afaf76 100644 --- a/lib/switchbot.js +++ b/lib/switchbot.js @@ -1,17 +1,17 @@ "use strict"; -const parameterChecker = require("./parameter-checker.js"); -const switchbotAdvertising = require("./switchbot-advertising.js"); +let parameterChecker = require("./parameter-checker.js"); +let switchbotAdvertising = require("./switchbot-advertising.js"); -const SwitchbotDevice = require("./switchbot-device.js"); -const SwitchbotDeviceWoHand = require("./switchbot-device-wohand.js"); -const SwitchbotDeviceWoCurtain = require("./switchbot-device-wocurtain.js"); -const SwitchbotDeviceWoPresence = require("./switchbot-device-wopresence.js"); -const SwitchbotDeviceWoContact = require("./switchbot-device-wocontact.js"); -const SwitchbotDeviceWoSensorTH = require("./switchbot-device-wosensorth.js"); -const SwitchbotDeviceWoHumi = require("./switchbot-device-wohumi.js"); -const SwitchbotDeviceWoPlugMini = require("./switchbot-device-woplugmini.js"); -const SwitchbotDeviceWoBulb = require("./switchbot-device-wobulb.js"); -const SwitchbotDeviceWoStrip = require("./switchbot-device-wostrip.js"); +let SwitchbotDevice = require("./switchbot-device.js"); +let SwitchbotDeviceWoHand = require("./switchbot-device-wohand.js"); +let SwitchbotDeviceWoCurtain = require("./switchbot-device-wocurtain.js"); +let SwitchbotDeviceWoPresence = require("./switchbot-device-wopresence.js"); +let SwitchbotDeviceWoContact = require("./switchbot-device-wocontact.js"); +let SwitchbotDeviceWoSensorTH = require("./switchbot-device-wosensorth.js"); +let SwitchbotDeviceWoHumi = require("./switchbot-device-wohumi.js"); +let SwitchbotDeviceWoPlugMini = require("./switchbot-device-woplugmini.js"); +let SwitchbotDeviceWoBulb = require("./switchbot-device-wobulb.js"); +let SwitchbotDeviceWoStrip = require("./switchbot-device-wostrip.js"); class Switchbot { /* ------------------------------------------------------------------ @@ -26,7 +26,7 @@ class Switchbot { * ---------------------------------------------------------------- */ constructor(params) { // Check parameters - const noble = null; + let noble = null; if (params && params.noble) { noble = params.noble; } else { @@ -83,9 +83,9 @@ class Switchbot { * `SwitchbotDevice` objects representing the found devices. * ---------------------------------------------------------------- */ discover(params = {}) { - const promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { // Check the parameters - const valid = parameterChecker.check( + let valid = parameterChecker.check( params, { duration: { required: false, type: "integer", min: 1, max: 60000 }, @@ -110,7 +110,7 @@ class Switchbot { } // Determine the values of the parameters - const p = { + let p = { duration: params.duration || this._DEFAULT_DISCOVERY_DURATION, model: params.model || "", id: params.id || "", @@ -120,16 +120,16 @@ class Switchbot { // Initialize the noble object this._init() .then(() => { - const peripherals = {}; - const timer = null; - const finishDiscovery = () => { + let peripherals = {}; + let timer = null; + let finishDiscovery = () => { if (timer) { clearTimeout(timer); } this.noble.removeAllListeners("discover"); this.noble.stopScanning(); - const device_list = []; - for (const addr in peripherals) { + let device_list = []; + for (let addr in peripherals) { device_list.push(peripherals[addr]); } resolve(device_list); @@ -137,11 +137,11 @@ class Switchbot { // Set a handler for the 'discover' event this.noble.on("discover", (peripheral) => { - const device = this._getDeviceObject(peripheral, p.id, p.model); + let device = this._getDeviceObject(peripheral, p.id, p.model); if (!device) { return; } - const id = device.id; + let id = device.id; peripherals[id] = device; if (this.ondiscover && typeof this.ondiscover === "function") { @@ -177,13 +177,13 @@ class Switchbot { } _init() { - const promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { switch (this.noble.state) { case "poweredOn": resolve(); return; case ("unsupported", "unauthorized", "poweredOff"): - const err = new Error( + let err = new Error( "Failed to initialize the Noble object: " + this.noble.state ); reject(err); @@ -193,7 +193,7 @@ class Switchbot { if (state === "poweredOn") { resolve(); } else { - const err = new Error( + let err = new Error( "Failed to initialize the Noble object: " + state ); reject(err); @@ -205,9 +205,9 @@ class Switchbot { } _getDeviceObject(peripheral, id, model) { - const ad = switchbotAdvertising.parse(peripheral, this.onlog); + let ad = switchbotAdvertising.parse(peripheral, this.onlog); if (this._filterAdvertising(ad, id, model)) { - const device = null; + let device = null; switch (ad.serviceData.model) { case "H": device = new SwitchbotDeviceWoHand(peripheral, this.noble); @@ -258,7 +258,7 @@ class Switchbot { } if (id) { id = id.toLowerCase().replace(/\:/g, ""); - const ad_id = ad.address.toLowerCase().replace(/[^a-z0-9]/g, ""); + let ad_id = ad.address.toLowerCase().replace(/[^a-z0-9]/g, ""); if (ad_id !== id) { return false; } @@ -324,9 +324,9 @@ class Switchbot { * Nothing will be passed to the `resolve()`. * ---------------------------------------------------------------- */ startScan(params) { - const promise = new Promise((resolve, reject) => { + let promise = new Promise((resolve, reject) => { // Check the parameters - const valid = parameterChecker.check( + let valid = parameterChecker.check( params, { model: { @@ -352,14 +352,14 @@ class Switchbot { this._init() .then(() => { // Determine the values of the parameters - const p = { + let p = { model: params.model || "", id: params.id || "", }; // Set a handler for the 'discover' event this.noble.on("discover", (peripheral) => { - const ad = switchbotAdvertising.parse(peripheral, this.onlog); + let ad = switchbotAdvertising.parse(peripheral, this.onlog); if (this._filterAdvertising(ad, p.id, p.model)) { if ( this.onadvertisement && @@ -419,7 +419,7 @@ class Switchbot { wait(msec) { return new Promise((resolve, reject) => { // Check the parameters - const valid = parameterChecker.check( + let valid = parameterChecker.check( { msec: msec }, { msec: { required: true, type: "integer", min: 0 }, diff --git a/package-lock.json b/package-lock.json index f557df39..2dc84239 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-switchbot", - "version": "1.6.0", + "version": "1.6.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "node-switchbot", - "version": "1.6.0", + "version": "1.6.1", "license": "MIT", "dependencies": { "@abandonware/noble": "^1.9.2-15" @@ -2229,27 +2229,30 @@ } }, "node_modules/npm-package-arg": { - "version": "9.1.2", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-9.1.2.tgz", - "integrity": "sha512-pzd9rLEx4TfNJkovvlBSLGhq31gGu2QDexFPWT19yCDh0JgnRhlBLNo5759N0AJmBk+kQ9Y/hXoLnlgFD+ukmg==", + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-10.0.0.tgz", + "integrity": "sha512-7dkh8mRp7s0KwVHKIVJnFCJQ2B34gOGnzgBjDGyprycmARq/82SX/lhilQ95ZuacP/G/1gsS345iAkKmxWBQ2Q==", "dev": true, "dependencies": { - "hosted-git-info": "^5.0.0", - "proc-log": "^2.0.1", + "hosted-git-info": "^6.0.0", + "proc-log": "^3.0.0", "semver": "^7.3.5", - "validate-npm-package-name": "^4.0.0" + "validate-npm-package-name": "^5.0.0" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/npm-package-arg/node_modules/proc-log": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-2.0.1.tgz", - "integrity": "sha512-Kcmo2FhfDTXdcbfDH76N7uBYHINxc/8GW7UAVuVP9I+Va3uHSerrnKV6dLooga/gh7GlgzuCCr/eoldnL1muGw==", + "node_modules/npm-package-arg/node_modules/hosted-git-info": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-6.0.0.tgz", + "integrity": "sha512-NURrKJX36ihI69iCqcvN4uuIk9fHcc1C+uax/5fPh4Tr5WJnATir+QM/CMJNKrcOOvxQDsAdS5C9oJliM80X7g==", "dev": true, + "dependencies": { + "lru-cache": "^7.5.1" + }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, "node_modules/npm-packlist": { @@ -2279,45 +2282,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/npm-pick-manifest/node_modules/hosted-git-info": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-6.0.0.tgz", - "integrity": "sha512-NURrKJX36ihI69iCqcvN4uuIk9fHcc1C+uax/5fPh4Tr5WJnATir+QM/CMJNKrcOOvxQDsAdS5C9oJliM80X7g==", - "dev": true, - "dependencies": { - "lru-cache": "^7.5.1" - }, - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, - "node_modules/npm-pick-manifest/node_modules/npm-package-arg": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-10.0.0.tgz", - "integrity": "sha512-7dkh8mRp7s0KwVHKIVJnFCJQ2B34gOGnzgBjDGyprycmARq/82SX/lhilQ95ZuacP/G/1gsS345iAkKmxWBQ2Q==", - "dev": true, - "dependencies": { - "hosted-git-info": "^6.0.0", - "proc-log": "^3.0.0", - "semver": "^7.3.5", - "validate-npm-package-name": "^5.0.0" - }, - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, - "node_modules/npm-pick-manifest/node_modules/validate-npm-package-name": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-5.0.0.tgz", - "integrity": "sha512-YuKoXDAhBYxY7SfOKxHBDoSyENFeW5VvIIQp2TGQuit8gpK6MnWaQelBKxso72DoxTZfZdcP3W90LqpSkgPzLQ==", - "dev": true, - "dependencies": { - "builtins": "^5.0.0" - }, - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, "node_modules/npm-registry-fetch": { "version": "14.0.2", "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-14.0.2.tgz", @@ -2336,18 +2300,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/npm-registry-fetch/node_modules/hosted-git-info": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-6.0.0.tgz", - "integrity": "sha512-NURrKJX36ihI69iCqcvN4uuIk9fHcc1C+uax/5fPh4Tr5WJnATir+QM/CMJNKrcOOvxQDsAdS5C9oJliM80X7g==", - "dev": true, - "dependencies": { - "lru-cache": "^7.5.1" - }, - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, "node_modules/npm-registry-fetch/node_modules/make-fetch-happen": { "version": "11.0.1", "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-11.0.1.tgz", @@ -2392,33 +2344,6 @@ "encoding": "^0.1.13" } }, - "node_modules/npm-registry-fetch/node_modules/npm-package-arg": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-10.0.0.tgz", - "integrity": "sha512-7dkh8mRp7s0KwVHKIVJnFCJQ2B34gOGnzgBjDGyprycmARq/82SX/lhilQ95ZuacP/G/1gsS345iAkKmxWBQ2Q==", - "dev": true, - "dependencies": { - "hosted-git-info": "^6.0.0", - "proc-log": "^3.0.0", - "semver": "^7.3.5", - "validate-npm-package-name": "^5.0.0" - }, - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, - "node_modules/npm-registry-fetch/node_modules/validate-npm-package-name": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-5.0.0.tgz", - "integrity": "sha512-YuKoXDAhBYxY7SfOKxHBDoSyENFeW5VvIIQp2TGQuit8gpK6MnWaQelBKxso72DoxTZfZdcP3W90LqpSkgPzLQ==", - "dev": true, - "dependencies": { - "builtins": "^5.0.0" - }, - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, "node_modules/npmlog": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", @@ -2522,9 +2447,9 @@ } }, "node_modules/pacote": { - "version": "15.0.1", - "resolved": "https://registry.npmjs.org/pacote/-/pacote-15.0.1.tgz", - "integrity": "sha512-91Po/ZZE5fIEkbesHwsZPNae7SczIN8pSD2od96NMCfA2gGzdeEVY4CAFfXZKi+lfSEOlFIsKadRrYPj7nR/PA==", + "version": "15.0.2", + "resolved": "https://registry.npmjs.org/pacote/-/pacote-15.0.2.tgz", + "integrity": "sha512-Gj4w436jiM9/0574JGI8nxpsuXssp5OhyBhnWijvzUVJdU5GvNvnYUgd5WA6mr6ImOQ7JqWqdA44ixBqqMfyZQ==", "dev": true, "dependencies": { "@npmcli/git": "^4.0.0", @@ -2534,7 +2459,7 @@ "cacache": "^17.0.0", "fs-minipass": "^2.1.0", "minipass": "^3.1.6", - "npm-package-arg": "^9.0.0", + "npm-package-arg": "^10.0.0", "npm-packlist": "^7.0.0", "npm-pick-manifest": "^8.0.0", "npm-registry-fetch": "^14.0.0", @@ -3370,15 +3295,15 @@ } }, "node_modules/validate-npm-package-name": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-4.0.0.tgz", - "integrity": "sha512-mzR0L8ZDktZjpX4OB46KT+56MAhl4EIazWP/+G/HPGuvfdaqg4YsCdtOm6U9+LOFyYDoh4dpnpxZRB9MQQns5Q==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-5.0.0.tgz", + "integrity": "sha512-YuKoXDAhBYxY7SfOKxHBDoSyENFeW5VvIIQp2TGQuit8gpK6MnWaQelBKxso72DoxTZfZdcP3W90LqpSkgPzLQ==", "dev": true, "dependencies": { "builtins": "^5.0.0" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, "node_modules/webidl-conversions": { @@ -5260,22 +5185,25 @@ "dev": true }, "npm-package-arg": { - "version": "9.1.2", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-9.1.2.tgz", - "integrity": "sha512-pzd9rLEx4TfNJkovvlBSLGhq31gGu2QDexFPWT19yCDh0JgnRhlBLNo5759N0AJmBk+kQ9Y/hXoLnlgFD+ukmg==", + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-10.0.0.tgz", + "integrity": "sha512-7dkh8mRp7s0KwVHKIVJnFCJQ2B34gOGnzgBjDGyprycmARq/82SX/lhilQ95ZuacP/G/1gsS345iAkKmxWBQ2Q==", "dev": true, "requires": { - "hosted-git-info": "^5.0.0", - "proc-log": "^2.0.1", + "hosted-git-info": "^6.0.0", + "proc-log": "^3.0.0", "semver": "^7.3.5", - "validate-npm-package-name": "^4.0.0" + "validate-npm-package-name": "^5.0.0" }, "dependencies": { - "proc-log": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-2.0.1.tgz", - "integrity": "sha512-Kcmo2FhfDTXdcbfDH76N7uBYHINxc/8GW7UAVuVP9I+Va3uHSerrnKV6dLooga/gh7GlgzuCCr/eoldnL1muGw==", - "dev": true + "hosted-git-info": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-6.0.0.tgz", + "integrity": "sha512-NURrKJX36ihI69iCqcvN4uuIk9fHcc1C+uax/5fPh4Tr5WJnATir+QM/CMJNKrcOOvxQDsAdS5C9oJliM80X7g==", + "dev": true, + "requires": { + "lru-cache": "^7.5.1" + } } } }, @@ -5298,38 +5226,6 @@ "npm-normalize-package-bin": "^3.0.0", "npm-package-arg": "^10.0.0", "semver": "^7.3.5" - }, - "dependencies": { - "hosted-git-info": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-6.0.0.tgz", - "integrity": "sha512-NURrKJX36ihI69iCqcvN4uuIk9fHcc1C+uax/5fPh4Tr5WJnATir+QM/CMJNKrcOOvxQDsAdS5C9oJliM80X7g==", - "dev": true, - "requires": { - "lru-cache": "^7.5.1" - } - }, - "npm-package-arg": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-10.0.0.tgz", - "integrity": "sha512-7dkh8mRp7s0KwVHKIVJnFCJQ2B34gOGnzgBjDGyprycmARq/82SX/lhilQ95ZuacP/G/1gsS345iAkKmxWBQ2Q==", - "dev": true, - "requires": { - "hosted-git-info": "^6.0.0", - "proc-log": "^3.0.0", - "semver": "^7.3.5", - "validate-npm-package-name": "^5.0.0" - } - }, - "validate-npm-package-name": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-5.0.0.tgz", - "integrity": "sha512-YuKoXDAhBYxY7SfOKxHBDoSyENFeW5VvIIQp2TGQuit8gpK6MnWaQelBKxso72DoxTZfZdcP3W90LqpSkgPzLQ==", - "dev": true, - "requires": { - "builtins": "^5.0.0" - } - } } }, "npm-registry-fetch": { @@ -5347,15 +5243,6 @@ "proc-log": "^3.0.0" }, "dependencies": { - "hosted-git-info": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-6.0.0.tgz", - "integrity": "sha512-NURrKJX36ihI69iCqcvN4uuIk9fHcc1C+uax/5fPh4Tr5WJnATir+QM/CMJNKrcOOvxQDsAdS5C9oJliM80X7g==", - "dev": true, - "requires": { - "lru-cache": "^7.5.1" - } - }, "make-fetch-happen": { "version": "11.0.1", "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-11.0.1.tgz", @@ -5391,27 +5278,6 @@ "minipass-sized": "^1.0.3", "minizlib": "^2.1.2" } - }, - "npm-package-arg": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-10.0.0.tgz", - "integrity": "sha512-7dkh8mRp7s0KwVHKIVJnFCJQ2B34gOGnzgBjDGyprycmARq/82SX/lhilQ95ZuacP/G/1gsS345iAkKmxWBQ2Q==", - "dev": true, - "requires": { - "hosted-git-info": "^6.0.0", - "proc-log": "^3.0.0", - "semver": "^7.3.5", - "validate-npm-package-name": "^5.0.0" - } - }, - "validate-npm-package-name": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-5.0.0.tgz", - "integrity": "sha512-YuKoXDAhBYxY7SfOKxHBDoSyENFeW5VvIIQp2TGQuit8gpK6MnWaQelBKxso72DoxTZfZdcP3W90LqpSkgPzLQ==", - "dev": true, - "requires": { - "builtins": "^5.0.0" - } } } }, @@ -5488,9 +5354,9 @@ } }, "pacote": { - "version": "15.0.1", - "resolved": "https://registry.npmjs.org/pacote/-/pacote-15.0.1.tgz", - "integrity": "sha512-91Po/ZZE5fIEkbesHwsZPNae7SczIN8pSD2od96NMCfA2gGzdeEVY4CAFfXZKi+lfSEOlFIsKadRrYPj7nR/PA==", + "version": "15.0.2", + "resolved": "https://registry.npmjs.org/pacote/-/pacote-15.0.2.tgz", + "integrity": "sha512-Gj4w436jiM9/0574JGI8nxpsuXssp5OhyBhnWijvzUVJdU5GvNvnYUgd5WA6mr6ImOQ7JqWqdA44ixBqqMfyZQ==", "dev": true, "requires": { "@npmcli/git": "^4.0.0", @@ -5500,7 +5366,7 @@ "cacache": "^17.0.0", "fs-minipass": "^2.1.0", "minipass": "^3.1.6", - "npm-package-arg": "^9.0.0", + "npm-package-arg": "^10.0.0", "npm-packlist": "^7.0.0", "npm-pick-manifest": "^8.0.0", "npm-registry-fetch": "^14.0.0", @@ -6112,9 +5978,9 @@ } }, "validate-npm-package-name": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-4.0.0.tgz", - "integrity": "sha512-mzR0L8ZDktZjpX4OB46KT+56MAhl4EIazWP/+G/HPGuvfdaqg4YsCdtOm6U9+LOFyYDoh4dpnpxZRB9MQQns5Q==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-5.0.0.tgz", + "integrity": "sha512-YuKoXDAhBYxY7SfOKxHBDoSyENFeW5VvIIQp2TGQuit8gpK6MnWaQelBKxso72DoxTZfZdcP3W90LqpSkgPzLQ==", "dev": true, "requires": { "builtins": "^5.0.0" diff --git a/package.json b/package.json index 1c61d00d..e6b9391a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-switchbot", - "version": "1.6.0", + "version": "1.6.1", "description": "The node-switchbot is a Node.js module which allows you to control your Switchbot Devices through Bluetooth (BLE).", "main": "./lib/switchbot.js", "files": [