Skip to content

Commit

Permalink
v5.10.9
Browse files Browse the repository at this point in the history
* Add plug-in Setting option to select temperature units (C or F) and time format (12hr or 24hr) when Display Modes are enabled.
  • Loading branch information
DMBlakeley committed Nov 15, 2023
1 parent 694fd91 commit b44233a
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 71 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/).

## v5.10.9
* Add plug-in Setting option to select temperature units (C or F) and time format (12hr or 24hr) when Display Modes are enabled.

## v5.10.8
* Update node-version: [18.x, 20.x], remove 16.x which is no longer supported by homebridge.

Expand Down
18 changes: 18 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,22 @@
"type": "boolean",
"default": false
},
"modeTemp": {
"title": "Select to display 'F' for Display Mode temperature (Default = 'C')",
"type": "boolean",
"default": false,
"condition": {
"functionBody": "return model.enableModes === true;"
}
},
"modeTime": {
"title": "Select to display '24hr' for Display Mode time (Default = '12hr')",
"type": "boolean",
"default": false,
"condition": {
"functionBody": "return model.enableModes === true;"
}
},
"development": {
"title": "Development Mode - Whether to enable Development mode to allow use of 'test' Awair devices lacking production/Awair OUI formatted Serial numbers.",
"type": "boolean",
Expand Down Expand Up @@ -198,6 +214,8 @@
"logging",
"verbose",
"enableModes",
"modeTemp",
"modeTime",
"development"
]
},
Expand Down
140 changes: 73 additions & 67 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": false,
"displayName": "Homebridge Awair2",
"name": "homebridge-awair2",
"version": "5.10.8",
"version": "5.10.9",
"description": "HomeKit integration of Awair air quality monitor as Dynamic Platform.",
"main": "dist/index.js",
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions src/configTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type AwairPlatformConfig = {
logging: boolean;
verbose: boolean;
development: boolean;
modeTemp: boolean;
ignoredDevices: [string];
};

Expand Down Expand Up @@ -54,8 +55,8 @@ export type UserConfig = {

export type DisplayConfig = {
mode: string; // score, temp, humid, co2, voc, pm25, clock
clock_mode: string; // 12hr, 24hr
temp_unit: string; // c, f
clock_mode: string; // 12hr, 24hr (default = 12hr)
temp_unit: string; // c, f (default = c)
};

export type LEDConfig = {
Expand Down
16 changes: 15 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class AwairPlatform implements DynamicPlatformPlugin {
private displayModes: string[] = ['Score', 'Temp', 'Humid', 'CO2', 'VOC', 'PM25', 'Clock'];
private ledModes: string[] = ['Auto', 'Sleep', 'Manual'];
private enableModes = false;
private temperatureUnits = 'c'; // default
private timeFormat = '12hr'; // default

/**
* The platform class constructor used when registering a plugin.
Expand Down Expand Up @@ -203,6 +205,18 @@ class AwairPlatform implements DynamicPlatformPlugin {
if ('enableModes' in this.config) {
this.enableModes = this.config.enableModes;
}

if ('modeTemp' in this.config) {
if (this.config.modeTemp === true) {
this.temperatureUnits = 'f';
}
}

if ('modeTime' in this.config) {
if (this.config.modeTime === true) {
this.timeFormat = '24hr';
}
}

if ('ignoredDevices' in this.config) {
this.ignoredDevices = this.config.ignoredDevices;
Expand Down Expand Up @@ -1355,7 +1369,7 @@ class AwairPlatform implements DynamicPlatformPlugin {
*/
async putDisplayMode(accessory: PlatformAccessory, mode: string): Promise<void> {
const url = `https://developer-apis.awair.is/v1/devices/${accessory.context.deviceType}/${accessory.context.deviceId}/display`;
const body = {'mode': mode.toLowerCase()};
const body = {'mode': mode.toLowerCase(), 'temp_unit': this.temperatureUnits, 'clock_mode': this.timeFormat};
const options = {
headers: {
'Authorization': `Bearer ${this.config.token}`,
Expand Down

0 comments on commit b44233a

Please sign in to comment.