homebridge-winix-purifiers 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # homebridge-winix-purifiers
2
2
 
3
+ [![verified-by-homebridge](https://badgen.net/badge/homebridge/verified/purple)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)
3
4
  [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/regaw-leinad/homebridge-winix-purifiers/build.yml)](https://github.com/regaw-leinad/homebridge-winix-purifiers/actions)
4
5
  [![npm](https://img.shields.io/npm/dt/homebridge-winix-purifiers)](https://www.npmjs.com/package/homebridge-winix-purifiers)
5
6
 
@@ -8,8 +9,7 @@
8
9
  I bought some Winix C545 purifiers and wanted to control them from the Home app (like everything else haha). I found
9
10
  another Homebridge plugin, but it did not work out of the box (11 open issues at the time). Since that plugin's last
10
11
  update was in September 2020 (over 2 years ago at the time of writing), I decided to dive in and create my own plugin to
11
- support it. Right now it only officially supports the C545, since that's all I own, but we can expand this to other
12
- Winix purifiers with support from other device owners!
12
+ support it. We can expand this to other Winix purifiers with support from other device owners!
13
13
 
14
14
  ## Features
15
15
 
@@ -30,11 +30,21 @@ The following features are optionally supported:
30
30
  * Expose ambient light
31
31
  * Expose switch to turn Plasmawave `on` / `off`
32
32
 
33
+ ### Winix API Response Caching
34
+
35
+ By default, all individual responses from the Winix API are cached for `60` seconds. This helps prevent rate limiting
36
+ and reduces the number of requests made to the Winix API. The value can be configured with the `cacheIntervalSeconds`
37
+ property (see [Properties](#properties) below).
38
+
39
+ I personally have `cacheIntervalSeconds` set to `600` seconds (10 minutes) since I don't need to know the air quality
40
+ every minute - this significantly reduces the number of requests made to the Winix API.
41
+
33
42
  ## Device Support
34
43
 
35
44
  Currently, this plugin supports the following Winix air purifiers
36
45
 
37
46
  * C545
47
+ * C909
38
48
 
39
49
  ## Installation
40
50
 
@@ -62,7 +72,8 @@ In your `config.json`, add and update the following under the `accessories` sect
62
72
  "serialNumber": "WNXAI40001234",
63
73
  "exposeAirQuality": true,
64
74
  "exposeAmbientLight": false,
65
- "exposePlasmawave": false
75
+ "exposePlasmawave": false,
76
+ "cacheIntervalSeconds": 60
66
77
  }
67
78
  ]
68
79
  }
@@ -70,16 +81,17 @@ In your `config.json`, add and update the following under the `accessories` sect
70
81
 
71
82
  ### Properties
72
83
 
73
- | Parameter | Note |
74
- |----------------------|---------------------------------------------------------------------------------|
75
- | `accessory` | must always be set to `WinixPurifier` |
76
- | `name` | a human-readable name for the air purifier |
77
- | `model` | the model of the [supported air purifier](#Device-Support) |
78
- | `deviceId` | the unique identifier of the device (see below for details on how to find this) |
79
- | `serialNumber` | _(optional)_ the serial number of the device |
80
- | `exposeAirQuality` | _(optional)_ whether to expose an air quality sensor |
81
- | `exposeAmbientLight` | _(optional)_ whether to expose an ambient light sensor |
82
- | `exposePlasmawave` | _(optional)_ whether to expose Plasmawave control as a `Switch` |
84
+ | Name | Default Value | Note |
85
+ |------------------------|---------------|---------------------------------------------------------------------------------|
86
+ | `accessory` | Required | must always be set to `WinixPurifier` |
87
+ | `name` | Required | a human-readable name for the air purifier |
88
+ | `model` | Required | the model of the [supported air purifier](#Device-Support) |
89
+ | `deviceId` | Required | the unique identifier of the device (see below for details on how to find this) |
90
+ | `serialNumber` | null | the serial number of the device |
91
+ | `exposeAirQuality` | `false` | whether to expose an air quality sensor |
92
+ | `exposeAmbientLight` | `false` | whether to expose an ambient light sensor |
93
+ | `exposePlasmawave` | `false` | whether to expose Plasmawave control as a `Switch` |
94
+ | `cacheIntervalSeconds` | `60` | the amount of seconds to cache the responses from the Winix API |
83
95
 
84
96
  ## Device ids
85
97
 
@@ -96,3 +108,7 @@ a [Python CLI](https://github.com/hfern/winix). This CLI allows you to, among ot
96
108
  ids associated with your account. I have used this to successfully get my device ids. Follow the setup and auth steps
97
109
  in the [README](https://github.com/hfern/winix/blob/master/README.md). You should then be able to find your device ids
98
110
  in the file `~/.config/winix/config.json`
111
+
112
+ > **Note:** While third-party tools like [@hfern](https://github.com/hfern) Python CLI can be incredibly useful, it's
113
+ > important to be aware of potential security implications when using such tools. Always ensure you understand the risks
114
+ > and follow best practices for security when handling your device's credentials.
@@ -26,6 +26,12 @@
26
26
  "enum": [
27
27
  "C545"
28
28
  ]
29
+ },
30
+ {
31
+ "title": "C909",
32
+ "enum": [
33
+ "C909"
34
+ ]
29
35
  }
30
36
  ]
31
37
  },
@@ -63,8 +69,9 @@
63
69
  "cacheIntervalSeconds": {
64
70
  "title": "Winix Response Cache Interval (seconds)",
65
71
  "description": "Time, in seconds, for how long to reuse the cached response from Winix",
66
- "type": "number",
67
- "default": 10,
72
+ "type": "integer",
73
+ "default": 60,
74
+ "minimum": 1,
68
75
  "required": true
69
76
  }
70
77
  }
package/dist/accessory.js CHANGED
@@ -11,7 +11,7 @@ class WinixPurifierAccessory {
11
11
  const deviceName = config.name;
12
12
  this.deviceId = config.deviceId;
13
13
  this.latestStatus = {};
14
- this.cacheIntervalSeconds = config.cacheIntervalSeconds * 1000 || 10000;
14
+ this.cacheIntervalMs = config.cacheIntervalSeconds * 1000 || 60000;
15
15
  this.lastWinixPoll = -1;
16
16
  this.services = [];
17
17
  // Create services
@@ -350,7 +350,7 @@ class WinixPurifierAccessory {
350
350
  }
351
351
  }
352
352
  shouldUseCachedValue(v) {
353
- return v !== undefined && Date.now() - this.lastWinixPoll < this.cacheIntervalSeconds;
353
+ return v !== undefined && Date.now() - this.lastWinixPoll < this.cacheIntervalMs;
354
354
  }
355
355
  polledWinix() {
356
356
  this.lastWinixPoll = Date.now();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "private": false,
3
3
  "displayName": "Winix Air Purifiers",
4
4
  "name": "homebridge-winix-purifiers",
5
- "version": "1.2.0",
5
+ "version": "1.3.1",
6
6
  "description": "Homebridge plugin for Winix air purifiers",
7
7
  "license": "Apache-2.0",
8
8
  "repository": {
@@ -33,13 +33,14 @@
33
33
  "keywords": [
34
34
  "homebridge-plugin",
35
35
  "c545",
36
+ "c909",
36
37
  "winix",
37
38
  "winix c545",
39
+ "winix c909",
38
40
  "winix purifier",
39
41
  "winix air purifier"
40
42
  ],
41
43
  "dependencies": {
42
- "axios": "^1.1.2",
43
44
  "winix-api": "1.1.2"
44
45
  },
45
46
  "devDependencies": {