Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@switchbot/homebridge-switchbot

Package Overview
Dependencies
Maintainers
2
Versions
924
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.0.2-beta.0 to 0.0.2-beta.1

4

dist/devices/meters.d.ts
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
import { SwitchBotPlatform } from '../platform';
import { Subject } from 'rxjs';
import { device, deviceStatusResponse } from '../settings';

@@ -25,4 +24,5 @@ /**

deviceStatus: deviceStatusResponse;
switchbot: any;
meterUpdateInProgress: boolean;
doMeterUpdate: Subject<unknown>;
doMeterUpdate: any;
constructor(platform: SwitchBotPlatform, accessory: PlatformAccessory, device: device);

@@ -29,0 +29,0 @@ /**

@@ -24,2 +24,5 @@ "use strict";

if (this.platform.config.options?.ble?.includes(this.device.deviceId)) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Switchbot = require('node-switchbot');
this.switchbot = new Switchbot();
const colon = device.deviceId.match(/.{1,2}/g);

@@ -85,2 +88,3 @@ const bleMac = colon.join(':'); //returns 1A:23:B4:56:78:9A;

});
this.platform.log.info(this.device.deviceName + ' current temperature: ' + this.CurrentTemperature + '\u2103');
}

@@ -112,2 +116,3 @@ else {

});
this.platform.log.info(this.device.deviceName + ' current humidity: ' + this.CurrentRelativeHumidity + '%');
}

@@ -168,15 +173,26 @@ else {

async refreshStatus() {
try {
const deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
if (deviceStatus.message === 'success') {
this.deviceStatus = deviceStatus;
this.platform.log.debug('Meter %s refreshStatus -', this.accessory.displayName, JSON.stringify(this.deviceStatus));
this.parseStatus();
this.updateHomeKitCharacteristics();
if (this.platform.config.options?.ble?.includes(this.device.deviceId)) {
this.switchbot.onadvertisement = (ad) => {
// log.info(JSON.stringify(ad, null, ' '));
// log.info("Temperature:", ad.serviceData.temperature.c);
// log.info("Humidity:", ad.serviceData.humidity);
this.CurrentTemperature = ad.serviceData.temperature.c;
this.CurrentRelativeHumidity = ad.serviceData.humidity;
};
}
else {
try {
const deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
if (deviceStatus.message === 'success') {
this.deviceStatus = deviceStatus;
this.platform.log.debug('Meter %s refreshStatus -', this.accessory.displayName, JSON.stringify(this.deviceStatus));
this.parseStatus();
this.updateHomeKitCharacteristics();
}
}
catch (e) {
this.platform.log.error('Meter - Failed to update status of', this.device.deviceName, JSON.stringify(e.message), this.platform.log.debug('Meter %s -', this.accessory.displayName, JSON.stringify(e)));
this.apiError(e);
}
}
catch (e) {
this.platform.log.error('Meter - Failed to update status of', this.device.deviceName, JSON.stringify(e.message), this.platform.log.debug('Meter %s -', this.accessory.displayName, JSON.stringify(e)));
this.apiError(e);
}
}

@@ -183,0 +199,0 @@ /**

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

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

@@ -25,5 +25,6 @@ import { Service, PlatformAccessory, Units, CharacteristicValue, HAPStatus } from 'homebridge';

deviceStatus!: deviceStatusResponse;
switchbot;
meterUpdateInProgress!: boolean;
doMeterUpdate!: Subject<unknown>;
doMeterUpdate;

@@ -42,2 +43,5 @@ constructor(

if (this.platform.config.options?.ble?.includes(this.device.deviceId!)) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Switchbot = require('node-switchbot');
this.switchbot = new Switchbot();
const colon = device.deviceId!.match(/.{1,2}/g);

@@ -111,3 +115,4 @@ const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;

return this.CurrentTemperature;
});
} );
this.platform.log.info(this.device.deviceName + ' current temperature: ' + this.CurrentTemperature + '\u2103');
} else {

@@ -139,2 +144,3 @@ if (this.platform.debugMode) {

});
this.platform.log.info(this.device.deviceName + ' current humidity: ' + this.CurrentRelativeHumidity + '%');
} else {

@@ -195,25 +201,35 @@ if (this.platform.debugMode) {

async refreshStatus() {
try {
const deviceStatus: deviceStatusResponse = (
await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)
).data;
if (deviceStatus.message === 'success') {
this.deviceStatus = deviceStatus;
this.platform.log.debug(
'Meter %s refreshStatus -',
this.accessory.displayName,
JSON.stringify(this.deviceStatus),
if (this.platform.config.options?.ble?.includes(this.device.deviceId!)) {
this.switchbot.onadvertisement = (ad: any) => {
// log.info(JSON.stringify(ad, null, ' '));
// log.info("Temperature:", ad.serviceData.temperature.c);
// log.info("Humidity:", ad.serviceData.humidity);
this.CurrentTemperature = ad.serviceData.temperature.c;
this.CurrentRelativeHumidity = ad.serviceData.humidity;
};
} else {
try {
const deviceStatus: deviceStatusResponse = (
await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)
).data;
if (deviceStatus.message === 'success') {
this.deviceStatus = deviceStatus;
this.platform.log.debug(
'Meter %s refreshStatus -',
this.accessory.displayName,
JSON.stringify(this.deviceStatus),
);
this.parseStatus();
this.updateHomeKitCharacteristics();
}
} catch (e) {
this.platform.log.error(
'Meter - Failed to update status of',
this.device.deviceName,
JSON.stringify(e.message),
this.platform.log.debug('Meter %s -', this.accessory.displayName, JSON.stringify(e)),
);
this.parseStatus();
this.updateHomeKitCharacteristics();
this.apiError(e);
}
} catch (e) {
this.platform.log.error(
'Meter - Failed to update status of',
this.device.deviceName,
JSON.stringify(e.message),
this.platform.log.debug('Meter %s -', this.accessory.displayName, JSON.stringify(e)),
);
this.apiError(e);
}

@@ -220,0 +236,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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