homebridge-flume 2.0.9 → 3.0.0-beta.0
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 +17 -1
- package/config.schema.json +1 -11
- package/lib/connection/http.js +12 -19
- package/lib/homebridge-ui/public/index.html +0 -24
- package/lib/platform.js +19 -9
- package/lib/utils/constants.js +0 -2
- package/lib/utils/lang-en.js +3 -2
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to homebridge-flume will be documented in this file.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## BETA
|
|
6
|
+
|
|
7
|
+
### Breaking
|
|
8
|
+
|
|
9
|
+
- Remove official support for Node 14
|
|
10
|
+
- Remove option to disable plugin - this is now available in the Homebridge UI
|
|
11
|
+
- Remove option for debug logging - this will be enabled when using a beta version of the plugin
|
|
12
|
+
- Remove individual accessory logging options to simplify the config
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Support for shared devices (thanks [@ssmoss](https://github.com/ssmoss)!)
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Fix a potential login issue that might be terminating the process incorrectly
|
|
21
|
+
- Bump `node` recommended versions to v16.19.1 or v18.14.2
|
|
6
22
|
|
|
7
23
|
## 2.0.9 (2023-01-07)
|
|
8
24
|
|
package/config.schema.json
CHANGED
|
@@ -39,16 +39,6 @@
|
|
|
39
39
|
"required": true,
|
|
40
40
|
"description": "Your Flume Client Secret, found at https://portal.flumetech.com."
|
|
41
41
|
},
|
|
42
|
-
"debug": {
|
|
43
|
-
"title": "Debug Logging",
|
|
44
|
-
"type": "boolean",
|
|
45
|
-
"description": "Global logging setting for the plugin. If true then debug information will be added to the log."
|
|
46
|
-
},
|
|
47
|
-
"disablePlugin": {
|
|
48
|
-
"title": "Disable Plugin",
|
|
49
|
-
"type": "boolean",
|
|
50
|
-
"description": "If true, the plugin will remove all accessories and not load the plugin on restart."
|
|
51
|
-
},
|
|
52
42
|
"disableDeviceLogging": {
|
|
53
43
|
"type": "boolean",
|
|
54
44
|
"title": "Disable Device Logging",
|
|
@@ -66,7 +56,7 @@
|
|
|
66
56
|
{
|
|
67
57
|
"type": "fieldset",
|
|
68
58
|
"title": "Required Settings",
|
|
69
|
-
"items": ["username", "password", "clientId", "clientSecret"
|
|
59
|
+
"items": ["username", "password", "clientId", "clientSecret"]
|
|
70
60
|
},
|
|
71
61
|
{
|
|
72
62
|
"type": "fieldset",
|
package/lib/connection/http.js
CHANGED
|
@@ -7,7 +7,6 @@ import platformLang from '../utils/lang-en.js';
|
|
|
7
7
|
export default class {
|
|
8
8
|
constructor(platform) {
|
|
9
9
|
// Create variables usable by the class
|
|
10
|
-
this.debug = platform.config.debug;
|
|
11
10
|
this.log = platform.log;
|
|
12
11
|
this.username = platform.config.username;
|
|
13
12
|
this.password = platform.config.password;
|
|
@@ -59,8 +58,12 @@ export default class {
|
|
|
59
58
|
*/
|
|
60
59
|
|
|
61
60
|
// Log the response if in debug mode
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
this.log.debug('[HTTP obtainToken()] %s.', JSON.stringify(res.data));
|
|
62
|
+
|
|
63
|
+
// Check to see we got a proper response
|
|
64
|
+
if (!res.data.data || !res.data.data[0]) {
|
|
65
|
+
this.log.warn('[HTTP obtainToken()] %s.', JSON.stringify(res.data));
|
|
66
|
+
throw new Error(platformLang.noDataReceived);
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
// Make the token available in other functions
|
|
@@ -121,9 +124,7 @@ export default class {
|
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
// Log the response if in debug mode
|
|
124
|
-
|
|
125
|
-
this.log('[HTTP renewToken()] %s.', JSON.stringify(res.data));
|
|
126
|
-
}
|
|
127
|
+
this.log.debug('[HTTP renewToken()] %s.', JSON.stringify(res.data));
|
|
127
128
|
|
|
128
129
|
/*
|
|
129
130
|
{
|
|
@@ -170,7 +171,7 @@ export default class {
|
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
// Perform the HTTP request
|
|
173
|
-
const res = await axios.get(`https://api.flumetech.com/users/${this.userId}/devices`, {
|
|
174
|
+
const res = await axios.get(`https://api.flumetech.com/users/${this.userId}/devices?list_shared=true`, {
|
|
174
175
|
headers: { Authorization: `Bearer ${this.accessToken}` },
|
|
175
176
|
timeout: 10000,
|
|
176
177
|
});
|
|
@@ -181,9 +182,7 @@ export default class {
|
|
|
181
182
|
}
|
|
182
183
|
|
|
183
184
|
// Log the response if in debug mode
|
|
184
|
-
|
|
185
|
-
this.log('[HTTP getDevices()] %s.', JSON.stringify(res.data));
|
|
186
|
-
}
|
|
185
|
+
this.log.debug('[HTTP getDevices()] %s.', JSON.stringify(res.data));
|
|
187
186
|
|
|
188
187
|
return res.data.data;
|
|
189
188
|
} catch (err) {
|
|
@@ -219,9 +218,7 @@ export default class {
|
|
|
219
218
|
}
|
|
220
219
|
|
|
221
220
|
// Log the response if in debug mode
|
|
222
|
-
|
|
223
|
-
this.log('[HTTP getDeviceInfo()] %s.', JSON.stringify(res.data));
|
|
224
|
-
}
|
|
221
|
+
this.log.debug('[HTTP getDeviceInfo()] %s.', JSON.stringify(res.data));
|
|
225
222
|
|
|
226
223
|
// Parse the response
|
|
227
224
|
return res.data.data[0];
|
|
@@ -290,9 +287,7 @@ export default class {
|
|
|
290
287
|
}
|
|
291
288
|
|
|
292
289
|
// Log the response if in debug mode
|
|
293
|
-
|
|
294
|
-
this.log('[HTTP getWaterInfo()] %s.', JSON.stringify(res.data));
|
|
295
|
-
}
|
|
290
|
+
this.log.debug('[HTTP getWaterInfo()] %s.', JSON.stringify(res.data));
|
|
296
291
|
|
|
297
292
|
// Parse the response
|
|
298
293
|
return res.data.data[0];
|
|
@@ -320,9 +315,7 @@ export default class {
|
|
|
320
315
|
}
|
|
321
316
|
|
|
322
317
|
// Log the response if in debug mode
|
|
323
|
-
|
|
324
|
-
this.log('[HTTP getLeakInfo()] %s.', JSON.stringify(res.data));
|
|
325
|
-
}
|
|
318
|
+
this.log('[HTTP getLeakInfo()] %s.', JSON.stringify(res.data));
|
|
326
319
|
|
|
327
320
|
// Parse the response
|
|
328
321
|
return res.data.data[0];
|
|
@@ -22,15 +22,6 @@
|
|
|
22
22
|
<button type="button" class="btn btn-primary ml-0" id="menuSettings">Settings</button>
|
|
23
23
|
<button type="button" class="btn btn-primary mr-0" id="menuHome">Support</button>
|
|
24
24
|
</div>
|
|
25
|
-
<div
|
|
26
|
-
id="disabledBanner"
|
|
27
|
-
class="alert alert-secondary mb-0 mt-3"
|
|
28
|
-
role="alert"
|
|
29
|
-
style="display: none;"
|
|
30
|
-
>
|
|
31
|
-
Plugin is currently disabled
|
|
32
|
-
<button id="disabledEnable" type="button" class="btn btn-link p-0 m-0 float-right">Enable</button>
|
|
33
|
-
</div>
|
|
34
25
|
<div id="pageSupport" class="mt-4" style="display: none;">
|
|
35
26
|
<p class="text-center lead">Thank you for using <strong>homebridge-flume</strong></p>
|
|
36
27
|
<p class="text-center">The links below will take you to our GitHub wiki</p>
|
|
@@ -143,26 +134,11 @@
|
|
|
143
134
|
homebridge.showSchemaForm()
|
|
144
135
|
homebridge.hideSpinner()
|
|
145
136
|
}
|
|
146
|
-
showDisabledBanner = () => {
|
|
147
|
-
document.getElementById('disabledBanner').style.display = 'block'
|
|
148
|
-
}
|
|
149
|
-
enablePlugin = async () => {
|
|
150
|
-
homebridge.showSpinner()
|
|
151
|
-
document.getElementById('disabledBanner').style.display = 'none'
|
|
152
|
-
currentConfig[0].disablePlugin = false
|
|
153
|
-
await homebridge.updatePluginConfig(currentConfig)
|
|
154
|
-
await homebridge.savePluginConfig()
|
|
155
|
-
homebridge.hideSpinner()
|
|
156
|
-
}
|
|
157
137
|
menuHome.addEventListener('click', () => showSupport())
|
|
158
138
|
menuSettings.addEventListener('click', () => showSettings())
|
|
159
|
-
disabledEnable.addEventListener('click', () => enablePlugin())
|
|
160
139
|
if (currentConfig.length) {
|
|
161
140
|
document.getElementById('menuWrapper').style.display = 'inline-flex'
|
|
162
141
|
showSettings()
|
|
163
|
-
if (currentConfig[0].disablePlugin) {
|
|
164
|
-
showDisabledBanner()
|
|
165
|
-
}
|
|
166
142
|
} else {
|
|
167
143
|
currentConfig.push({ name: 'Flume' })
|
|
168
144
|
await homebridge.updatePluginConfig(currentConfig)
|
package/lib/platform.js
CHANGED
|
@@ -19,12 +19,13 @@ export default class {
|
|
|
19
19
|
try {
|
|
20
20
|
this.api = api;
|
|
21
21
|
this.log = log;
|
|
22
|
+
this.isBeta = plugin.version.includes('beta');
|
|
22
23
|
|
|
23
24
|
// Configuration objects for accessories
|
|
24
25
|
this.devicesInHB = new Map();
|
|
25
26
|
|
|
26
|
-
// Make sure user is running Homebridge v1.
|
|
27
|
-
if (!api.versionGreaterOrEqual?.('1.
|
|
27
|
+
// Make sure user is running Homebridge v1.5 or above
|
|
28
|
+
if (!api.versionGreaterOrEqual?.('1.5.0')) {
|
|
28
29
|
throw new Error(platformLang.hbVersionFail);
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -93,9 +94,7 @@ export default class {
|
|
|
93
94
|
this.config[key] = val;
|
|
94
95
|
}
|
|
95
96
|
break;
|
|
96
|
-
case 'debug':
|
|
97
97
|
case 'disableDeviceLogging':
|
|
98
|
-
case 'disablePlugin':
|
|
99
98
|
if (typeof val === 'string') {
|
|
100
99
|
logQuotes(key);
|
|
101
100
|
}
|
|
@@ -133,10 +132,21 @@ export default class {
|
|
|
133
132
|
// Log that the plugin initialisation has been successful
|
|
134
133
|
this.log('%s.', platformLang.initialised);
|
|
135
134
|
|
|
136
|
-
//
|
|
137
|
-
if (this.
|
|
138
|
-
this.
|
|
139
|
-
|
|
135
|
+
// Sort out some logging functions
|
|
136
|
+
if (this.isBeta) {
|
|
137
|
+
this.log.debug = this.log;
|
|
138
|
+
this.log.debugWarn = this.log.warn;
|
|
139
|
+
|
|
140
|
+
// Log that using a beta will generate a lot of debug logs
|
|
141
|
+
if (this.isBeta) {
|
|
142
|
+
const divide = '*'.repeat(platformLang.beta.length + 1); // don't forget the full stop (+1!)
|
|
143
|
+
this.log.warn(divide);
|
|
144
|
+
this.log.warn(`${platformLang.beta}.`);
|
|
145
|
+
this.log.warn(divide);
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
this.log.debug = () => {};
|
|
149
|
+
this.log.debugWarn = () => {};
|
|
140
150
|
}
|
|
141
151
|
|
|
142
152
|
// Ensure username and password have been provided
|
|
@@ -152,7 +162,7 @@ export default class {
|
|
|
152
162
|
// Require any libraries that the accessory instances use
|
|
153
163
|
this.cusChar = new platformChars(this.api);
|
|
154
164
|
|
|
155
|
-
// Set up the HTTP client if
|
|
165
|
+
// Set up the HTTP client if Flume username and password have been provided
|
|
156
166
|
this.httpClient = new httpClient(this);
|
|
157
167
|
await this.httpClient.obtainToken();
|
|
158
168
|
const deviceList = await this.httpClient.getDevices();
|
package/lib/utils/constants.js
CHANGED
package/lib/utils/lang-en.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
accNotFound: 'accessory not found',
|
|
3
|
+
beta: 'You are using a beta version of the plugin - you will experience more logging than normal',
|
|
3
4
|
brand: 'Flume',
|
|
4
5
|
cfgDef: 'is not a valid number so using default of',
|
|
5
6
|
cfgDup: 'will be ignored since another entry with this ID already exists',
|
|
@@ -19,9 +20,8 @@ export default {
|
|
|
19
20
|
devNotRemove: 'could not be removed from Homebridge as',
|
|
20
21
|
devNotUpdated: 'could not be updated as',
|
|
21
22
|
devRemove: 'has been removed from Homebridge',
|
|
22
|
-
disabled: 'To change this, set disablePlugin to false',
|
|
23
23
|
disabling: 'Disabling plugin',
|
|
24
|
-
hbVersionFail: 'Your version of Homebridge is too low - please update to v1.
|
|
24
|
+
hbVersionFail: 'Your version of Homebridge is too low - please update to v1.6',
|
|
25
25
|
httpRetry: 'Unable to reach Flume, retrying in 30 seconds',
|
|
26
26
|
initialised: 'Plugin initialised. Setting up accessories...',
|
|
27
27
|
initialising: 'Initialising plugin',
|
|
@@ -44,5 +44,6 @@ export default {
|
|
|
44
44
|
'Have time to give this plugin a review? https://bit.ly/hb-flume-review',
|
|
45
45
|
'This plugin currently has a 4☆ rating on HOOBS! https://bit.ly/hb-flume-review',
|
|
46
46
|
'Want to see this plugin in your own language? Let me know!',
|
|
47
|
+
'Want to beta test Homebridge 2.0? https://github.com/homebridge/homebridge/wiki/Homebridge-Beta-Testing',
|
|
47
48
|
],
|
|
48
49
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-flume",
|
|
3
3
|
"alias": "Flume",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0-beta.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ben Potter",
|
|
7
7
|
"email": "bwp91@icloud.com"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
31
31
|
"homebridge": "^1.6.0 || 2.0.0-beta.0",
|
|
32
|
-
"node": "^
|
|
32
|
+
"node": "^16.19.1 || ^18.14.2"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@homebridge/plugin-ui-utils": "^0.0.19",
|
|
61
|
-
"axios": "^1.
|
|
61
|
+
"axios": "^1.3.4",
|
|
62
62
|
"jwt-decode": "^3.1.2"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
66
|
-
"eslint-plugin-import": "^2.
|
|
67
|
-
"eslint-plugin-import-newlines": "^1.3.
|
|
66
|
+
"eslint-plugin-import": "^2.27.5",
|
|
67
|
+
"eslint-plugin-import-newlines": "^1.3.1",
|
|
68
68
|
"eslint-plugin-sort-exports": "^0.8.0",
|
|
69
|
-
"eslint": "^8.
|
|
69
|
+
"eslint": "^8.35.0"
|
|
70
70
|
}
|
|
71
71
|
}
|