Skip to content

Commit

Permalink
v2.1.1 (#522)
Browse files Browse the repository at this point in the history
## [Version 2.1.1](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v2.1.1) (2022-10-14)

## What's Changed

- Fixed issue were `CustomOff` would send incorrect commands. Also Resolves [#409](#409).
- Fixed issue were IR Commands were not sent from IR Devices, Thanks [@jonzhan](https://github.com/jonzhan). [#520](#520)
- Fixed issue with Curtain not refreshing moving status. [#517](#517)
- Housekeeping and updated dependencies.

**Full Changelog**: v2.1.0...v2.1.1
  • Loading branch information
donavanbecker committed Oct 14, 2022
1 parent c582a86 commit ed009a0
Show file tree
Hide file tree
Showing 14 changed files with 176 additions and 120 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

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

## [Version 2.1.1](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v2.1.1) (2022-10-14)

## What's Changed

- Fixed issue were `CustomOff` would send incorrect commands. Also Resolves [#409](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/409).
- Fixed issue were IR Commands were not sent from IR Devices, Thanks [@jonzhan](https://github.com/jonzhan). [#520](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/520)
- Fixed issue with Curtain not refreshing moving status. [#517](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/517)
- Housekeeping and updated dependencies.

**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v2.1.0...v2.1.1

## [Version 2.1.0](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v2.1.0) (2022-10-13)

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

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Homebridge SwitchBot",
"name": "@switchbot/homebridge-switchbot",
"version": "2.1.0",
"version": "2.1.1",
"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 <support@wondertechlabs.com> (https://github.com/SwitchBot)",
"license": "ISC",
Expand Down
4 changes: 2 additions & 2 deletions src/device/curtain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class Curtain {

// update slide progress
interval(this.updateRate * 1000)
.pipe(skipWhile(() => this.curtainUpdateInProgress))
//.pipe(skipWhile(() => this.curtainUpdateInProgress))
.subscribe(async () => {
if (this.PositionState === this.platform.Characteristic.PositionState.STOPPED) {
return;
Expand Down Expand Up @@ -652,7 +652,7 @@ export class Curtain {
}
} catch (e: any) {
this.apiError(e);
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushBrightnessChanges with ${this.device.connectionType}`
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}`
+ ` Connection, Error Message: ${superStringify(e.message)}`,
);
}
Expand Down
46 changes: 25 additions & 21 deletions src/irdevice/airconditioner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ export class AirConditioner {

constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
// default placeholders
this.logs(device);
this.config(device);
this.pushOnChanges(device);
this.context(device);
this.logs({ device });
this.config({ device });
this.pushOnChanges({ device });
this.context({ device });

// set accessory information
accessory
.getService(this.platform.Service.AccessoryInformation)!
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision(accessory, device))
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision({ accessory, device }))
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
.updateValue(this.FirmwareRevision(accessory, device));
.updateValue(this.FirmwareRevision({ accessory, device }));

// get the Television service if it exists, otherwise create a new Television service
// you can create multiple services for each accessory
Expand Down Expand Up @@ -238,7 +238,7 @@ export class AirConditioner {
await this.pushChanges(body);
}

async pushChanges(body): Promise<void> {
async pushChanges(body: any): Promise<void> {
if (this.device.connectionType === 'OpenAPI') {
try {
// Make Push On request to the API
Expand Down Expand Up @@ -285,7 +285,7 @@ export class AirConditioner {
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
this.updateHomeKitCharacteristics();
} catch (e: any) {
this.apiError(e);
this.apiError({ e });
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
+ ` Error Message: ${superStringify(e.message)}`,
);
Expand Down Expand Up @@ -334,8 +334,6 @@ export class AirConditioner {

async ActiveSet(value: CharacteristicValue): Promise<void> {
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
this.Active = value;
this.accessory.context.Active = this.Active;
if (value === this.platform.Characteristic.Active.INACTIVE) {
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
this.pushAirConditionerOffChanges();
Expand All @@ -347,6 +345,12 @@ export class AirConditioner {
this.pushAirConditionerStatusChanges();
}
}
/**
* pushAirConditionerOnChanges and pushAirConditionerOffChanges above assume they are measuring the state of the accessory BEFORE
* they are updated, so we are only updating the accessory state after calling the above.
*/
this.Active = value;
this.accessory.context.Active = this.Active;
}

async TargetHeaterCoolerStateGet(): Promise<CharacteristicValue> {
Expand Down Expand Up @@ -557,7 +561,7 @@ export class AirConditioner {
}
}

async commandType() {
async commandType(): Promise<string> {
let commandType: string;
if (this.device.customize) {
commandType = 'customize';
Expand All @@ -567,7 +571,7 @@ export class AirConditioner {
return commandType;
}

async commandOn() {
async commandOn(): Promise<string> {
let command: string;
if (this.device.customize && this.device.customOn) {
command = this.device.customOn;
Expand All @@ -577,10 +581,10 @@ export class AirConditioner {
return command;
}

async commandOff() {
async commandOff(): Promise<string> {
let command: string;
if (this.device.customize && this.device.customOn) {
command = this.device.customOn;
if (this.device.customize && this.device.customOff) {
command = this.device.customOff;
} else {
command = 'turnOff';
}
Expand Down Expand Up @@ -618,7 +622,7 @@ export class AirConditioner {
}
}

async apiError(e: any): Promise<void> {
async apiError({ e }: { e: any; }): Promise<void> {
this.coolerService.updateCharacteristic(this.platform.Characteristic.Active, e);
this.coolerService.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
Expand All @@ -628,7 +632,7 @@ export class AirConditioner {
this.coolerService.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
}

FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
FirmwareRevision({ accessory, device }: { accessory: PlatformAccessory; device: irdevice & irDevicesConfig; }): string {
let FirmwareRevision: string;
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
Expand All @@ -644,7 +648,7 @@ export class AirConditioner {
return FirmwareRevision;
}

async context(device: irdevice & irDevicesConfig) {
async context({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
if (this.Active === undefined) {
this.Active = this.platform.Characteristic.Active.INACTIVE;
} else {
Expand All @@ -664,7 +668,7 @@ export class AirConditioner {
}
}

async config(device: irdevice & irDevicesConfig): Promise<void> {
async config({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
let config = {};
if (device.irair) {
config = device.irair;
Expand All @@ -683,7 +687,7 @@ export class AirConditioner {
}
}

async logs(device: irdevice & irDevicesConfig): Promise<void> {
async logs({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
if (this.platform.debugMode) {
this.deviceLogging = this.accessory.context.logging = 'debugMode';
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
Expand All @@ -700,7 +704,7 @@ export class AirConditioner {
}


async pushOnChanges(device: irdevice & irDevicesConfig): Promise<void> {
async pushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
if (device.irair?.pushOn) {
this.pushOn = true;
} else {
Expand Down
18 changes: 11 additions & 7 deletions src/irdevice/airpurifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,17 @@ export class AirPurifier {

async ActiveSet(value: CharacteristicValue): Promise<void> {
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
this.Active = value;
this.accessory.context.Active = this.Active;
if (value === this.platform.Characteristic.Active.INACTIVE) {
this.pushAirPurifierOffChanges();
} else {
this.pushAirPurifierOnChanges();
}
/**
* pushAirPurifierOnChanges and pushAirPurifierOffChanges above assume they are measuring the state of the accessory BEFORE
* they are updated, so we are only updating the accessory state after calling the above.
*/
this.Active = value;
this.accessory.context.Active = this.Active;
}

async TargetAirPurifierStateSet(value: CharacteristicValue): Promise<void> {
Expand Down Expand Up @@ -267,7 +271,7 @@ export class AirPurifier {
}
}

async commandType() {
async commandType(): Promise<string> {
let commandType: string;
if (this.device.customize) {
commandType = 'customize';
Expand All @@ -277,7 +281,7 @@ export class AirPurifier {
return commandType;
}

async commandOn() {
async commandOn(): Promise<string> {
let command: string;
if (this.device.customize && this.device.customOn) {
command = this.device.customOn;
Expand All @@ -287,10 +291,10 @@ export class AirPurifier {
return command;
}

async commandOff() {
async commandOff(): Promise<string> {
let command: string;
if (this.device.customize && this.device.customOn) {
command = this.device.customOn;
if (this.device.customize && this.device.customOff) {
command = this.device.customOff;
} else {
command = 'turnOff';
}
Expand Down
20 changes: 12 additions & 8 deletions src/irdevice/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ export class Camera {

async OnSet(value: CharacteristicValue): Promise<void> {
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
this.On = value;
this.accessory.context.On = this.On;
if (this.On) {
if (value) {
this.pushOnChanges();
} else {
this.pushOffChanges();
}
/**
* pushOnChanges and pushOffChanges above assume they are measuring the state of the accessory BEFORE
* they are updated, so we are only updating the accessory state after calling the above.
*/
this.On = value;
this.accessory.context.On = this.On;
}

/**
Expand Down Expand Up @@ -164,7 +168,7 @@ export class Camera {
}
}

async commandType() {
async commandType(): Promise<string> {
let commandType: string;
if (this.device.customize) {
commandType = 'customize';
Expand All @@ -174,7 +178,7 @@ export class Camera {
return commandType;
}

async commandOn() {
async commandOn(): Promise<string> {
let command: string;
if (this.device.customize && this.device.customOn) {
command = this.device.customOn;
Expand All @@ -184,10 +188,10 @@ export class Camera {
return command;
}

async commandOff() {
async commandOff(): Promise<string> {
let command: string;
if (this.device.customize && this.device.customOn) {
command = this.device.customOn;
if (this.device.customize && this.device.customOff) {
command = this.device.customOff;
} else {
command = 'turnOff';
}
Expand Down
18 changes: 11 additions & 7 deletions src/irdevice/fan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,17 @@ export class Fan {

async ActiveSet(value: CharacteristicValue): Promise<void> {
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${value}`);
this.Active = value;
this.accessory.context.Active = this.Active;
if (value === this.platform.Characteristic.Active.INACTIVE) {
this.pushFanOffChanges();
} else {
this.pushFanOnChanges();
}
/**
* pushFanOnChanges and pushFanOffChanges above assume they are measuring the state of the accessory BEFORE
* they are updated, so we are only updating the accessory state after calling the above.
*/
this.Active = value;
this.accessory.context.Active = this.Active;
}

/**
Expand Down Expand Up @@ -293,7 +297,7 @@ export class Fan {
}
}

async commandType() {
async commandType(): Promise<string> {
let commandType: string;
if (this.device.customize) {
commandType = 'customize';
Expand All @@ -303,7 +307,7 @@ export class Fan {
return commandType;
}

async commandOn() {
async commandOn(): Promise<string> {
let command: string;
if (this.device.customize && this.device.customOn) {
command = this.device.customOn;
Expand All @@ -313,10 +317,10 @@ export class Fan {
return command;
}

async commandOff() {
async commandOff(): Promise<string> {
let command: string;
if (this.device.customize && this.device.customOn) {
command = this.device.customOn;
if (this.device.customize && this.device.customOff) {
command = this.device.customOff;
} else {
command = 'turnOff';
}
Expand Down
Loading

0 comments on commit ed009a0

Please sign in to comment.