Skip to content

Commit

Permalink
v1.12.3 (#248)
Browse files Browse the repository at this point in the history
## [Version 1.12.3](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.12.3) (2022-02-05)

## What's Changed

- Housekeeping and updated dependencies.

**Full Changelog**: v1.12.2...v1.12.3
  • Loading branch information
donavanbecker authored Feb 5, 2022
1 parent 1695cb6 commit 6544fe7
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 77 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

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

## [Version 1.12.3](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.12.3) (2022-02-05)

## What's Changed

- Housekeeping and updated dependencies.

**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.12.2...v1.12.3

## [Version 1.12.2](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.12.2) (2022-02-02)

## What's Changed
Expand Down
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Homebridge SwitchBot",
"name": "@switchbot/homebridge-switchbot",
"version": "1.12.2",
"version": "1.12.3",
"description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",
"author": "SwitchBot <[email protected]> (https://github.com/SwitchBot)",
"license": "ISC",
Expand Down Expand Up @@ -59,7 +59,7 @@
"rxjs": "^7.5.2"
},
"devDependencies": {
"@types/node": "^17.0.14",
"@types/node": "^17.0.15",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"eslint": "^8.8.0",
Expand Down
3 changes: 1 addition & 2 deletions src/device/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ export class Bot {
.deviceId!.match(/.{1,2}/g)!
.join(':')
.toLowerCase();
this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
this.debugLog(`Bot: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
// Start to monitor advertisement packets
if (switchbot === false) {
this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection: ${switchbot}`);
Expand Down Expand Up @@ -561,7 +561,6 @@ export class Bot {
await this.openAPIpushChanges();
}
interval(5000)
.pipe(skipWhile(() => this.botUpdateInProgress))
.pipe(take(1))
.subscribe(async () => {
await this.refreshStatus();
Expand Down
78 changes: 31 additions & 47 deletions src/device/colorbulb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ export class ColorBulb {
this.Hue = 0;
this.Brightness = 0;
this.Saturation = 0;
if (device.deviceType === 'Color Bulb') {
this.ColorTemperature = 140;
}
this.ColorTemperature = 140;
this.minKelvin = 2000;
this.maxKelvin = 9000;
// this is subject we use to track when we need to POST changes to the SwitchBot API
Expand Down Expand Up @@ -125,22 +123,18 @@ export class ColorBulb {
.onSet(this.BrightnessSet.bind(this));

// handle ColorTemperature events using the ColorTemperature characteristic
if (device.deviceType === 'Color Bulb') {
this.debugLog(`Color Bulb: ${accessory.displayName} Add ColorTemperature Characteristic`);
this.lightBulbService
.getCharacteristic(this.platform.Characteristic.ColorTemperature)
.setProps({
minValue: 140,
maxValue: 500,
validValueRanges: [140, 500],
})
.onGet(() => {
return this.ColorTemperature!;
})
.onSet(this.ColorTemperatureSet.bind(this));
} else {
this.debugLog(`Color Bulb: ${accessory.displayName} ColorTemperature Characteristic Not Added`);
}
this.debugLog(`Color Bulb: ${accessory.displayName} Add ColorTemperature Characteristic`);
this.lightBulbService
.getCharacteristic(this.platform.Characteristic.ColorTemperature)
.setProps({
minValue: 140,
maxValue: 500,
validValueRanges: [140, 500],
})
.onGet(() => {
return this.ColorTemperature!;
})
.onSet(this.ColorTemperatureSet.bind(this));

// handle Hue events using the Hue characteristic
this.lightBulbService
Expand Down Expand Up @@ -251,17 +245,16 @@ export class ColorBulb {
}

// ColorTemperature
if (this.device.deviceType === 'Color Bulb') {
if (!Number.isNaN(this.colorTemperature)) {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI ColorTemperature: ${this.colorTemperature}`);
const mired = Math.round(1000000 / this.colorTemperature!);
if (!Number.isNaN(this.colorTemperature)) {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI ColorTemperature: ${this.colorTemperature}`);
const mired = Math.round(1000000 / this.colorTemperature!);

this.ColorTemperature = Number(mired);
this.ColorTemperature = Number(mired);

this.ColorTemperature = Math.max(Math.min(this.ColorTemperature, 500), 140);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${this.ColorTemperature}`);
}
this.ColorTemperature = Math.max(Math.min(this.ColorTemperature, 500), 140);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${this.ColorTemperature}`);
}

}

async refreshStatus(): Promise<void> {
Expand All @@ -271,9 +264,8 @@ export class ColorBulb {
this.power = this.deviceStatus.body.power;
this.color = this.deviceStatus.body.color;
this.brightness = this.deviceStatus.body.brightness;
if (this.device.deviceType === 'Color Bulb') {
this.colorTemperature = this.deviceStatus.body.colorTemperature;
}
this.colorTemperature = this.deviceStatus.body.colorTemperature;

this.parseStatus();
this.updateHomeKitCharacteristics();
} catch (e: any) {
Expand Down Expand Up @@ -337,7 +329,7 @@ export class ColorBulb {
}

// Push ColorTemperature Update
if (this.On && this.device.deviceType === 'Color Bulb') {
if (this.On) {
await this.pushColorTemperatureChanges();
}

Expand Down Expand Up @@ -491,13 +483,11 @@ export class ColorBulb {
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Brightness, this.Brightness);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Brightness: ${this.Brightness}`);
}
if (this.device.deviceType === 'Color Bulb') {
if (this.ColorTemperature === undefined) {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${this.ColorTemperature}`);
} else {
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, this.ColorTemperature);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic ColorTemperature: ${this.ColorTemperature}`);
}
if (this.ColorTemperature === undefined) {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${this.ColorTemperature}`);
} else {
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, this.ColorTemperature);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic ColorTemperature: ${this.ColorTemperature}`);
}
if (this.Hue === undefined) {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.Hue}`);
Expand All @@ -518,9 +508,7 @@ export class ColorBulb {
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Hue, e);
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Brightness, e);
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, e);
if (this.device.deviceType === 'Color Bulb') {
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, e);
}
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, e);
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
}

