Socket
Socket
Sign inDemoInstall

@switchbot/homebridge-switchbot

Package Overview
Dependencies
Maintainers
2
Versions
853
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@switchbot/homebridge-switchbot - npm Package Compare versions

Comparing version 0.1.2-beta.28 to 0.1.2-beta.29

13

dist/devices/bots.d.ts
/// <reference types="node" />
import { PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';
import { SwitchBotPlatform } from '../platform';
import { device, deviceStatusResponse } from '../settings';
import { device } from '../settings';
/**

@@ -17,3 +17,12 @@ * Platform Accessory

OutletInUse: CharacteristicValue;
deviceStatus: deviceStatusResponse;
deviceStatus: {
statusCode: number;
body: {
deviceId: string;
deviceType: string;
hubDeviceId: string;
power: string;
};
message: string;
};
RunTimer: NodeJS.Timeout;

@@ -20,0 +29,0 @@ ScanDuration: number;

9

dist/devices/bots.js

@@ -182,3 +182,3 @@ "use strict";

try {
const deviceStatus = {
this.deviceStatus = {
statusCode: 100,

@@ -193,3 +193,2 @@ body: {

};
this.deviceStatus = deviceStatus;
this.parseStatus();

@@ -295,6 +294,6 @@ this.updateHomeKitCharacteristics();

this.platform.log.info('Sending request for', this.accessory.displayName, 'to SwitchBot API. command:', payload.command, 'parameter:', payload.parameter, 'commandType:', payload.commandType);
this.platform.debug(`Bot ${this.accessory.displayName} pushChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Bot ${this.accessory.displayName} pushchanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Bot ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push = (await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload));
this.platform.debug(`Bot ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -301,0 +300,0 @@ }

import { Service, PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';
import { SwitchBotPlatform } from '../platform';
import { device, deviceStatusResponse } from '../settings';
import { device } from '../settings';
/**

@@ -17,3 +17,3 @@ * Platform Accessory

ColorTemperature: CharacteristicValue;
deviceStatus: deviceStatusResponse;
deviceStatus: any;
switchbot: {

@@ -36,4 +36,4 @@ discover: (arg0: {

* deviceType commandType Command command parameter Description
* Plug - "command" "turnOff" "default" = set to OFF state
* Plug - "command" "turnOn" "default" = set to ON state
* Bulb - "command" "turnOff" "default" = set to OFF state
* Bulb - "command" "turnOn" "default" = set to ON state
*/

@@ -40,0 +40,0 @@ pushChanges(): Promise<void>;

@@ -86,3 +86,3 @@ "use strict";

});
// Watch for Plug change events
// Watch for Bulb change events
// We put in a debounce of 100ms so we don't make duplicate calls

@@ -99,3 +99,3 @@ this.doBulbUpdate

this.platform.log.error(JSON.stringify(e.message));
this.platform.debug(`Plug ${accessory.displayName} - ${JSON.stringify(e)}`);
this.platform.debug(`Bulb ${accessory.displayName} - ${JSON.stringify(e)}`);
this.apiError(e);

@@ -114,3 +114,3 @@ }

}
this.platform.debug(`Plug ${this.accessory.displayName} On: ${this.On}`);
this.platform.debug(`Bulb ${this.accessory.displayName} On: ${this.On}`);
this.deviceStatus.body.brightness = Number(this.Brightness);

@@ -121,13 +121,11 @@ this.deviceStatus.body.colorTemperature = Number(this.ColorTemperature);

