homebridge-flume 3.1.1 → 3.1.2
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/CHANGELOG.md +10 -42
- package/config.schema.json +41 -20
- package/dist/homebridge/accessory.js +16 -15
- package/dist/homebridge/accessory.js.map +1 -1
- package/dist/homebridge/index.d.ts +0 -3
- package/dist/homebridge/index.js +2 -4
- package/dist/homebridge/index.js.map +1 -1
- package/dist/homebridge/platform.d.ts +0 -3
- package/dist/homebridge/platform.js +20 -32
- package/dist/homebridge/platform.js.map +1 -1
- package/dist/homebridge/settings.d.ts +2 -0
- package/dist/homebridge/settings.js +3 -0
- package/dist/homebridge/settings.js.map +1 -0
- package/dist/homebridge-ui/public/index.html +17 -0
- package/dist/homebridge-ui/public/ui.js +1 -0
- package/dist/homebridge-ui/server.js +8 -2
- package/dist/homebridge-ui/server.js.map +1 -1
- package/dist/i18n/en.d.ts +66 -0
- package/dist/i18n/en.js +72 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/i18n.d.ts +75 -0
- package/dist/i18n/i18n.js +38 -0
- package/dist/i18n/i18n.js.map +1 -0
- package/dist/i18n/template.d.ts +66 -0
- package/dist/i18n/template.js +8 -0
- package/dist/i18n/template.js.map +1 -0
- package/dist/i18n/zz.d.ts +92 -0
- package/dist/i18n/zz.js +32 -0
- package/dist/i18n/zz.js.map +1 -0
- package/dist/model/api.d.ts +3 -3
- package/dist/model/api.js +16 -16
- package/dist/model/api.js.map +1 -1
- package/dist/model/auth.d.ts +2 -2
- package/dist/model/auth.js +22 -18
- package/dist/model/auth.js.map +1 -1
- package/dist/model/device.d.ts +1 -1
- package/dist/tools/storage.d.ts +3 -3
- package/dist/tools/storage.js +21 -18
- package/dist/tools/storage.js.map +1 -1
- package/dist/tools/version.d.ts +1 -0
- package/dist/tools/version.js +18 -0
- package/dist/tools/version.js.map +1 -0
- package/eslint.config.ts +35 -0
- package/package.json +13 -8
- package/src/homebridge-ui/public/index.html +6 -93
- package/dist/lang/en.d.ts +0 -28
- package/dist/lang/en.js +0 -39
- package/dist/lang/en.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
|
+
### HELP NEEDED!
|
|
2
|
+
|
|
3
|
+
Would you like to see Homebridge Flume in your language? Please consider [getting involved](https://github.com/mpatfield/homebridge-flume/issues/107).
|
|
4
|
+
|
|
1
5
|
# Change Log
|
|
2
6
|
|
|
3
7
|
All notable changes to homebridge-flume will be documented in this file.
|
|
4
8
|
|
|
9
|
+
## 3.1.2 (2025-06-22)
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- Dynamic translations
|
|
13
|
+
- Use node-persist for auth token caching
|
|
14
|
+
|
|
5
15
|
## 3.1.1 (2025-06-02)
|
|
6
16
|
|
|
7
17
|
### Added
|
|
8
|
-
|
|
9
18
|
- Fetch device name from Flume locations api
|
|
10
19
|
|
|
11
20
|
### Changed
|
|
12
|
-
|
|
13
21
|
- Updated dependencies
|
|
14
22
|
|
|
15
23
|
## 3.1.0 (2025-05-28)
|
|
16
24
|
|
|
17
25
|
### Added
|
|
18
|
-
|
|
19
26
|
- Devices can now be excluded from HomeKit by adding device IDs in config
|
|
20
27
|
- Fetch device name from Flume location information
|
|
21
28
|
- Volume units for usage data can be changed in config
|
|
22
29
|
|
|
23
30
|
### Changed
|
|
24
|
-
|
|
25
31
|
- Persist tokens across launches to avoid unnecessary authentication calls
|
|
26
32
|
- Limit the number of http retries with exponential backoff
|
|
27
33
|
- Beta versions no longer log unless "verbose" config flag is set to true
|
|
@@ -29,57 +35,47 @@ All notable changes to homebridge-flume will be documented in this file.
|
|
|
29
35
|
- Redact all personal info in logs
|
|
30
36
|
|
|
31
37
|
### Fixed
|
|
32
|
-
|
|
33
38
|
- `disableDeviceLogging` actually stops logging accessory changes
|
|
34
39
|
|
|
35
40
|
## 3.0.5 (2025-05-24)
|
|
36
41
|
|
|
37
42
|
### Changed
|
|
38
|
-
|
|
39
43
|
- While there are no new features, this release is a major rewrite to cleanup and modernize a lot of very old code. This will make it much easier to maintain and improve this plugin going forward.
|
|
40
44
|
|
|
41
45
|
## 3.0.4 (2025-05-19)
|
|
42
|
-
|
|
43
46
|
- Updating README and other metadata to reflect new plugin ownership
|
|
44
47
|
- Getting plugin ready for Homebridge v2
|
|
45
48
|
|
|
46
49
|
## 3.0.3 (2024-07-23)
|
|
47
|
-
|
|
48
50
|
- Maintenance release
|
|
49
51
|
|
|
50
52
|
## 3.0.2 (2023-03-24)
|
|
51
53
|
|
|
52
54
|
### Fixed
|
|
53
|
-
|
|
54
55
|
- Debug logging
|
|
55
56
|
|
|
56
57
|
## 3.0.1 (2023-03-11)
|
|
57
58
|
|
|
58
59
|
### Fixed
|
|
59
|
-
|
|
60
60
|
- Put `getLeakInfo()` into debug logging
|
|
61
61
|
|
|
62
62
|
## 3.0.0 (2023-03-11)
|
|
63
63
|
|
|
64
64
|
### Breaking
|
|
65
|
-
|
|
66
65
|
- Remove official support for Node 14
|
|
67
66
|
- Remove option to disable plugin - this is now available in the Homebridge UI
|
|
68
67
|
- Remove option for debug logging - this will be enabled when using a beta version of the plugin
|
|
69
68
|
|
|
70
69
|
### Added
|
|
71
|
-
|
|
72
70
|
- Support for shared devices (thanks [@ssmoss](https://github.com/ssmoss)!)
|
|
73
71
|
|
|
74
72
|
### Changed
|
|
75
|
-
|
|
76
73
|
- Fix a potential login issue that might be terminating the process incorrectly
|
|
77
74
|
- Bump `node` recommended versions to v16.19.1 or v18.15.0
|
|
78
75
|
|
|
79
76
|
## 2.0.9 (2023-01-07)
|
|
80
77
|
|
|
81
78
|
### Changed
|
|
82
|
-
|
|
83
79
|
- Bump `axios` to v1.2.2
|
|
84
80
|
- Bump `homebridge` recommended version to v1.6.0 or v2.0.0-beta
|
|
85
81
|
- Bump `node` recommended versions to v14.21.2 or v16.19.0 or v18.13.0
|
|
@@ -87,7 +83,6 @@ All notable changes to homebridge-flume will be documented in this file.
|
|
|
87
83
|
## 2.0.8 (2022-10-16)
|
|
88
84
|
|
|
89
85
|
### Changed
|
|
90
|
-
|
|
91
86
|
- Requests for device info will occur less often, meaning requests for leak info can occur more frequently
|
|
92
87
|
- Minimum refresh interval reduced to 1 minute
|
|
93
88
|
- Bump `node` recommended versions to v14.20.1 or v16.18.0 or v18.11.0
|
|
@@ -96,46 +91,39 @@ All notable changes to homebridge-flume will be documented in this file.
|
|
|
96
91
|
## 2.0.7 (2022-09-25)
|
|
97
92
|
|
|
98
93
|
### Changed
|
|
99
|
-
|
|
100
94
|
- Bump `node` recommended versions to v14.20.1 or v16.17.1
|
|
101
95
|
- Updated dev dependencies
|
|
102
96
|
|
|
103
97
|
## 2.0.6 (2022-08-23)
|
|
104
98
|
|
|
105
99
|
### Changed
|
|
106
|
-
|
|
107
100
|
- Bump `node` recommended versions to v14.20.0 or v16.17.0
|
|
108
101
|
- Bump `homebridge` recommended version to v1.5.0
|
|
109
102
|
|
|
110
103
|
## 2.0.5 (2022-06-26)
|
|
111
104
|
|
|
112
105
|
### Changed
|
|
113
|
-
|
|
114
106
|
- Updated dependencies
|
|
115
107
|
|
|
116
108
|
## 2.0.4 (2022-06-21)
|
|
117
109
|
|
|
118
110
|
### Changed
|
|
119
|
-
|
|
120
111
|
- Bump `node` recommended versions to v14.19.3 or v16.15.1
|
|
121
112
|
|
|
122
113
|
## 2.0.3 (2022-05-28)
|
|
123
114
|
|
|
124
115
|
### Changed
|
|
125
|
-
|
|
126
116
|
- More fixes and refactoring
|
|
127
117
|
|
|
128
118
|
## 2.0.2 (2022-05-28)
|
|
129
119
|
|
|
130
120
|
### Changed
|
|
131
|
-
|
|
132
121
|
- Bump `node` recommended versions to v14.19.3 or v16.15.0
|
|
133
122
|
- Updated dependencies
|
|
134
123
|
|
|
135
124
|
## 2.0.1 (2022-04-30)
|
|
136
125
|
|
|
137
126
|
### Changed
|
|
138
|
-
|
|
139
127
|
- Bump `axios` to v0.27.2
|
|
140
128
|
- Bump `node` recommended versions to v14.19.1 or v16.15.0
|
|
141
129
|
|
|
@@ -147,44 +135,37 @@ All notable changes to homebridge-flume will be documented in this file.
|
|
|
147
135
|
⚠️ The minimum required version of Node is now v14
|
|
148
136
|
|
|
149
137
|
### Changed
|
|
150
|
-
|
|
151
138
|
- Changed to ESM package
|
|
152
139
|
|
|
153
140
|
## 1.2.7 (2022-04-03)
|
|
154
141
|
|
|
155
142
|
### Changed
|
|
156
|
-
|
|
157
143
|
- Bump `axios` to v0.26.1
|
|
158
144
|
- Updated dependencies
|
|
159
145
|
|
|
160
146
|
## 1.2.6 (2022-02-27)
|
|
161
147
|
|
|
162
148
|
### Changed
|
|
163
|
-
|
|
164
149
|
- Bump `axios` to v0.26.0
|
|
165
150
|
- Bump `node` recommended versions to v14.19.0 or v16.14.0
|
|
166
151
|
|
|
167
152
|
## 1.2.5 (2022-01-24)
|
|
168
153
|
|
|
169
154
|
### Changed
|
|
170
|
-
|
|
171
155
|
- Bump `homebridge` recommended version to v1.4.0
|
|
172
156
|
- Bump `axios` to v0.25.0
|
|
173
157
|
|
|
174
158
|
## 1.2.4 (2022-01-13)
|
|
175
159
|
|
|
176
160
|
### Changed
|
|
177
|
-
|
|
178
161
|
- Bump `node` recommended versions to v14.18.3 or v16.13.2
|
|
179
162
|
|
|
180
163
|
### Fixed
|
|
181
|
-
|
|
182
164
|
- Plugin crash for older versions of Homebridge
|
|
183
165
|
|
|
184
166
|
## 1.2.3 (2022-01-03)
|
|
185
167
|
|
|
186
168
|
### Changed
|
|
187
|
-
|
|
188
169
|
- HOOBS certified badge on README
|
|
189
170
|
- Plugin will log HAPNodeJS version on startup
|
|
190
171
|
- Bump `homebridge` recommended version to v1.3.9
|
|
@@ -192,74 +173,61 @@ All notable changes to homebridge-flume will be documented in this file.
|
|
|
192
173
|
## 1.2.2 (2021-12-21)
|
|
193
174
|
|
|
194
175
|
### Changed
|
|
195
|
-
|
|
196
176
|
- Some config options rearranged for easier access
|
|
197
177
|
|
|
198
178
|
## 1.2.1 (2021-12-08)
|
|
199
179
|
|
|
200
180
|
### Changed
|
|
201
|
-
|
|
202
181
|
- Bump `homebridge` recommended version to v1.3.8
|
|
203
182
|
- Bump `node` recommended versions to v14.18.2 or v16.13.1
|
|
204
183
|
|
|
205
184
|
## 1.2.0 (2021-12-01)
|
|
206
185
|
|
|
207
186
|
### Added
|
|
208
|
-
|
|
209
187
|
- Previous month usage custom characteristic (viewable in HomeKit apps like Eve)
|
|
210
188
|
|
|
211
189
|
## 1.1.0 (2021-11-30)
|
|
212
190
|
|
|
213
191
|
### Added
|
|
214
|
-
|
|
215
192
|
- Daily and monthly usage custom characteristics (viewable in HomeKit apps like Eve)
|
|
216
193
|
|
|
217
194
|
### Removed
|
|
218
|
-
|
|
219
195
|
- `threshold` configuration option as unused
|
|
220
196
|
|
|
221
197
|
## 1.0.0 (2021-11-29)
|
|
222
198
|
|
|
223
199
|
### Added
|
|
224
|
-
|
|
225
200
|
- Plugin logo
|
|
226
201
|
|
|
227
202
|
## 0.7.0 (2021-11-24)
|
|
228
203
|
|
|
229
204
|
### Added
|
|
230
|
-
|
|
231
205
|
- `StatusFault` and `StatusLowBattery` characteristics to the `LeakSensor` service
|
|
232
206
|
|
|
233
207
|
## 0.6.0 (2021-11-24)
|
|
234
208
|
|
|
235
209
|
### Added
|
|
236
|
-
|
|
237
210
|
- Leak sensor service
|
|
238
211
|
|
|
239
212
|
### Changed
|
|
240
|
-
|
|
241
213
|
- Minimum refresh interval increased to two minutes
|
|
242
214
|
|
|
243
215
|
## 0.5.0 (2021-11-23)
|
|
244
216
|
|
|
245
217
|
### Added
|
|
246
|
-
|
|
247
218
|
- Make use of the debug logging option for HTTP responses
|
|
248
219
|
|
|
249
220
|
### Changed
|
|
250
|
-
|
|
251
221
|
- `client_id` and `client_secret` config options changed to `clientId` and `clientSecret` for consistency
|
|
252
222
|
|
|
253
223
|
## 0.4.0 (2021-11-23)
|
|
254
224
|
|
|
255
225
|
### Added
|
|
256
|
-
|
|
257
226
|
- The plugin will remove 'stale' accessories that don't appear in the obtained device list
|
|
258
227
|
|
|
259
228
|
## 0.3.1 (2021-11-23)
|
|
260
229
|
|
|
261
230
|
### Fixed
|
|
262
|
-
|
|
263
231
|
- Some logging references to Thermobit rather than Flume
|
|
264
232
|
|
|
265
233
|
## 0.3.0 (2021-11-22)
|
package/config.schema.json
CHANGED
|
@@ -3,75 +3,73 @@
|
|
|
3
3
|
"pluginType": "platform",
|
|
4
4
|
"singular": true,
|
|
5
5
|
"customUi": true,
|
|
6
|
-
"customUiPath": "./
|
|
6
|
+
"customUiPath": "./dist/homebridge-ui",
|
|
7
7
|
"schema": {
|
|
8
8
|
"type": "object",
|
|
9
9
|
"required": ["username", "password", "clientId", "clientSecret", "refreshInterval", "units"],
|
|
10
10
|
"properties": {
|
|
11
11
|
"name": {
|
|
12
12
|
"type": "string",
|
|
13
|
-
"title": "Plugin Name",
|
|
14
13
|
"default": "Flume"
|
|
15
14
|
},
|
|
16
15
|
"username": {
|
|
17
16
|
"type": "string",
|
|
18
|
-
"title": "
|
|
17
|
+
"title": "${config.title.username}",
|
|
19
18
|
"required": true
|
|
20
19
|
},
|
|
21
20
|
"password": {
|
|
22
21
|
"type": "string",
|
|
23
|
-
"title": "
|
|
22
|
+
"title": "${config.title.password}",
|
|
24
23
|
"required": true
|
|
25
24
|
},
|
|
26
25
|
"clientId": {
|
|
27
26
|
"type": "string",
|
|
28
|
-
"title": "
|
|
27
|
+
"title": "${config.title.clientId}",
|
|
29
28
|
"placeholder": "1234567890ABCD",
|
|
30
29
|
"required": true
|
|
31
30
|
},
|
|
32
31
|
"clientSecret": {
|
|
33
32
|
"type": "string",
|
|
34
|
-
"title": "
|
|
35
|
-
"description": "
|
|
33
|
+
"title": "${config.title.clientSecret}",
|
|
34
|
+
"description": "${config.description.clientSecret}",
|
|
36
35
|
"placeholder": "1234567890ABCDEFGHIJ",
|
|
37
36
|
"required": true
|
|
38
37
|
},
|
|
39
38
|
"refreshInterval": {
|
|
40
39
|
"type": "integer",
|
|
41
|
-
"title": "
|
|
42
|
-
"description": "
|
|
40
|
+
"title": "${config.title.refreshInterval}",
|
|
41
|
+
"description": "${config.description.refreshInterval}",
|
|
43
42
|
"default": 2,
|
|
44
43
|
"minimum": 1,
|
|
45
44
|
"required": true
|
|
46
45
|
},
|
|
47
46
|
"units": {
|
|
48
47
|
"type": "string",
|
|
49
|
-
"title": "
|
|
50
|
-
"description": "
|
|
48
|
+
"title": "${config.title.units}",
|
|
49
|
+
"description": "${config.description.units}",
|
|
51
50
|
"enum": ["GALLONS", "LITERS", "CUBIC_FEET", "CUBIC_METERS"],
|
|
52
|
-
"enumNames": ["
|
|
51
|
+
"enumNames": ["${config.enumNames.gallons}", "${config.enumNames.liters}", "${config.enumNames.cubicFeet}", "${config.enumNames.cubicMeters}"],
|
|
53
52
|
"default": "GALLONS",
|
|
54
53
|
"required": true
|
|
55
54
|
},
|
|
56
55
|
"disableDeviceLogging": {
|
|
57
56
|
"type": "boolean",
|
|
58
|
-
"title": "
|
|
59
|
-
"description": "
|
|
57
|
+
"title": "${config.title.disableDeviceLogging}",
|
|
58
|
+
"description": "${config.description.disableDeviceLogging}",
|
|
60
59
|
"default": false,
|
|
61
60
|
"required": false
|
|
62
61
|
},
|
|
63
62
|
"verbose": {
|
|
64
63
|
"type": "boolean",
|
|
65
|
-
"title": "
|
|
66
|
-
"description": "
|
|
64
|
+
"title": "${config.title.verbose}",
|
|
65
|
+
"description": "${config.description.verbose}",
|
|
67
66
|
"required": false
|
|
68
67
|
},
|
|
69
68
|
"excludeDevices": {
|
|
70
69
|
"type": "array",
|
|
71
|
-
"title": "
|
|
72
|
-
"description": "
|
|
70
|
+
"title": "${config.title.excludeDevices}",
|
|
71
|
+
"description": "${config.description.excludeDevices}",
|
|
73
72
|
"items": {
|
|
74
|
-
"title": "Device ID",
|
|
75
73
|
"type": "string"
|
|
76
74
|
},
|
|
77
75
|
"uniqueItems": true,
|
|
@@ -79,5 +77,28 @@
|
|
|
79
77
|
"required": false
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
|
-
}
|
|
80
|
+
},
|
|
81
|
+
"layout": [
|
|
82
|
+
{
|
|
83
|
+
"type": "fieldset",
|
|
84
|
+
"items": [
|
|
85
|
+
"username",
|
|
86
|
+
"password",
|
|
87
|
+
"clientId",
|
|
88
|
+
"clientSecret",
|
|
89
|
+
"refreshInterval",
|
|
90
|
+
"units",
|
|
91
|
+
"disableDeviceLogging",
|
|
92
|
+
"verbose",
|
|
93
|
+
{
|
|
94
|
+
"key": "excludeDevices",
|
|
95
|
+
"type": "array",
|
|
96
|
+
"items": {
|
|
97
|
+
"type": "string",
|
|
98
|
+
"title": "${config.title.deviceId}"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
]
|
|
83
104
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import strings from '../
|
|
1
|
+
import { strings } from '../i18n/i18n.js';
|
|
2
2
|
import { VolumeUnits } from '../model/types.js';
|
|
3
|
+
import getVersion from '../tools/version.js';
|
|
3
4
|
class CustomCharacteristic {
|
|
4
5
|
uuid;
|
|
5
6
|
name;
|
|
@@ -8,9 +9,9 @@ class CustomCharacteristic {
|
|
|
8
9
|
this.name = name;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
|
-
const TODAY_USAGE = new CustomCharacteristic('f25cc272-83cb-46a7-915a-259fa17364ed', strings.todayUsage);
|
|
12
|
-
const MONTH_USAGE = new CustomCharacteristic('580e224d-edf2-4c23-af79-cdbebfc509c5', strings.monthUsage);
|
|
13
|
-
const LAST_MONTH_USAGE = new CustomCharacteristic('69129d54-bdb8-46a1-a93b-f7e8d16d32a8', strings.lastMonth);
|
|
12
|
+
const TODAY_USAGE = new CustomCharacteristic('f25cc272-83cb-46a7-915a-259fa17364ed', strings.customChar.todayUsage);
|
|
13
|
+
const MONTH_USAGE = new CustomCharacteristic('580e224d-edf2-4c23-af79-cdbebfc509c5', strings.customChar.monthUsage);
|
|
14
|
+
const LAST_MONTH_USAGE = new CustomCharacteristic('69129d54-bdb8-46a1-a93b-f7e8d16d32a8', strings.customChar.lastMonth);
|
|
14
15
|
export class FlumeAccessory {
|
|
15
16
|
platform;
|
|
16
17
|
accessory;
|
|
@@ -40,12 +41,12 @@ export class FlumeAccessory {
|
|
|
40
41
|
this.Characteristic = this.HAP.Characteristic;
|
|
41
42
|
this.Service = this.HAP.Service;
|
|
42
43
|
accessory.getService(this.Service.AccessoryInformation)
|
|
43
|
-
.setCharacteristic(this.Characteristic.Name, name ?? strings.brand)
|
|
44
|
-
.setCharacteristic(this.Characteristic.ConfiguredName, name ?? strings.brand)
|
|
45
|
-
.setCharacteristic(this.Characteristic.Manufacturer, strings.brand)
|
|
44
|
+
.setCharacteristic(this.Characteristic.Name, name ?? strings.general.brand)
|
|
45
|
+
.setCharacteristic(this.Characteristic.ConfiguredName, name ?? strings.general.brand)
|
|
46
|
+
.setCharacteristic(this.Characteristic.Manufacturer, strings.general.brand)
|
|
46
47
|
.setCharacteristic(this.Characteristic.SerialNumber, device.id)
|
|
47
48
|
.setCharacteristic(this.Characteristic.Model, device.productName)
|
|
48
|
-
.setCharacteristic(this.Characteristic.FirmwareRevision,
|
|
49
|
+
.setCharacteristic(this.Characteristic.FirmwareRevision, getVersion());
|
|
49
50
|
this.charLeakDetected = this.Characteristic.LeakDetected;
|
|
50
51
|
this.charStatusLowBattery = this.Characteristic.StatusLowBattery;
|
|
51
52
|
this.charStatusFault = this.Characteristic.StatusFault;
|
|
@@ -71,19 +72,19 @@ export class FlumeAccessory {
|
|
|
71
72
|
this.isLeakDetected = this.device.isLeakDetected;
|
|
72
73
|
const value = this.isLeakDetected ? this.charLeakDetected.LEAK_DETECTED : this.charLeakDetected.LEAK_NOT_DETECTED;
|
|
73
74
|
this.leakService.updateCharacteristic(this.charLeakDetected, value);
|
|
74
|
-
this.logState(this.isLeakDetected ? "error" /* LogLevel.ERROR */ : "info" /* LogLevel.INFO */, this.isLeakDetected ? strings.leakDetected : strings.leakNotDetected);
|
|
75
|
+
this.logState(this.isLeakDetected ? "error" /* LogLevel.ERROR */ : "info" /* LogLevel.INFO */, this.isLeakDetected ? strings.status.leakDetected : strings.status.leakNotDetected);
|
|
75
76
|
}
|
|
76
77
|
if (this.device.isBatteryLow !== this.isBatteryLow) {
|
|
77
78
|
this.isBatteryLow = this.device.isBatteryLow;
|
|
78
79
|
const value = this.isBatteryLow ? this.charStatusLowBattery.BATTERY_LEVEL_LOW : this.charStatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
79
80
|
this.leakService.updateCharacteristic(this.charStatusLowBattery, value);
|
|
80
|
-
this.logState(this.isBatteryLow ? "warn" /* LogLevel.WARN */ : "info" /* LogLevel.INFO */, this.isBatteryLow ? strings.batteryLow : strings.batteryNormal);
|
|
81
|
+
this.logState(this.isBatteryLow ? "warn" /* LogLevel.WARN */ : "info" /* LogLevel.INFO */, this.isBatteryLow ? strings.status.batteryLow : strings.status.batteryNormal);
|
|
81
82
|
}
|
|
82
83
|
if (this.device.isDisconnected !== this.isDisconnected) {
|
|
83
84
|
this.isDisconnected = this.device.isDisconnected;
|
|
84
85
|
const value = this.isDisconnected ? this.charStatusFault.GENERAL_FAULT : this.charStatusFault.NO_FAULT;
|
|
85
86
|
this.leakService.updateCharacteristic(this.charStatusFault, value);
|
|
86
|
-
this.logState(this.isDisconnected ? "warn" /* LogLevel.WARN */ : "info" /* LogLevel.INFO */, this.isDisconnected ? strings.connectionFault : strings.connectionNormal);
|
|
87
|
+
this.logState(this.isDisconnected ? "warn" /* LogLevel.WARN */ : "info" /* LogLevel.INFO */, this.isDisconnected ? strings.status.connectionFault : strings.status.connectionNormal);
|
|
87
88
|
}
|
|
88
89
|
this.todayUsageChar.updateValue(this.device.usageToday);
|
|
89
90
|
this.monthUsageChar.updateValue(this.device.usageMonth);
|
|
@@ -91,10 +92,10 @@ export class FlumeAccessory {
|
|
|
91
92
|
}
|
|
92
93
|
stringForUnits() {
|
|
93
94
|
switch (this.units) {
|
|
94
|
-
case VolumeUnits.GALLONS: return strings.
|
|
95
|
-
case VolumeUnits.LITERS: return strings.
|
|
96
|
-
case VolumeUnits.CUBIC_FEET: return strings.
|
|
97
|
-
case VolumeUnits.CUBIC_METERS: return strings.
|
|
95
|
+
case VolumeUnits.GALLONS: return strings.config.enumNames.gallons;
|
|
96
|
+
case VolumeUnits.LITERS: return strings.config.enumNames.liters;
|
|
97
|
+
case VolumeUnits.CUBIC_FEET: return strings.config.enumNames.cubicFeet;
|
|
98
|
+
case VolumeUnits.CUBIC_METERS: return strings.config.enumNames.cubicMeters;
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
clearCustomCharacteristics() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessory.js","sourceRoot":"","sources":["../../src/homebridge/accessory.ts"],"names":[],"mappings":"AAIA,OAAO,OAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"accessory.js","sourceRoot":"","sources":["../../src/homebridge/accessory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,MAAM,oBAAoB;IACH;IAAuB;IAA5C,YAAqB,IAAY,EAAW,IAAY;QAAnC,SAAI,GAAJ,IAAI,CAAQ;QAAW,SAAI,GAAJ,IAAI,CAAQ;IACxD,CAAC;CACF;AAED,MAAM,WAAW,GAAG,IAAI,oBAAoB,CAAC,sCAAsC,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AACpH,MAAM,WAAW,GAAG,IAAI,oBAAoB,CAAC,sCAAsC,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AACpH,MAAM,gBAAgB,GAAG,IAAI,oBAAoB,CAAC,sCAAsC,EAAE,OAAO,CAAC,UAAU,CAAC,SAAS,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AAC,IAAI,CAAE,CAAC;QAC1D,CAAC;aAAM,CAAC;YAEN,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1C,MAAM,oBAAoB,GAAG,MAAM,UAAW,SAAQ,IAAI,CAAC,cAAc;gBACvE;oBACE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;wBAC1B,MAAM,+BAAgB;wBACtB,KAAK,EAAE,uDAAmC;wBAC1C,IAAI,EAAE,WAAW;qBAClB,CAAC,CAAC;oBACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;gBACtC,CAAC;aACF,CAAC;YACF,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;YAClE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAC1B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,QAAQ,CAAC,KAAe,EAAE,OAAe;QAC/C,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF"}
|
package/dist/homebridge/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { FlumePlatform
|
|
2
|
-
|
|
3
|
-
* This method registers the platform with Homebridge
|
|
4
|
-
*/
|
|
1
|
+
import { FlumePlatform } from './platform.js';
|
|
2
|
+
import { PLATFORM_ALIAS } from './settings.js';
|
|
5
3
|
export default (api) => {
|
|
6
4
|
api.registerPlatform(PLATFORM_ALIAS, FlumePlatform);
|
|
7
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/homebridge/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/homebridge/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,eAAe,CAAC,GAAQ,EAAE,EAAE;IAC1B,GAAG,CAAC,gBAAgB,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;AACtD,CAAC,CAAC"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, PlatformConfig } from 'homebridge';
|
|
2
|
-
export declare const PLATFORM_ALIAS = "Flume";
|
|
3
2
|
export declare class FlumePlatform implements DynamicPlatformPlugin {
|
|
4
3
|
readonly log: Logger;
|
|
5
4
|
readonly config: PlatformConfig;
|
|
6
5
|
readonly api: API;
|
|
7
|
-
private readonly storagePath;
|
|
8
6
|
private flumeAPI;
|
|
9
7
|
private readonly accessories;
|
|
10
8
|
constructor(log: Logger, config: PlatformConfig, api: API);
|
|
11
|
-
get packageVersion(): string;
|
|
12
9
|
private didFinishLaunching;
|
|
13
10
|
private shutdown;
|
|
14
11
|
private initializeAccessory;
|
|
@@ -1,57 +1,41 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
1
|
import { FlumeAccessory } from './accessory.js';
|
|
5
|
-
import
|
|
2
|
+
import { PLATFORM_ALIAS, PLUGIN_NAME } from './settings.js';
|
|
3
|
+
import { setLanguage, strings } from '../i18n/i18n.js';
|
|
6
4
|
import { FlumeAPI } from '../model/api.js';
|
|
7
|
-
import { STORAGE_FILE_NAME } from '../tools/storage.js';
|
|
8
5
|
import { VolumeUnits } from '../model/types.js';
|
|
9
|
-
|
|
10
|
-
const PLUGIN_NAME = 'homebridge-flume';
|
|
6
|
+
import getVersion from '../tools/version.js';
|
|
11
7
|
export class FlumePlatform {
|
|
12
8
|
log;
|
|
13
9
|
config;
|
|
14
10
|
api;
|
|
15
|
-
storagePath;
|
|
16
11
|
flumeAPI = null;
|
|
17
12
|
accessories = new Map();
|
|
18
13
|
constructor(log, config, api) {
|
|
19
14
|
this.log = log;
|
|
20
15
|
this.config = config;
|
|
21
16
|
this.api = api;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.log.info('v%s | System %s | Node %s | HB v%s | HAPNodeJS v%s',
|
|
17
|
+
const userLang = Intl.DateTimeFormat().resolvedOptions().locale.split('-')[0];
|
|
18
|
+
setLanguage(userLang);
|
|
19
|
+
this.log.info('v%s | System %s | Node %s | HB v%s | HAPNodeJS v%s', getVersion(), process.platform, process.version, api.serverVersion, api.hap.HAPLibraryVersion());
|
|
25
20
|
this.api.on('didFinishLaunching', () => this.didFinishLaunching());
|
|
26
21
|
this.api.on('shutdown', () => this.shutdown());
|
|
27
22
|
}
|
|
28
|
-
get packageVersion() {
|
|
29
|
-
try {
|
|
30
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
31
|
-
const packageJSONPath = path.join(__dirname, '../../package.json');
|
|
32
|
-
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, { encoding: 'utf8' }));
|
|
33
|
-
return packageJSON.version;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
return '0.0.0';
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
23
|
async didFinishLaunching() {
|
|
40
24
|
if (!this.config.username ||
|
|
41
25
|
!this.config.password ||
|
|
42
26
|
!this.config.clientId ||
|
|
43
27
|
!this.config.clientSecret ||
|
|
44
28
|
!this.config.refreshInterval) {
|
|
45
|
-
this.log.error(strings.badConfig);
|
|
29
|
+
this.log.error(strings.errors.badConfig);
|
|
46
30
|
return;
|
|
47
31
|
}
|
|
48
|
-
this.flumeAPI = await FlumeAPI.connect(this.config.username, this.config.password, this.config.clientId, this.config.clientSecret, this.config.refreshInterval, this.config.units ?? VolumeUnits.GALLONS, this.
|
|
32
|
+
this.flumeAPI = await FlumeAPI.connect(this.config.username, this.config.password, this.config.clientId, this.config.clientSecret, this.config.refreshInterval, this.config.units ?? VolumeUnits.GALLONS, this.api.user.persistPath(), this.log, this.config.verbose);
|
|
49
33
|
const keepDevices = new Set();
|
|
50
34
|
const excludeDevices = new Set(this.config.excludeDevices ?? []);
|
|
51
35
|
const devices = this.flumeAPI.devices.filter((device) => !excludeDevices.has(device.id));
|
|
52
36
|
if (devices.length === 0) {
|
|
53
37
|
this.accessories.forEach((accessory) => this.removeAccessory(accessory));
|
|
54
|
-
this.log.warn(strings.noDevices);
|
|
38
|
+
this.log.warn(strings.errors.noDevices);
|
|
55
39
|
this.shutdown();
|
|
56
40
|
return;
|
|
57
41
|
}
|
|
@@ -59,14 +43,13 @@ export class FlumePlatform {
|
|
|
59
43
|
keepDevices.add(device.id);
|
|
60
44
|
this.initializeAccessory(device);
|
|
61
45
|
});
|
|
62
|
-
// Remove any stale accessories that don't appear in the device list
|
|
63
46
|
this.accessories.forEach((accessory) => {
|
|
64
47
|
if (!keepDevices.has(accessory.context.deviceId)) {
|
|
65
48
|
this.removeAccessory(accessory);
|
|
66
49
|
}
|
|
67
50
|
});
|
|
68
|
-
const randIndex = Math.floor(Math.random() * strings.
|
|
69
|
-
this.log.info(strings.complete, strings.
|
|
51
|
+
const randIndex = Math.floor(Math.random() * strings.startup.welcome.length);
|
|
52
|
+
this.log.info(strings.startup.complete, strings.startup.welcome[randIndex]);
|
|
70
53
|
}
|
|
71
54
|
shutdown() {
|
|
72
55
|
this.flumeAPI?.teardown();
|
|
@@ -76,8 +59,13 @@ export class FlumePlatform {
|
|
|
76
59
|
const name = this.flumeAPI?.locationNames.get(device.locationId);
|
|
77
60
|
let accessory = this.accessories.get(uuid);
|
|
78
61
|
if (!accessory) {
|
|
79
|
-
|
|
80
|
-
|
|
62
|
+
if (name) {
|
|
63
|
+
this.log.info('%s %s [%s]', strings.startup.newDevice, name, device.id);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.log.info('%s [%s]', strings.startup.newDevice, device.id);
|
|
67
|
+
}
|
|
68
|
+
accessory = new this.api.platformAccessory(strings.general.brand, uuid);
|
|
81
69
|
accessory.context.deviceId = device.id;
|
|
82
70
|
accessory.context.deviceName = name;
|
|
83
71
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_ALIAS, [accessory]);
|
|
@@ -91,11 +79,11 @@ export class FlumePlatform {
|
|
|
91
79
|
new FlumeAccessory(this, accessory, device, name, units, this.config.disableDeviceLogging);
|
|
92
80
|
}
|
|
93
81
|
configureAccessory(accessory) {
|
|
94
|
-
this.log.info(strings.restoringDevice, accessory.context.deviceName ?? accessory.context.deviceId);
|
|
82
|
+
this.log.info(strings.startup.restoringDevice, accessory.context.deviceName ?? accessory.context.deviceId);
|
|
95
83
|
this.accessories.set(accessory.UUID, accessory);
|
|
96
84
|
}
|
|
97
85
|
removeAccessory(accessory) {
|
|
98
|
-
this.log.info(strings.removeDevice, accessory.context.deviceName ?? accessory.context.deviceId);
|
|
86
|
+
this.log.info(strings.startup.removeDevice, accessory.context.deviceName ?? accessory.context.deviceId);
|
|
99
87
|
this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_ALIAS, [accessory]);
|
|
100
88
|
this.accessories.delete(accessory.UUID);
|
|
101
89
|
}
|