Expand Down Expand Up @@ -619,9 +607,7 @@ export class ColorBulb {
async HueSet(value: CharacteristicValue): Promise<void> {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${value}`);

if (this.device.deviceType === 'Color Bulb') {
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
}
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);

this.Hue = value;
this.doColorBulbUpdate.next();
Expand All @@ -633,9 +619,7 @@ export class ColorBulb {
async SaturationSet(value: CharacteristicValue): Promise<void> {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${value}`);

if (this.device.deviceType === 'Color Bulb') {
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
}
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);

this.Saturation = value;
this.doColorBulbUpdate.next();
Expand Down
2 changes: 1 addition & 1 deletion src/device/contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export class Contact {
.deviceId!.match(/.{1,2}/g)!
.join(':')
.toLowerCase();
this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
this.debugLog(`Contact Sensor: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
// Start to monitor advertisement packets
if (switchbot !== false) {
switchbot
Expand Down
5 changes: 2 additions & 3 deletions src/device/curtain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,8 @@ export class Curtain {
} else {
await this.openAPIpushChanges();
}
interval(5000)
.pipe(skipWhile(() => this.curtainUpdateInProgress))
.pipe(take(1))
interval(this.updateRate * 1000)
.pipe(take(2))
.subscribe(async () => {
await this.refreshStatus();
});
Expand Down
5 changes: 2 additions & 3 deletions src/device/humidifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class Humidifier {
.deviceId!.match(/.{1,2}/g)!
.join(':')
.toLowerCase();
this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
this.debugLog(`Humidifier: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
// Start to monitor advertisement packets
if (switchbot !== false) {
switchbot
Expand Down Expand Up @@ -395,7 +395,6 @@ export class Humidifier {
await this.openAPIpushChanges();
//}
interval(5000)
.pipe(skipWhile(() => this.humidifierUpdateInProgress))
.pipe(take(1))
.subscribe(async () => {
await this.refreshStatus();
Expand All @@ -410,7 +409,7 @@ export class Humidifier {
.deviceId!.match(/.{1,2}/g)!
.join(':')
.toLowerCase();
this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
this.debugLog(`Humidifier: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
if (switchbot !== false) {
switchbot
.discover({ model: 'e', quick: true, id: this.device.bleMac })
Expand Down
1 change: 0 additions & 1 deletion src/device/lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ export class Lock {
this.accessory.context.On = this.LockTargetStateCached;
}
interval(5000)
.pipe(skipWhile(() => this.lockUpdateInProgress))
.pipe(take(1))
.subscribe(async () => {
await this.refreshStatus();
Expand Down
2 changes: 1 addition & 1 deletion src/device/meter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class Meter {
.deviceId!.match(/.{1,2}/g)!
.join(':')
.toLowerCase();
this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
this.debugLog(`Meter: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
// Start to monitor advertisement packets
if (switchbot !== false) {
switchbot
Expand Down
2 changes: 1 addition & 1 deletion src/device/motion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class Motion {
.deviceId!.match(/.{1,2}/g)!
.join(':')
.toLowerCase();
this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
this.debugLog(`Motion Sensor: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
// Start to monitor advertisement packets
if (switchbot !== false) {
switchbot
Expand Down
1 change: 0 additions & 1 deletion src/device/plug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export class Plug {
this.accessory.context.On = this.OnCached;
}
interval(5000)
.pipe(skipWhile(() => this.plugUpdateInProgress))
.pipe(take(1))
.subscribe(async () => {
await this.refreshStatus();
Expand Down

0 comments on commit 6544fe7

Please sign in to comment.