Skip to content

Commit

Permalink
release-1.12.4: don't return undefined for missing chars
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Schroeder authored and Paul Schroeder committed Feb 4, 2024
1 parent 672b066 commit 0b66cd2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"displayName": "Levoit Humidifiers",
"main": "dist/index.js",
"license": "Apache-2.0",
"version": "1.12.3",
"version": "1.12.4",
"private": false,
"bugs": {
"url": "https://github.com/pschroeder89/homebridge-levoit-humidifiers/issues"
Expand Down
6 changes: 5 additions & 1 deletion src/characteristics/Active.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ const characteristic: {
get: async function (): Promise<Nullable<CharacteristicValue>> {
await this.device.updateInfo();

return this.device.isOn;
if (this.device.isOn) {
return true;
} else {
return false;
}
},
set: async function (value: CharacteristicValue) {
const boolValue = value == 1;
Expand Down
6 changes: 5 additions & 1 deletion src/characteristics/DisplayState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ const characteristic: {
} & AccessoryThisType = {
get: async function (): Promise<Nullable<CharacteristicValue>> {
await this.device.updateInfo();
return this.device.displayOn;
if (this.device.displayOn) {
return true;
} else {
return false;
}
},
set: async function (value: CharacteristicValue) {
const boolValue = value == 1;
Expand Down
4 changes: 3 additions & 1 deletion src/characteristics/Humidity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const characteristic: {
} & AccessoryThisType = {
get: async function (): Promise<Nullable<CharacteristicValue>> {
await this.device.updateInfo();

if (typeof this.device.humidityLevel !== 'number') {
return 0;
}
return this.device.humidityLevel;
},
};
Expand Down
3 changes: 3 additions & 0 deletions src/characteristics/LightBrightness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const characteristic: {
return this.device.brightnessLevel;
},
set: async function (value: CharacteristicValue) {
// Convert value to number
value = Number(value);

if (this.device.brightnessLevel > 0 && value > 0) {
// If light is on, and we are applying a non-zero value, change brightness to that level.
// Otherwise, LightState will handle on / off switching.
Expand Down

0 comments on commit 0b66cd2

Please sign in to comment.