Skip to content

Commit

Permalink
v2.6.2 (#723)
Browse files Browse the repository at this point in the history
## [Version 2.6.2](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v2.6.2) (2023-04-17)

## What's Changed

- Fix for Commands not being sent, [#721](#721)
- Housekeeping.

**Full Changelog**: v2.6.1....v2.6.2
  • Loading branch information
donavanbecker authored Apr 17, 2023
1 parent a678f42 commit b09e789
Show file tree
Hide file tree
Showing 24 changed files with 175 additions and 147 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

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

## [Version 2.6.2](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v2.6.2) (2023-04-17)

## What's Changed

- Fix for Commands not being sent, [#721](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/721)
- Housekeeping.

**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v2.6.1....v2.6.2

## [Version 2.6.1](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v2.6.1) (2023-04-15)

## What's Changed
Expand Down
2 changes: 1 addition & 1 deletion nodemon.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"watch": ["src"],
"ext": "ts",
"ignore": [],
"exec": "DEBUG= tsc && homebridge -T -D -P ..",
"exec": "DEBUG= tsc && homebridge -T -D -P -I ..",
"signal": "SIGTERM",
"env": {
"NODE_OPTIONS": "--trace-warnings"
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.6.1",
"version": "2.6.2",
"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
13 changes: 7 additions & 6 deletions src/device/blindtilt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,35 +629,36 @@ export class BlindTilt {
}

async openAPIpushChanges(): Promise<void> {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI pushChanges`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges`);
const hasDifferentAndRelevantHorizontalTiltAngle = (
this.mappingMode === BlindTiltMappingMode.UseTiltForDirection
&& this.TargetHorizontalTiltAngle !== this.CurrentHorizontalTiltAngle);
if ((this.TargetPosition !== this.CurrentPosition) || hasDifferentAndRelevantHorizontalTiltAngle || this.device.disableCaching) {
const [direction, position] = this.mapHomekitValuesToDeviceValues(Number(this.TargetPosition), Number(this.TargetHorizontalTiltAngle));
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Pushing ${this.TargetPosition} (device = ${direction};${position})`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Mode: ${this.Mode}`);
let body = '';
let bodyChange = '';
if (position === 100) {
body = JSON.stringify({
bodyChange = JSON.stringify({
'command': 'fullyOpen',
'commandType': 'command',
});
} else if (position === 0) {
body = JSON.stringify({
bodyChange = JSON.stringify({
'command': direction === 'up' ? 'closeUp' : 'closeDown',
'commandType': 'command',
});
} else {
body = JSON.stringify({
bodyChange = JSON.stringify({
'command': 'setPosition',
'parameter': `${direction};${position}`,
'commandType': 'command',
});
}
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
try {
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
body: bodyChange,
method: 'POST',
headers: this.platform.generateHeaders(),
});
Expand Down
7 changes: 4 additions & 3 deletions src/device/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ export class Bot {
}

async openAPIpushChanges(): Promise<void> {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI pushChanges`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges`);
if (this.multiPressCount > 0) {
this.debugLog(`${this.device.deviceType}: ${this.multiPressCount} request(s) queued.`);
this.On = true;
Expand All @@ -681,14 +681,15 @@ export class Bot {
} else {
throw new Error(`${this.device.deviceType}: ${this.accessory.displayName} Device Paramters not set for this Bot.`);
}
const body = JSON.stringify({
const bodyChange = JSON.stringify({
'command': `${command}`,
'parameter': 'default',
'commandType': 'command',
});
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
try {
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
body: bodyChange,
method: 'POST',
headers: this.platform.generateHeaders(),
});
Expand Down
22 changes: 13 additions & 9 deletions src/device/ceilinglight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,22 +489,23 @@ export class CeilingLight {
}

async openAPIpushChanges(): Promise<void> {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI pushChanges`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges`);
if (this.On !== this.accessory.context.On) {
let command = '';
if (this.On) {
command = 'turnOn';
} else {
command = 'turnOff';
}
const body = JSON.stringify({
const bodyChange = JSON.stringify({
'command': `${command}`,
'parameter': 'default',
'commandType': 'command',
});
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
try {
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
body: bodyChange,
method: 'POST',
headers: this.platform.generateHeaders(),
});
Expand Down Expand Up @@ -543,14 +544,15 @@ export class CeilingLight {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${JSON.stringify(this.Saturation)}`);
const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} rgb: ${JSON.stringify([red, green, blue])}`);
const body = JSON.stringify({
const bodyChange = JSON.stringify({
'command': 'setColor',
'parameter': `${red}:${green}:${blue}`,
'commandType': 'command',
});
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
try {
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
body: bodyChange,
method: 'POST',
headers: this.platform.generateHeaders(),
});
Expand All @@ -575,14 +577,15 @@ export class CeilingLight {
if (this.ColorTemperature !== this.accessory.context.ColorTemperature) {
const kelvin = Math.round(1000000 / Number(this.ColorTemperature));
this.cacheKelvin = kelvin;
const body = JSON.stringify({
const bodyChange = JSON.stringify({
'command': 'setColorTemperature',
'parameter': `${kelvin}`,
'commandType': 'command',
});
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
try {
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
body: bodyChange,
method: 'POST',
headers: this.platform.generateHeaders(),
});
Expand All @@ -605,14 +608,15 @@ export class CeilingLight {
async pushBrightnessChanges(): Promise<void> {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushBrightnessChanges`);
if (this.Brightness !== this.accessory.context.Brightness) {
const body = JSON.stringify({
const bodyChange = JSON.stringify({
'command': 'setBrightness',
'parameter': `${this.Brightness}`,
'commandType': 'command',
});
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
try {
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
body: bodyChange,
method: 'POST',
headers: this.platform.generateHeaders(),
});
Expand Down
20 changes: 12 additions & 8 deletions src/device/colorbulb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,14 +651,15 @@ export class ColorBulb {
} else {
command = 'turnOff';
}
const body = JSON.stringify({
const bodyChange = JSON.stringify({
'command': `${command}`,
'parameter': 'default',
'commandType': 'command',
});
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
try {
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
body: bodyChange,
method: 'POST',
headers: this.platform.generateHeaders(),
});
Expand Down Expand Up @@ -697,14 +698,15 @@ export class ColorBulb {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${JSON.stringify(this.Saturation)}`);
const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} rgb: ${JSON.stringify([red, green, blue])}`);
const body = JSON.stringify({
const bodyChange = JSON.stringify({
'command': 'setColor',
'parameter': `${red}:${green}:${blue}`,
'commandType': 'command',
});
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
try {
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
body: bodyChange,
method: 'POST',
headers: this.platform.generateHeaders(),
});
Expand All @@ -729,14 +731,15 @@ export class ColorBulb {
if (this.ColorTemperature !== this.accessory.context.ColorTemperature) {
const kelvin = Math.round(1000000 / Number(this.ColorTemperature));
this.cacheKelvin = kelvin;
const body = JSON.stringify({
const bodyChange = JSON.stringify({
'command': 'setColorTemperature',
'parameter': `${kelvin}`,
'commandType': 'command',
});
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
try {
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
body: bodyChange,
method: 'POST',
headers: this.platform.generateHeaders(),
});
Expand All @@ -759,14 +762,15 @@ export class ColorBulb {
async pushBrightnessChanges(): Promise<void> {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushBrightnessChanges`);
if (this.Brightness !== this.accessory.context.Brightness) {
const body = JSON.stringify({
const bodyChange = JSON.stringify({
'command': 'setBrightness',
'parameter': `${this.Brightness}`,
'commandType': 'command',
});
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
try {
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
body: bodyChange,
method: 'POST',
headers: this.platform.generateHeaders(),
});
Expand Down
7 changes: 4 additions & 3 deletions src/device/curtain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ export class Curtain {
}

async openAPIpushChanges(): Promise<void> {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI pushChanges`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges`);
if ((this.TargetPosition !== this.CurrentPosition) || this.device.disableCaching) {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Pushing ${this.TargetPosition}`);
const adjustedTargetPosition = 100 - Number(this.TargetPosition);
Expand All @@ -606,14 +606,15 @@ export class Curtain {
}
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Mode: ${this.Mode}`);
const adjustedMode = this.setPositionMode || 'ff';
const body = JSON.stringify({
const bodyChange = JSON.stringify({
'command': 'setPosition',
'parameter': `0,${adjustedMode},${adjustedTargetPosition}`,
'commandType': 'command',
});
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
try {
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
body: bodyChange,
method: 'POST',
headers: this.platform.generateHeaders(),
});
Expand Down
15 changes: 9 additions & 6 deletions src/device/humidifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,15 @@ export class Humidifier {
if (this.TargetHumidifierDehumidifierState === this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER &&
this.Active === this.platform.Characteristic.Active.ACTIVE) {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Pushing Manual: ${this.RelativeHumidityHumidifierThreshold}!`);
const body = JSON.stringify({
const bodyChange = JSON.stringify({
'command': 'setMode',
'parameter': `${this.RelativeHumidityHumidifierThreshold}`,
'commandType': 'command',
});
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
try {
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
body: bodyChange,
method: 'POST',
headers: this.platform.generateHeaders(),
});
Expand Down Expand Up @@ -483,14 +484,15 @@ export class Humidifier {
if (this.TargetHumidifierDehumidifierState === this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER &&
this.Active === this.platform.Characteristic.Active.ACTIVE) {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Pushing Auto`);
const body = JSON.stringify({
const bodyChange = JSON.stringify({
'command': 'setMode',
'parameter': 'auto',
'commandType': 'command',
});
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
try {
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
body: bodyChange,
method: 'POST',
headers: this.platform.generateHeaders(),
});
Expand All @@ -517,14 +519,15 @@ export class Humidifier {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushActiveChanges`);
if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Pushing Off`);
const body = JSON.stringify({
const bodyChange = JSON.stringify({
'command': 'turnOff',
'parameter': 'default',
'commandType': 'command',
});
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
try {
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
body: bodyChange,
method: 'POST',
headers: this.platform.generateHeaders(),
});
Expand Down
Loading

0 comments on commit b09e789

Please sign in to comment.