From a5e226a9a29b96dd5436126b7f7edf98f01e391c Mon Sep 17 00:00:00 2001 From: Donavan Becker Date: Wed, 24 Nov 2021 21:30:49 -0600 Subject: [PATCH] fix for #110 --- CHANGELOG.md | 6 ++++-- package-lock.json | 33 +++++++++++++++------------------ package.json | 4 ++-- src/devices/meters.ts | 20 ++++++++++++++++---- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad454bec..7d6f5103 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,14 @@ All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/) -## [Beta - Version 1.2.1](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.2.0) (2021-11-XX) +## [Version 1.2.1](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.2.0) (2021-11-24) ## What's Changed * Fixed Bug: Curtains alternate between open/close state. [#85](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/85) +* Fixed Bug: Meter not working with BLE. [#110](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/110) +* Housekeeping and updated dependencies. -**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.1.0...v1.2.0 +**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.2.0...v1.2.1 ## [Version 1.2.0](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.2.0) (2021-11-19) diff --git a/package-lock.json b/package-lock.json index f956c211..bd96fda4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@switchbot/homebridge-switchbot", - "version": "1.2.0", + "version": "1.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@switchbot/homebridge-switchbot", - "version": "1.2.0", + "version": "1.2.1", "funding": [ { "type": "Paypal", @@ -21,7 +21,7 @@ "rxjs": "^7.4.0" }, "devDependencies": { - "@types/node": "^16.11.9", + "@types/node": "^16.11.10", "@typescript-eslint/eslint-plugin": "^5.4.0", "@typescript-eslint/parser": "^5.4.0", "eslint": "^8.3.0", @@ -405,9 +405,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "16.11.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.9.tgz", - "integrity": "sha512-MKmdASMf3LtPzwLyRrFjtFFZ48cMf8jmX5VRYrDQiJa8Ybu5VAmkqBWqKU8fdCwD8ysw4mQ9nrEHvzg6gunR7A==", + "version": "16.11.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.10.tgz", + "integrity": "sha512-3aRnHa1KlOEEhJ6+CvyHKK5vE9BcLGjtUpwvqYLRvYNQKMfabu3BwfJaA/SLW8dxe28LsNDjtHwePTuzn3gmOA==", "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { @@ -1072,16 +1072,13 @@ } }, "node_modules/cli-table": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.8.tgz", - "integrity": "sha512-5IO15fJRzgM+hHZjvQlqD6UPRuVGWR4Ny5ZzaM5VJxJEQqSIEVyVh9dMAUN6CBAVfMc4/6CFEzbhnRftLRCyug==", + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.9.tgz", + "integrity": "sha512-7eA6hFtAZwVx3dWAGoaBqTrzWko5jRUFKpHT64ZHkJpaA3y5wf5NlLjguqTRmqycatJZiwftODYYyGNLbQ7MuA==", "dev": true, "dependencies": { "colors": "1.0.3", "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">= 12" } }, "node_modules/clone-response": { @@ -5452,9 +5449,9 @@ "dev": true }, "@types/node": { - "version": "16.11.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.9.tgz", - "integrity": "sha512-MKmdASMf3LtPzwLyRrFjtFFZ48cMf8jmX5VRYrDQiJa8Ybu5VAmkqBWqKU8fdCwD8ysw4mQ9nrEHvzg6gunR7A==", + "version": "16.11.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.10.tgz", + "integrity": "sha512-3aRnHa1KlOEEhJ6+CvyHKK5vE9BcLGjtUpwvqYLRvYNQKMfabu3BwfJaA/SLW8dxe28LsNDjtHwePTuzn3gmOA==", "dev": true }, "@typescript-eslint/eslint-plugin": { @@ -5929,9 +5926,9 @@ "dev": true }, "cli-table": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.8.tgz", - "integrity": "sha512-5IO15fJRzgM+hHZjvQlqD6UPRuVGWR4Ny5ZzaM5VJxJEQqSIEVyVh9dMAUN6CBAVfMc4/6CFEzbhnRftLRCyug==", + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.9.tgz", + "integrity": "sha512-7eA6hFtAZwVx3dWAGoaBqTrzWko5jRUFKpHT64ZHkJpaA3y5wf5NlLjguqTRmqycatJZiwftODYYyGNLbQ7MuA==", "dev": true, "requires": { "colors": "1.0.3", diff --git a/package.json b/package.json index 9392abf9..b847dc2e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "Homebridge SwitchBot", "name": "@switchbot/homebridge-switchbot", - "version": "1.2.0", + "version": "1.2.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 (https://github.com/SwitchBot)", "license": "ISC", @@ -53,7 +53,7 @@ "rxjs": "^7.4.0" }, "devDependencies": { - "@types/node": "^16.11.9", + "@types/node": "^16.11.10", "@typescript-eslint/eslint-plugin": "^5.4.0", "@typescript-eslint/parser": "^5.4.0", "eslint": "^8.3.0", diff --git a/src/devices/meters.ts b/src/devices/meters.ts index 24ee76bb..927d20a5 100644 --- a/src/devices/meters.ts +++ b/src/devices/meters.ts @@ -190,7 +190,19 @@ export class Meter { // Current Temperature if (!this.device.meter?.hide_temperature) { - this.CurrentTemperature = Number(this.temperature); + if (this.device.meter?.unit === 1) { + this.CurrentTemperature = Number(this.temperature?.f); + } else if (this.device.meter?.unit === 0) { + this.CurrentTemperature = Number(this.temperature?.c); + } else { + if (this.fahrenheit) { + this.CurrentTemperature = Number(this.temperature?.f); + } else { + this.CurrentTemperature = Number(this.temperature?.c); + } + } + + this.CurrentTemperature = Number(); this.platform.debug(`Meter: ${this.accessory.displayName} Temperature: ${this.CurrentTemperature}°c, fahrenheit: ${this.fahrenheit}`); } } @@ -252,7 +264,7 @@ export class Meter { const switchbot = this.connectBLE(); // Start to monitor advertisement packets switchbot.startScan({ - model: 'e', + model: 'T', id: this.device.bleMac, }).then(() => { // Set an event hander @@ -264,8 +276,8 @@ export class Meter { this.battery = ad.serviceData.battery; this.platform.device(`Meter: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`); this.platform.device(`Meter: ${this.accessory.displayName} model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName}, ` - + `temperature: ${ad.serviceData.temperature}, fahrenheit: ${ad.serviceData.fahrenheit}, humidity: ${ad.serviceData.humidity}, ` - + `battery: ${ad.serviceData.battery}`); + + `temperature: ${JSON.stringify(ad.serviceData.temperature)}, fahrenheit: ${ad.serviceData.fahrenheit}, ` + + `humidity: ${ad.serviceData.humidity}, battery: ${ad.serviceData.battery}`); }; // Wait 10 seconds return switchbot.wait(10000);