try {
this.platform.debug('Plug - Reading', `${settings_1.DeviceURL}/${this.device.deviceId}/status`);
this.deviceStatus = await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`);
if (this.deviceStatus.message === 'success') {
this.platform.device(`Plug ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
}
this.platform.debug('Bulb - Reading', `${settings_1.DeviceURL}/${this.device.deviceId}/status`);
this.deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
this.platform.device(`Bulb ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
}
catch (e) {
this.platform.log.error(`Plug - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);
this.platform.debug(`Plug ${this.accessory.displayName} - ${JSON.stringify(e)}`);
this.platform.log.error(`Bulb - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);
this.platform.debug(`Bulb ${this.accessory.displayName} - ${JSON.stringify(e)}`);
this.apiError(e);

@@ -139,4 +137,4 @@ }

* deviceType commandType Command command parameter Description
* Plug - "command" "turnOff" "default" = set to OFF state
* Plug - "command" "turnOn" "default" = set to ON state
* Bulb - "command" "turnOff" "default" = set to OFF state
* Bulb - "command" "turnOn" "default" = set to ON state
*/

@@ -155,6 +153,6 @@ async pushChanges() {

this.platform.log.info('Sending request for', this.accessory.displayName, 'to SwitchBot API. command:', payload.command, 'parameter:', payload.parameter, 'commandType:', payload.commandType);
this.platform.debug(`Plug ${this.accessory.displayName} pushChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Bulb ${this.accessory.displayName} pushchanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Plug ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push = (await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload));
this.platform.debug(`Bulb ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -161,0 +159,0 @@ }

import { Service, PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';
import { SwitchBotPlatform } from '../platform';
import { device, deviceStatusResponse } from '../settings';
import { device } from '../settings';
/**

@@ -17,3 +17,3 @@ * Platform Accessory

MotionDetected: CharacteristicValue;
deviceStatus: deviceStatusResponse;
deviceStatus: any;
BLEmotion: boolean;

@@ -20,0 +20,0 @@ BLEstate: boolean;

@@ -162,11 +162,6 @@ "use strict";

try {
this.deviceStatus = await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`);
if (this.deviceStatus.message === 'success') {
this.platform.debug(`Contact ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
}
else {
this.platform.debug(this.deviceStatus);
}
this.deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
this.platform.debug(`Contact ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
}

@@ -173,0 +168,0 @@ catch (e) {

/// <reference types="node" />
import { PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';
import { SwitchBotPlatform } from '../platform';
import { device, deviceStatusResponse } from '../settings';
import { device } from '../settings';
export declare class Curtain {

@@ -15,3 +15,3 @@ private readonly platform;

CurrentAmbientLightLevel: CharacteristicValue;
deviceStatus: deviceStatusResponse;
deviceStatus: any;
moveTimer: NodeJS.Timeout;

@@ -18,0 +18,0 @@ ScanIntervalId: NodeJS.Timeout;

@@ -236,12 +236,7 @@ "use strict";

this.platform.debug('Curtain - Reading', `${settings_1.DeviceURL}/${this.device.deviceId}/status`);
this.deviceStatus = await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`);
if (this.deviceStatus.message === 'success') {
this.platform.debug(`Curtain ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
this.setMinMax();
this.parseStatus();
this.updateHomeKitCharacteristics();
}
else {
this.platform.debug(this.deviceStatus);
}
this.deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
this.platform.debug(`Curtain ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
this.setMinMax();
this.parseStatus();
this.updateHomeKitCharacteristics();
}

@@ -275,6 +270,6 @@ catch (e) {

this.platform.log.info('Sending request for', this.accessory.displayName, 'to SwitchBot API. command:', payload.command, 'parameter:', payload.parameter, 'commandType:', payload.commandType);
this.platform.debug(`Curtain ${this.accessory.displayName} pushChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Curtain ${this.accessory.displayName} pushchanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Curtain ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push = (await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload));
this.platform.debug(`Curtain ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -281,0 +276,0 @@ }

import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
import { SwitchBotPlatform } from '../platform';
import { device, deviceStatusResponse } from '../settings';
import { device } from '../settings';
/**

@@ -22,3 +22,3 @@ * Platform Accessory

WaterLevel: CharacteristicValue;
deviceStatus: deviceStatusResponse;
deviceStatus: any;
humidifierUpdateInProgress: boolean;

@@ -25,0 +25,0 @@ doHumidifierUpdate: any;

@@ -189,3 +189,3 @@ "use strict";

try {
this.deviceStatus = await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`);
this.deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
if (this.deviceStatus.message === 'success') {

@@ -220,6 +220,6 @@ this.platform.debug(`Humidifier ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);

this.platform.log.info('Sending request for', this.accessory.displayName, 'to SwitchBot API. command:', payload.command, 'parameter:', payload.parameter, 'commandType:', payload.commandType);
this.platform.debug(`Humidifier ${this.accessory.displayName} pushChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Humidifier ${this.accessory.displayName} pushChanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Humidifier ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push = (await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload));
this.platform.debug(`Humidifier ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -251,6 +251,6 @@ }

this.platform.log.info('Sending request for', this.accessory.displayName, 'to SwitchBot API. command:', payload.command, 'parameter:', payload.parameter, 'commandType:', payload.commandType);
this.platform.debug(`Humidifier ${this.accessory.displayName} pushAutoChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Humidifier ${this.accessory.displayName} pushAutoChanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Humidifier ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push = (await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload));
this.platform.debug(`Humidifier ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -278,6 +278,6 @@ }

this.platform.log.info('Sending request for', this.accessory.displayName, 'to SwitchBot API. command:', payload.command, 'parameter:', payload.parameter, 'commandType:', payload.commandType);
this.platform.debug(`Humidifier ${this.accessory.displayName} pushActiveChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Humidifier ${this.accessory.displayName} pushActiveChanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Humidifier ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push = (await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload));
this.platform.debug(`Humidifier ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -284,0 +284,0 @@ }

import { PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';
import { SwitchBotPlatform } from '../platform';
import { device, deviceStatusResponse } from '../settings';
import { device } from '../settings';
export declare class IndoorCam {

@@ -11,3 +11,3 @@ private readonly platform;

OutletInUse: CharacteristicValue;
deviceStatus: deviceStatusResponse;
deviceStatus: any;
switchbot: {

@@ -14,0 +14,0 @@ discover: (arg0: {

@@ -146,11 +146,6 @@ "use strict";

this.platform.debug('Camera - Reading', `${settings_1.DeviceURL}/${this.device.deviceId}/status`);
this.deviceStatus = await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`);
if (this.deviceStatus.message === 'success') {
this.platform.device(`Camera ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
}
else {
this.platform.debug(this.deviceStatus);
}
this.deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
this.platform.device(`Camera ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
}

@@ -181,6 +176,6 @@ catch (e) {

this.platform.log.info('Sending request for', this.accessory.displayName, 'to SwitchBot API. command:', payload.command, 'parameter:', payload.parameter, 'commandType:', payload.commandType);
this.platform.debug(`Camera ${this.accessory.displayName} pushChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Camera ${this.accessory.displayName} pushchanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Camera ${this.accessory.displayName} Changes pushed - ${push.data}`);
this.platform.debug(`Camera ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -187,0 +182,0 @@ }

import { Service, PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';
import { SwitchBotPlatform } from '../platform';
import { device, deviceStatusResponse } from '../settings';
import { device } from '../settings';
/**

@@ -23,3 +23,3 @@ * Platform Accessory

WaterLevel: CharacteristicValue;
deviceStatus: deviceStatusResponse;
deviceStatus: any;
BLEtemperature: number;

@@ -26,0 +26,0 @@ BLEHumidity: number;

@@ -253,11 +253,6 @@ "use strict";

try {
this.deviceStatus = await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`);
if (this.deviceStatus.message === 'success') {
this.platform.debug(`Meter ${this.accessory.displayName} openAPIRefreshStatus - ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
}
else {
this.platform.debug(this.deviceStatus);
}
this.deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
this.platform.debug(`Meter ${this.accessory.displayName} openAPIRefreshStatus: ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
}

@@ -264,0 +259,0 @@ catch (e) {

import { PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';
import { SwitchBotPlatform } from '../platform';
import { device, deviceStatusResponse } from '../settings';
import { device } from '../settings';
/**

@@ -15,3 +15,3 @@ * Platform Accessory

MotionDetected: CharacteristicValue;
deviceStatus: deviceStatusResponse;
deviceStatus: any;
BLEmotion: boolean;

@@ -18,0 +18,0 @@ switchbot: {

@@ -146,11 +146,6 @@ "use strict";

try {
this.deviceStatus = await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`);
if (this.deviceStatus.message === 'success') {
this.platform.debug(`Motion ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
}
else {
this.platform.debug(this.deviceStatus);
}
this.deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
this.platform.debug(`Motion ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
}

@@ -157,0 +152,0 @@ catch (e) {

import { PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';
import { SwitchBotPlatform } from '../platform';
import { device, deviceStatusResponse } from '../settings';
import { device } from '../settings';
export declare class Plug {

@@ -11,3 +11,3 @@ private readonly platform;

OutletInUse: CharacteristicValue;
deviceStatus: deviceStatusResponse;
deviceStatus: any;
switchbot: {

@@ -14,0 +14,0 @@ discover: (arg0: {

@@ -148,11 +148,6 @@ "use strict";

this.platform.debug('Plug - Reading', `${settings_1.DeviceURL}/${this.device.deviceId}/status`);
this.deviceStatus = await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`);
if (this.deviceStatus.message === 'success') {
this.platform.device(`Plug ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
}
else {
this.platform.debug(this.deviceStatus);
}
this.deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
this.platform.device(`Plug ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
}

@@ -183,6 +178,6 @@ catch (e) {

this.platform.log.info('Sending request for', this.accessory.displayName, 'to SwitchBot API. command:', payload.command, 'parameter:', payload.parameter, 'commandType:', payload.commandType);
this.platform.debug(`Plug ${this.accessory.displayName} pushChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Plug ${this.accessory.displayName} pushchanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Plug ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push = (await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload));
this.platform.debug(`Plug ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -189,0 +184,0 @@ }

import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, Service, Characteristic } from 'homebridge';
import { AxiosInstance } from 'axios';
import { irdevice, device, SwitchBotPlatformConfig, deviceResponses, deviceStatusResponse } from './settings';
import { irdevice, device, SwitchBotPlatformConfig, deviceResponses } from './settings';
/**

@@ -18,3 +18,3 @@ * HomebridgePlatform

version: any;
deviceStatus: deviceStatusResponse;
deviceStatus: any;
constructor(log: Logger, config: SwitchBotPlatformConfig, api: API);

@@ -21,0 +21,0 @@ /**

{
"displayName": "Homebridge SwitchBot",
"name": "@switchbot/homebridge-switchbot",
"version": "0.1.2-beta.28",
"version": "0.1.2-beta.29",
"description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",

@@ -56,6 +56,6 @@ "author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",

"devDependencies": {
"@types/node": "^16.10.6",
"@types/node": "^16.11.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.0",
"eslint": "^8.0.1",
"homebridge": "^1.3.5",

@@ -62,0 +62,0 @@ "nodemon": "^2.0.13",

@@ -5,4 +5,3 @@ import { Service, PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';

import { debounceTime, skipWhile, tap } from 'rxjs/operators';
import { DeviceURL, device, deviceStatusResponse } from '../settings';
import { AxiosResponse } from 'axios';
import { DeviceURL, device } from '../settings';

@@ -19,3 +18,3 @@ /**

OutletInUse!: CharacteristicValue;
deviceStatus!: deviceStatusResponse;
deviceStatus!: { statusCode: number; body: { deviceId: string; deviceType: string; hubDeviceId: string; power: string; }; message: string; };
RunTimer!: NodeJS.Timeout;

@@ -227,3 +226,3 @@ ScanDuration: number;

try {
const deviceStatus: deviceStatusResponse = {
this.deviceStatus = {
statusCode: 100,

@@ -238,3 +237,2 @@ body: {

};
this.deviceStatus = deviceStatus;
this.parseStatus();

@@ -348,7 +346,7 @@ this.updateHomeKitCharacteristics();

);
this.platform.debug(`Bot ${this.accessory.displayName} pushChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Bot ${this.accessory.displayName} pushchanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Bot ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push: any = (await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload));
this.platform.debug(`Bot ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -380,3 +378,3 @@ }

private statusCode(push: AxiosResponse<any>) {
private statusCode(push: { data: { statusCode: any; }; }) {
switch (push.data.statusCode) {

@@ -383,0 +381,0 @@ case 151:

@@ -5,4 +5,3 @@ import { Service, PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';

import { debounceTime, skipWhile, tap } from 'rxjs/operators';
import { DeviceURL, device, deviceStatusResponse } from '../settings';
import { AxiosResponse } from 'axios';
import { DeviceURL, device } from '../settings';

@@ -24,3 +23,3 @@ /**

// Others
deviceStatus!: deviceStatusResponse;
deviceStatus: any;
switchbot!: {

@@ -132,3 +131,3 @@ discover: (

// Watch for Plug change events
// Watch for Bulb change events
// We put in a debounce of 100ms so we don't make duplicate calls

@@ -147,3 +146,3 @@ this.doBulbUpdate

this.platform.log.error(JSON.stringify(e.message));
this.platform.debug(`Plug ${accessory.displayName} - ${JSON.stringify(e)}`);
this.platform.debug(`Bulb ${accessory.displayName} - ${JSON.stringify(e)}`);
this.apiError(e);

@@ -163,3 +162,3 @@ }

}
this.platform.debug(`Plug ${this.accessory.displayName} On: ${this.On}`);
this.platform.debug(`Bulb ${this.accessory.displayName} On: ${this.On}`);
this.deviceStatus.body.brightness = Number(this.Brightness);

@@ -171,12 +170,10 @@ this.deviceStatus.body.colorTemperature = Number(this.ColorTemperature);

try {
this.platform.debug('Plug - Reading', `${DeviceURL}/${this.device.deviceId}/status`);
this.deviceStatus = await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`);
if (this.deviceStatus.message === 'success') {
this.platform.device(`Plug ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
}
this.platform.debug('Bulb - Reading', `${DeviceURL}/${this.device.deviceId}/status`);
this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
this.platform.device(`Bulb ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
} catch (e: any) {
this.platform.log.error(`Plug - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);
this.platform.debug(`Plug ${this.accessory.displayName} - ${JSON.stringify(e)}`);
this.platform.log.error(`Bulb - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);
this.platform.debug(`Bulb ${this.accessory.displayName} - ${JSON.stringify(e)}`);
this.apiError(e);

@@ -189,4 +186,4 @@ }

* deviceType commandType Command command parameter Description
* Plug - "command" "turnOff" "default" = set to OFF state
* Plug - "command" "turnOn" "default" = set to ON state
* Bulb - "command" "turnOff" "default" = set to OFF state
* Bulb - "command" "turnOn" "default" = set to ON state
*/

@@ -215,7 +212,7 @@ async pushChanges() {

);
this.platform.debug(`Plug ${this.accessory.displayName} pushChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Bulb ${this.accessory.displayName} pushchanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Plug ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push: any = (await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload));
this.platform.debug(`Bulb ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -249,3 +246,3 @@ }

private statusCode(push: AxiosResponse<any>) {
private statusCode(push: { data: { statusCode: any; }; }) {
switch (push.data.statusCode) {

@@ -252,0 +249,0 @@ case 151:

@@ -5,3 +5,3 @@ import { Service, PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';

import { skipWhile } from 'rxjs/operators';
import { DeviceURL, device, deviceStatusResponse } from '../settings';
import { DeviceURL, device } from '../settings';

@@ -23,3 +23,3 @@ /**

// Others
deviceStatus!: deviceStatusResponse;
deviceStatus!: any;
BLEmotion!: boolean;

@@ -208,10 +208,6 @@ BLEstate!: boolean;

try {
this.deviceStatus = await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`);
if (this.deviceStatus.message === 'success') {
this.platform.debug(`Contact ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
} else {
this.platform.debug(this.deviceStatus);
}
this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
this.platform.debug(`Contact ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
} catch (e: any) {

@@ -218,0 +214,0 @@ this.platform.log.error(`Contact - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);

@@ -6,4 +6,3 @@ /* eslint-disable @typescript-eslint/no-var-requires */

import { debounceTime, skipWhile, tap } from 'rxjs/operators';
import { DeviceURL, device, deviceStatusResponse } from '../settings';
import { AxiosResponse } from 'axios';
import { DeviceURL, device } from '../settings';

@@ -22,3 +21,3 @@ export class Curtain {

// Others
deviceStatus!: deviceStatusResponse;
deviceStatus!: any;
moveTimer!: NodeJS.Timeout;

@@ -310,11 +309,7 @@ ScanIntervalId!: NodeJS.Timeout;

this.platform.debug('Curtain - Reading', `${DeviceURL}/${this.device.deviceId}/status`);
this.deviceStatus = await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`);
if (this.deviceStatus.message === 'success') {
this.platform.debug(`Curtain ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
this.setMinMax();
this.parseStatus();
this.updateHomeKitCharacteristics();
} else {
this.platform.debug(this.deviceStatus);
}
this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
this.platform.debug(`Curtain ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
this.setMinMax();
this.parseStatus();
this.updateHomeKitCharacteristics();
} catch (e: any) {

@@ -359,7 +354,7 @@ this.platform.log.error(`Curtain - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);

);
this.platform.debug(`Curtain ${this.accessory.displayName} pushChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Curtain ${this.accessory.displayName} pushchanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Curtain ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push: any = (await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload));
this.platform.debug(`Curtain ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -408,4 +403,3 @@ }

private statusCode(push: AxiosResponse<any>) {
private statusCode(push: { data: { statusCode: any; }; }) {
switch (push.data.statusCode) {

@@ -412,0 +406,0 @@ case 151:

@@ -5,4 +5,3 @@ import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';

import { debounceTime, skipWhile, tap } from 'rxjs/operators';
import { DeviceURL, device, deviceStatusResponse } from '../settings';
import { AxiosResponse } from 'axios';
import { DeviceURL, device } from '../settings';

@@ -29,3 +28,3 @@ /**

// Others
deviceStatus!: deviceStatusResponse;
deviceStatus!: any;

@@ -230,3 +229,3 @@ // Updates

try {
this.deviceStatus = await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`);
this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
if (this.deviceStatus.message === 'success') {

@@ -272,7 +271,7 @@ this.platform.debug(`Humidifier ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);

);
this.platform.debug(`Humidifier ${this.accessory.displayName} pushChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Humidifier ${this.accessory.displayName} pushChanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Humidifier ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push: any = (await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload));
this.platform.debug(`Humidifier ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -317,7 +316,7 @@ } else if (

);
this.platform.debug(`Humidifier ${this.accessory.displayName} pushAutoChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Humidifier ${this.accessory.displayName} pushAutoChanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Humidifier ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push: any = (await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload));
this.platform.debug(`Humidifier ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -355,7 +354,7 @@ }

);
this.platform.debug(`Humidifier ${this.accessory.displayName} pushActiveChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Humidifier ${this.accessory.displayName} pushActiveChanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Humidifier ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push: any = (await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload));
this.platform.debug(`Humidifier ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -424,3 +423,3 @@ }

private statusCode(push: AxiosResponse<any>) {
private statusCode(push: { data: { statusCode: any; }; }) {
switch (push.data.statusCode) {

@@ -427,0 +426,0 @@ case 151:

@@ -5,4 +5,3 @@ import { Service, PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';

import { debounceTime, skipWhile, tap } from 'rxjs/operators';
import { DeviceURL, device, deviceStatusResponse } from '../settings';
import { AxiosResponse } from 'axios';
import { DeviceURL, device } from '../settings';

@@ -18,3 +17,3 @@ export class IndoorCam {

// Others
deviceStatus!: deviceStatusResponse;
deviceStatus!: any;
switchbot!: {

@@ -196,10 +195,6 @@ discover: (

this.platform.debug('Camera - Reading', `${DeviceURL}/${this.device.deviceId}/status`);
this.deviceStatus = await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`);
if (this.deviceStatus.message === 'success') {
this.platform.device(`Camera ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
} else {
this.platform.debug(this.deviceStatus);
}
this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
this.platform.device(`Camera ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
} catch (e: any) {

@@ -240,7 +235,7 @@ this.platform.log.error(`IndoorCam - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);

);
this.platform.debug(`Camera ${this.accessory.displayName} pushChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Camera ${this.accessory.displayName} pushchanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Camera ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Camera ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -264,3 +259,3 @@ }

private statusCode(push: AxiosResponse<any>) {
private statusCode(push: { data: { statusCode: any; }; }) {
switch (push.data.statusCode) {

@@ -267,0 +262,0 @@ case 151:

@@ -5,3 +5,3 @@ import { Service, PlatformAccessory, Units, CharacteristicValue, MacAddress } from 'homebridge';

import { skipWhile } from 'rxjs/operators';
import { DeviceURL, device, deviceStatusResponse } from '../settings';
import { DeviceURL, device } from '../settings';

@@ -29,3 +29,3 @@ /**

// Others
deviceStatus!: deviceStatusResponse;
deviceStatus!: any;
BLEtemperature!: number;

@@ -301,10 +301,6 @@ BLEHumidity!: number;

try {
this.deviceStatus = await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`);
if (this.deviceStatus.message === 'success') {
this.platform.debug(`Meter ${this.accessory.displayName} openAPIRefreshStatus - ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
} else {
this.platform.debug(this.deviceStatus);
}
this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
this.platform.debug(`Meter ${this.accessory.displayName} openAPIRefreshStatus: ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
} catch (e: any) {

@@ -311,0 +307,0 @@ this.platform.log.error(`Meter - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);

@@ -5,3 +5,3 @@ import { Service, PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';

import { skipWhile } from 'rxjs/operators';
import { DeviceURL, device, deviceStatusResponse } from '../settings';
import { DeviceURL, device } from '../settings';

@@ -21,3 +21,3 @@ /**

// Others
deviceStatus!: deviceStatusResponse;
deviceStatus!: any;
BLEmotion!: boolean;

@@ -192,10 +192,6 @@ switchbot!: {

try {
this.deviceStatus = await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`);
if (this.deviceStatus.message === 'success') {
this.platform.debug(`Motion ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
} else {
this.platform.debug(this.deviceStatus);
}
this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
this.platform.debug(`Motion ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
} catch (e: any) {

@@ -202,0 +198,0 @@ this.platform.log.error(`Motion - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);

@@ -5,4 +5,3 @@ import { Service, PlatformAccessory, CharacteristicValue, MacAddress } from 'homebridge';

import { debounceTime, skipWhile, tap } from 'rxjs/operators';
import { DeviceURL, device, deviceStatusResponse } from '../settings';
import { AxiosResponse } from 'axios';
import { DeviceURL, device } from '../settings';

@@ -18,3 +17,3 @@ export class Plug {

// Others
deviceStatus!: deviceStatusResponse;
deviceStatus!: any;
switchbot!: {

@@ -198,10 +197,6 @@ discover: (

this.platform.debug('Plug - Reading', `${DeviceURL}/${this.device.deviceId}/status`);
this.deviceStatus = await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`);
if (this.deviceStatus.message === 'success') {
this.platform.device(`Plug ${this.accessory.displayName} refreshStatus - ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
} else {
this.platform.debug(this.deviceStatus);
}
this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
this.platform.device(`Plug ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
this.parseStatus();
this.updateHomeKitCharacteristics();
} catch (e: any) {

@@ -242,7 +237,7 @@ this.platform.log.error(`Plug - Failed to refresh status of ${this.device.deviceName} - ${JSON.stringify(e.message)}`);

);
this.platform.debug(`Plug ${this.accessory.displayName} pushChanges - ${JSON.stringify(payload)}`);
this.platform.debug(`Plug ${this.accessory.displayName} pushchanges: ${JSON.stringify(payload)}`);
// Make the API request
const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
this.platform.debug(`Plug ${this.accessory.displayName} Changes pushed - ${push.data}`);
const push: any = (await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload));
this.platform.debug(`Plug ${this.accessory.displayName} Changes pushed: ${JSON.stringify(push.data)}`);
this.statusCode(push);

@@ -266,3 +261,3 @@ }

private statusCode(push: AxiosResponse<any>) {
private statusCode(push: { data: { statusCode: any; }; }) {
switch (push.data.statusCode) {

@@ -269,0 +264,0 @@ case 151:

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc