homebridge-blueair-purifier 1.0.10 → 1.0.11
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 +5 -0
- package/homebridge-ui/public/index.html +33 -33
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<link href="css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
|
2
2
|
<script src="js/bootstrap.min.js" crossorigin="anonymous"></script>
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
<div id="main" data-bs-theme="dark">
|
|
5
5
|
<div class="card">
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
<div class="card-header" id="uiButtons">
|
|
8
8
|
<h5 class="mb-0 text-center">
|
|
9
9
|
<button class="btn btn-primary" data-bs-toggle="collapse" data-bs-target="#discoverDevices"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</button>
|
|
13
13
|
</h5>
|
|
14
14
|
</div>
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
<div class="collapse" id="discoverDevices">
|
|
17
17
|
<div class="card-body">
|
|
18
18
|
<form>
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
<option value="Australia">Australia</option>
|
|
33
33
|
<option value="China">China</option>
|
|
34
34
|
<option value="Russia">Russia</option>
|
|
35
|
-
<option value="USA">USA</option>
|
|
35
|
+
<option value="USA">USA/Canada</option>
|
|
36
36
|
</select>
|
|
37
37
|
</div>
|
|
38
38
|
<button class="btn btn-primary btn-login" type="submit" id="discoverBtn" style="border: 0;">
|
|
@@ -59,49 +59,49 @@
|
|
|
59
59
|
</div>
|
|
60
60
|
</div>
|
|
61
61
|
</div>
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
</div>
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
<style>
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
.hide {
|
|
68
68
|
display: none;
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
.disabled {
|
|
72
72
|
pointer-events: none;
|
|
73
73
|
opacity: 0.5;
|
|
74
74
|
}
|
|
75
75
|
</style>
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
|
|
77
|
+
|
|
78
78
|
<script>
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
(async () => {
|
|
81
81
|
/*********************************************************************
|
|
82
82
|
* Initialize Javascript supporting code
|
|
83
83
|
*/
|
|
84
84
|
homebridge.showSpinner();
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
const { defaultConfig, defaultDeviceConfig } = await homebridge.request('/getDefaults');
|
|
87
87
|
const pluginConfig = await homebridge.getPluginConfig();
|
|
88
88
|
const configSchema = await homebridge.getPluginConfigSchema();
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
if (!pluginConfig.length) {
|
|
91
91
|
pluginConfig.push({});
|
|
92
92
|
}
|
|
93
93
|
let configuration = pluginConfig[0];
|
|
94
|
-
|
|
94
|
+
|
|
95
95
|
// Helper funcion to contol debug messages
|
|
96
96
|
function debugLog(s) {
|
|
97
97
|
if (configuration.uiDebug) {
|
|
98
98
|
console.debug(s);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
debugLog(`Plugin Config:\n${JSON.stringify(configuration, null, 2)}`);
|
|
103
103
|
configuration = await homebridge.request('/mergeToDefault', { config: configuration });
|
|
104
|
-
|
|
104
|
+
|
|
105
105
|
/*********************************************************************
|
|
106
106
|
* showToast event listener
|
|
107
107
|
* Provides information from server-side to the end user.
|
|
@@ -114,13 +114,13 @@
|
|
|
114
114
|
homebridge.toast.error(event.data.msg);
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
|
-
|
|
117
|
+
|
|
118
118
|
/*********************************************************************
|
|
119
119
|
* filterOutDefaults
|
|
120
120
|
* returns object for config.json that has default values removed
|
|
121
121
|
*/
|
|
122
122
|
function filterOutDefaults(object, defaults) {
|
|
123
|
-
|
|
123
|
+
|
|
124
124
|
function deleteEmptyObjects(object) {
|
|
125
125
|
for (const [k, v] of Object.entries(object)) {
|
|
126
126
|
if (!v || typeof v !== 'object' || v === null) {
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
}
|
|
134
134
|
return object;
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
let newObject = {};
|
|
138
138
|
for (const [k, v] of Object.entries(object)) {
|
|
139
139
|
if (k === 'devices') {
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
}
|
|
151
151
|
return deleteEmptyObjects(newObject);
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
|
|
154
154
|
/*********************************************************************
|
|
155
155
|
* createForm
|
|
156
156
|
* Update the plugin config GUI. Does not save to config.json
|
|
@@ -163,22 +163,22 @@
|
|
|
163
163
|
await homebridge.updatePluginConfig([changes]);
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
|
|
166
|
+
|
|
167
167
|
createForm(configSchema, configuration);
|
|
168
168
|
homebridge.hideSpinner();
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
/*********************************************************************
|
|
171
171
|
* Discover button clicked....
|
|
172
172
|
*/
|
|
173
173
|
document.getElementById('discoverBtn').addEventListener('click', async (e) => {
|
|
174
174
|
e.preventDefault();
|
|
175
|
-
|
|
175
|
+
|
|
176
176
|
const username = document.getElementById('username').value;
|
|
177
177
|
const password = document.getElementById('password').value;
|
|
178
178
|
const region = document.getElementById('region').value;
|
|
179
|
-
|
|
179
|
+
|
|
180
180
|
homebridge.showSpinner();
|
|
181
|
-
|
|
181
|
+
|
|
182
182
|
console.info(`Request login...`);
|
|
183
183
|
try {
|
|
184
184
|
const devices = await homebridge.request('/discover', { username, password, region });
|
|
@@ -209,7 +209,7 @@
|
|
|
209
209
|
const td = tr.insertCell();
|
|
210
210
|
td.appendChild(document.createTextNode(state.name));
|
|
211
211
|
td.setAttribute('scope', 'row');
|
|
212
|
-
|
|
212
|
+
|
|
213
213
|
tr.insertCell().appendChild(document.createTextNode(device.uuid));
|
|
214
214
|
tr.insertCell().appendChild(document.createTextNode(device.mac));
|
|
215
215
|
|
|
@@ -227,7 +227,7 @@
|
|
|
227
227
|
id: device.uuid,
|
|
228
228
|
name: state.name
|
|
229
229
|
};
|
|
230
|
-
|
|
230
|
+
|
|
231
231
|
configuration.devices.push({
|
|
232
232
|
...defaultDeviceConfig,
|
|
233
233
|
...newDevice
|
|
@@ -235,10 +235,10 @@
|
|
|
235
235
|
debugLog(`Adding new device:\n${JSON.stringify({ ...defaultDeviceConfig, ...newDevice }, null, 2)}`);
|
|
236
236
|
// refresh view
|
|
237
237
|
createForm(configSchema, configuration);
|
|
238
|
-
|
|
238
|
+
|
|
239
239
|
addCell.removeChild(button);
|
|
240
240
|
addCell.appendChild(document.createTextNode('Added'));
|
|
241
|
-
|
|
241
|
+
|
|
242
242
|
homebridge.toast.success('Device added');
|
|
243
243
|
});
|
|
244
244
|
addCell.appendChild(button);
|
|
@@ -248,17 +248,17 @@
|
|
|
248
248
|
table.innerHTML += `<tr><td>No devices found!</td></tr>`;
|
|
249
249
|
}
|
|
250
250
|
document.getElementById('discoverTableWrapper').style.display = 'block';
|
|
251
|
-
|
|
251
|
+
|
|
252
252
|
homebridge.hideSpinner();
|
|
253
253
|
|
|
254
254
|
} catch (e) {
|
|
255
255
|
homebridge.toast.error(e.message);
|
|
256
256
|
homebridge.hideSpinner();
|
|
257
257
|
return;
|
|
258
|
-
|
|
258
|
+
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
});
|
|
262
262
|
})();
|
|
263
|
-
|
|
264
|
-
</script>
|
|
263
|
+
|
|
264
|
+
</script>
|
package/package.json
CHANGED