Skip to content

Commit

Permalink
fix for #110
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Nov 25, 2021
1 parent 44345c1 commit a5e226a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 26 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
33 changes: 15 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <support@wondertechlabs.com> (https://github.com/SwitchBot)",
"license": "ISC",
Expand Down Expand Up @@ -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",
Expand Down
20 changes: 16 additions & 4 deletions src/devices/meters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
}
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit a5e226a

Please sign in to comment.