Skip to content

Commit b59e1db

Browse files
donavanbeckergravity-addictiondnicolsonbanboobee
authored
v1.8.2 (#197)
Co-authored-by: G <[email protected]> Co-authored-by: Dave Nicolson <[email protected]> Co-authored-by: banboobee <[email protected]>
1 parent 59e2dc1 commit b59e1db

14 files changed

+745
-797
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)
44

5+
## [Version 1.8.2](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.8.2) (2023-07-25)
6+
7+
## What's Changed
8+
- Added Lint Script, Thanks [@dnicolson](https://github.com/dnicolson) [#195](https://github.com/OpenWonderLabs/node-switchbot/pull/195)
9+
- Fixed a Linting Issues, Thanks [@dnicolson](https://github.com/dnicolson) [#196](https://github.com/OpenWonderLabs/node-switchbot/pull/196)
10+
- Fixed 'TypeError: Assignment to constant variable', Thanks [@banboobee](https://github.com/banboobee) [#194](https://github.com/OpenWonderLabs/node-switchbot/pull/194)
11+
- Fix issue of re-assigning to constant for Temperature, Thanks [@gravity-addiction](https://github.com/gravity-addiction) [#191](https://github.com/OpenWonderLabs/node-switchbot/pull/191)
12+
- Housekeeping and update dependencies
13+
14+
**Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.8.1...v1.8.2
15+
516
## [Version 1.8.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.8.1) (2023-04-08)
617

718
## What's Changed

lib/parameter-checker.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"use strict";
22

3+
const { Buffer } = require('buffer');
4+
35
class ParameterChecker {
46
constructor() {
57
this._error = null;
@@ -492,7 +494,7 @@ class ParameterChecker {
492494
}
493495
}
494496
if (rule.pattern instanceof RegExp) {
495-
if (!rule.pattern.test(v)) {
497+
if (!rule.pattern.test(value)) {
496498
this._error = {
497499
code: "PATTERN_UNMATCH",
498500
message: "The `" + name + "` does not conform with the pattern.",

lib/switchbot-advertising.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"use strict";
22

3+
const { Buffer } = require('buffer');
4+
35
class SwitchbotAdvertising {
46
constructor() {}
57

@@ -201,8 +203,7 @@ class SwitchbotAdvertising {
201203

202204
const temp_sign = byte4 & 0b10000000 ? 1 : -1;
203205
const temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
204-
const temp_f = (temp_c * 9 / 5) + 32;
205-
temp_f = Math.round(temp_f * 10) / 10;
206+
const temp_f = Math.round(((temp_c * 9 / 5) + 32) * 10) / 10;
206207

207208
const data = {
208209
model: "T",
@@ -408,7 +409,7 @@ class SwitchbotAdvertising {
408409
return null;
409410
}
410411
const byte1 = manufacturerData.readUInt8(1);//power and light status
411-
const byte2 = manufacturerData.readUInt8(2);//bulb brightness
412+
//const byte2 = manufacturerData.readUInt8(2);//bulb brightness
412413
const byte3 = manufacturerData.readUInt8(3);//bulb R
413414
const byte4 = manufacturerData.readUInt8(4);//bulb G
414415
const byte5 = manufacturerData.readUInt8(5);//bulb B
@@ -596,8 +597,7 @@ class SwitchbotAdvertising {
596597

597598
const temp_sign = byte4 & 0b10000000 ? 1 : -1;
598599
const temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
599-
const temp_f = (temp_c * 9 / 5) + 32;
600-
temp_f = Math.round(temp_f * 10) / 10;
600+
const temp_f = Math.round(((temp_c * 9 / 5) + 32) * 10) / 10;
601601

602602
const data = {
603603
model: "i",
@@ -624,8 +624,8 @@ class SwitchbotAdvertising {
624624
return null;
625625
}
626626

627-
const byte1 = buf.readUInt8(1);//power and light status
628-
const byte2 = buf.readUInt8(2);//bulb brightness
627+
//const byte1 = buf.readUInt8(1);//power and light status
628+
//const byte2 = buf.readUInt8(2);//bulb brightness
629629
const byte3 = buf.readUInt8(3);//bulb R
630630
const byte4 = buf.readUInt8(4);//bulb G
631631
const byte5 = buf.readUInt8(5);//bulb B

lib/switchbot-device-woblindtilt.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
"use strict";
2+
3+
const { Buffer } = require('buffer');
4+
25
let SwitchbotDevice = require("./switchbot-device.js");
36

47
class SwitchbotDeviceWoBlindTilt extends SwitchbotDevice {

lib/switchbot-device-wobulb.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
"use strict";
2+
3+
const { Buffer } = require('buffer');
4+
25
const SwitchbotDevice = require("./switchbot-device.js");
36

47
/**

lib/switchbot-device-wocurtain.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
"use strict";
2+
3+
const { Buffer } = require('buffer');
4+
25
const SwitchbotDevice = require("./switchbot-device.js");
36

47
class SwitchbotDeviceWoCurtain extends SwitchbotDevice {

lib/switchbot-device-wohand.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
"use strict";
2+
3+
const { Buffer } = require('buffer');
4+
25
const SwitchbotDevice = require("./switchbot-device.js");
36

47
class SwitchbotDeviceWoHand extends SwitchbotDevice {

lib/switchbot-device-wohumi.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
"use strict";
2+
3+
const { Buffer } = require('buffer');
4+
25
const SwitchbotDevice = require("./switchbot-device.js");
36

47
class SwitchbotDeviceWoHumi extends SwitchbotDevice {

lib/switchbot-device-woplugmini.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
"use strict";
2+
3+
const { Buffer } = require('buffer');
4+
25
const SwitchbotDevice = require("./switchbot-device.js");
36

47
/**

lib/switchbot-device-wostrip.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
"use strict";
2+
3+
const { Buffer } = require('buffer');
4+
25
const SwitchbotDevice = require("./switchbot-device.js");
36

47
/**

0 commit comments

Comments
 (0)