@switchbot/homebridge-switchbot
Advanced tools
Comparing version 0.0.2-beta.15 to 0.0.2-beta.16
@@ -170,40 +170,32 @@ "use strict"; | ||
if (this.platform.config.options?.ble?.includes(this.device.deviceId)) { | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const Switchbot = require('node-switchbot'); | ||
const switchbot = new Switchbot(); | ||
const colon = this.device.deviceId.match(/.{1,2}/g); | ||
const bleMac = colon.join(':'); //returns 1A:23:B4:56:78:9A; | ||
this.device.bleMac = bleMac.toLowerCase(); | ||
if (this.platform.debugMode) { | ||
this.platform.log.warn(this.device.bleMac); | ||
} | ||
switchbot.onadvertisement = (ad) => { | ||
this.platform.log.info(JSON.stringify(ad, null, ' ')); | ||
this.platform.log.warn('ad:', JSON.stringify(ad)); | ||
this.platform.log.info('Temperature:', ad.serviceData.temperature.c); | ||
this.platform.log.info('Humidity:', ad.serviceData.humidity); | ||
this.BLEtemperature = ad.serviceData.temperature.c; | ||
this.BLEHumidity = ad.serviceData.humidity; | ||
}; | ||
switchbot | ||
.startScan({ | ||
id: this.device.bleMac, | ||
}) | ||
.then(() => { | ||
return switchbot.wait(this.platform.config.options.refreshRate * 1000); | ||
}) | ||
.then(() => { | ||
switchbot.stopScan(); | ||
}) | ||
.catch((error) => { | ||
this.platform.log.error(error); | ||
}); | ||
this.parseStatus(); | ||
this.updateHomeKitCharacteristics(); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const Switchbot = require('node-switchbot'); | ||
const switchbot = new Switchbot(); | ||
const colon = this.device.deviceId.match(/.{1,2}/g); | ||
const bleMac = colon.join(':'); //returns 1A:23:B4:56:78:9A; | ||
this.device.bleMac = bleMac.toLowerCase(); | ||
if (this.platform.debugMode) { | ||
this.platform.log.warn(this.device.bleMac); | ||
} | ||
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); | ||
} | ||
switchbot.onadvertisement = (ad) => { | ||
this.platform.log.info(JSON.stringify(ad, null, ' ')); | ||
this.platform.log.warn('ad:', JSON.stringify(ad)); | ||
this.platform.log.info('Temperature:', ad.serviceData.temperature.c); | ||
this.platform.log.info('Humidity:', ad.serviceData.humidity); | ||
this.BLEtemperature = ad.serviceData.temperature.c; | ||
this.BLEHumidity = ad.serviceData.humidity; | ||
}; | ||
switchbot | ||
.startScan({ | ||
id: this.device.bleMac, | ||
}) | ||
.then(() => { | ||
return switchbot.wait(this.platform.config.options.refreshRate * 1000); | ||
}) | ||
.then(() => { | ||
switchbot.stopScan(); | ||
}) | ||
.catch((error) => { | ||
this.platform.log.error(error); | ||
}); | ||
} | ||
@@ -210,0 +202,0 @@ try { |
{ | ||
"displayName": "Homebridge SwitchBot", | ||
"name": "@switchbot/homebridge-switchbot", | ||
"version": "0.0.2-beta.15", | ||
"version": "0.0.2-beta.16", | ||
"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)", |
@@ -197,44 +197,32 @@ import { Service, PlatformAccessory, Units, CharacteristicValue, HAPStatus } from 'homebridge'; | ||
if (this.platform.config.options?.ble?.includes(this.device.deviceId!)) { | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const Switchbot = require('node-switchbot'); | ||
const switchbot = new Switchbot(); | ||
const colon = this.device.deviceId!.match(/.{1,2}/g); | ||
const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A; | ||
this.device.bleMac = bleMac.toLowerCase(); | ||
if (this.platform.debugMode) { | ||
this.platform.log.warn(this.device.bleMac!); | ||
} | ||
switchbot.onadvertisement = (ad: any) => { | ||
this.platform.log.info(JSON.stringify(ad, null, ' ')); | ||
this.platform.log.warn('ad:', JSON.stringify(ad)); | ||
this.platform.log.info('Temperature:', ad.serviceData.temperature.c); | ||
this.platform.log.info('Humidity:', ad.serviceData.humidity); | ||
this.BLEtemperature = ad.serviceData.temperature.c; | ||
this.BLEHumidity = ad.serviceData.humidity; | ||
}; | ||
switchbot | ||
.startScan({ | ||
id: this.device.bleMac, | ||
}) | ||
.then(() => { | ||
return switchbot.wait(this.platform.config.options!.refreshRate! * 1000); | ||
}) | ||
.then(() => { | ||
switchbot.stopScan(); | ||
}) | ||
.catch((error: any) => { | ||
this.platform.log.error(error); | ||
}); | ||
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); | ||
const Switchbot = require('node-switchbot'); | ||
const switchbot = new Switchbot(); | ||
const colon = this.device.deviceId!.match(/.{1,2}/g); | ||
const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A; | ||
this.device.bleMac = bleMac.toLowerCase(); | ||
if (this.platform.debugMode) { | ||
this.platform.log.warn(this.device.bleMac!); | ||
} | ||
switchbot.onadvertisement = (ad: any) => { | ||
this.platform.log.info(JSON.stringify(ad, null, ' ')); | ||
this.platform.log.warn('ad:', JSON.stringify(ad)); | ||
this.platform.log.info('Temperature:', ad.serviceData.temperature.c); | ||
this.platform.log.info('Humidity:', ad.serviceData.humidity); | ||
this.BLEtemperature = ad.serviceData.temperature.c; | ||
this.BLEHumidity = ad.serviceData.humidity; | ||
}; | ||
switchbot | ||
.startScan({ | ||
id: this.device.bleMac, | ||
}) | ||
.then(() => { | ||
return switchbot.wait(this.platform.config.options!.refreshRate! * 1000); | ||
}) | ||
.then(() => { | ||
switchbot.stopScan(); | ||
}) | ||
.catch((error: any) => { | ||
this.platform.log.error(error); | ||
}); | ||
} | ||
@@ -241,0 +229,0 @@ try { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
929795
11072