@homebridge-plugins/homebridge-wemo 7.5.3 → 7.6.0-beta.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to `@homebridge-plugins/homebridge-wemo` will be documented in this file.
4
4
 
5
+ ## v7.6.0 (Pending Release)
6
+
7
+ ### Changed
8
+
9
+ - feat(ui): add, remove and hide devices from the config via the my devices tab
10
+ - style(ui): standardise the custom ui layout and sync the support tab with the readme
11
+
5
12
  ## v7.5.3 (2026-07-18)
6
13
 
7
14
  ### Changed
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <a href="https://github.com/homebridge-plugins/homebridge-wemo"><img alt="Homebridge Verified" src="https://user-images.githubusercontent.com/43026681/126868557-d0983348-d124-4247-bea9-7dcc62849cdf.png" width="600px"></a>
2
+ <a href="https://github.com/homebridge-plugins/homebridge-wemo"><img alt="Homebridge Verified" src="https://raw.githubusercontent.com/homebridge-plugins/homebridge-wemo/latest/branding/Homebridge_x_Wemo.png" width="600px"></a>
3
3
  </p>
4
4
  <span align="center">
5
5
 
@@ -39,7 +39,7 @@ Homebridge plugin to integrate Wemo devices into HomeKit
39
39
 
40
40
  - [Installation](https://github.com/homebridge-plugins/homebridge-wemo/wiki/Installation)
41
41
  - [Configuration](https://github.com/homebridge-plugins/homebridge-wemo/wiki/Configuration)
42
- - [Beta Version](https://github.com/homebridge/homebridge/wiki/How-to-Install-Alternate-Plugin-Versions)
42
+ - [Beta Version](https://github.com/homebridge-plugins/homebridge-wemo/wiki/Beta-Version)
43
43
  - [Node Version](https://github.com/homebridge-plugins/homebridge-wemo/wiki/Node-Version)
44
44
 
45
45
  ### Features
Binary file
@@ -3,7 +3,7 @@
3
3
  "pluginType": "platform",
4
4
  "customUi": true,
5
5
  "customUiPath": "./lib/homebridge-ui",
6
- "headerDisplay": "<p align=\"center\"><img width=\"60%\" src=\"https://user-images.githubusercontent.com/43026681/126868557-d0983348-d124-4247-bea9-7dcc62849cdf.png\"></p><p align=\"center\">For help and support please visit our <a href=\"https://github.com/homebridge-plugins/homebridge-wemo/wiki\">GitHub Wiki</a>. We hope you find this plugin useful!</p>",
6
+ "headerDisplay": "<p align=\"center\"><img width=\"250px\" src=\"https://raw.githubusercontent.com/homebridge-plugins/homebridge-wemo/latest/branding/Homebridge_x_Wemo.png\"></p><p align=\"center\">For help and support please visit our <a href=\"https://github.com/homebridge-plugins/homebridge-wemo/wiki\">GitHub Wiki</a>. We hope you find this plugin useful!</p>",
7
7
  "singular": true,
8
8
  "strictValidation": true,
9
9
  "schema": {
@@ -17,6 +17,22 @@
17
17
  color: #eeeeee !important;
18
18
  font-weight: 500 !important;
19
19
  }
20
+
21
+ .list-group-item {
22
+ background-color: #333333;
23
+ border-color: #444444;
24
+ color: #eeeeee;
25
+ }
26
+
27
+ .text-muted {
28
+ color: #aaaaaa !important;
29
+ }
30
+ }
31
+ .min-w-50 {
32
+ min-width: 50px;
33
+ }
34
+ .action-desc {
35
+ font-size: 0.85rem;
20
36
  }
21
37
  select {
22
38
  background-image:
@@ -60,11 +76,46 @@
60
76
  <div id="pageDevices" class="mt-4" style="display: none;">
61
77
  <div id="deviceInfo">
62
78
  <form>
63
- <div class="form-group">
79
+ <div class="form-group mb-0">
64
80
  <select class="form-control" id="deviceSelect"></select>
65
81
  </div>
66
82
  </form>
67
- <table class="table w-100 mt-3" id="deviceTable" style="display: none;">
83
+ <ul class="list-group mt-4 mb-4 mx-0" id="configActionList" style="display: none;">
84
+ <li class="list-group-item">
85
+ <div class="d-flex justify-content-between align-items-center">
86
+ <div class="pr-2">
87
+ <div>Add All Devices</div>
88
+ <div class="text-muted action-desc">Add all devices to the config that are not already in the config.</div>
89
+ </div>
90
+ <button type="button" class="btn btn-primary m-0 ml-3 py-1 min-w-50" id="addAllBtn" aria-label="Add all devices to the config">
91
+ <i aria-hidden="true" class="fas fa-arrow-right"></i>
92
+ </button>
93
+ </div>
94
+ </li>
95
+ <li class="list-group-item">
96
+ <div class="d-flex justify-content-between align-items-center">
97
+ <div class="pr-2">
98
+ <div id="deviceConfigTitle">Add This Device</div>
99
+ <div class="text-muted action-desc" id="deviceConfigText">Add this device to the plugin config.</div>
100
+ </div>
101
+ <button type="button" class="btn btn-primary m-0 ml-3 py-1 min-w-50" id="deviceConfigBtn" aria-label="Add this device to the config">
102
+ <i aria-hidden="true" class="fas fa-arrow-right"></i>
103
+ </button>
104
+ </div>
105
+ </li>
106
+ <li class="list-group-item">
107
+ <div class="d-flex justify-content-between align-items-center">
108
+ <div class="pr-2">
109
+ <div id="hideDeviceTitle">Hide This Device</div>
110
+ <div class="text-muted action-desc" id="hideDeviceText">Hide this device from HomeKit. This adds the device to the config if needed.</div>
111
+ </div>
112
+ <button type="button" class="btn btn-primary m-0 ml-3 py-1 min-w-50" id="hideDeviceBtn" aria-label="Hide this device from HomeKit">
113
+ <i aria-hidden="true" class="fas fa-arrow-right"></i>
114
+ </button>
115
+ </div>
116
+ </li>
117
+ </ul>
118
+ <table class="table w-100 mt-0" id="deviceTable" style="display: none;">
68
119
  <thead>
69
120
  <tr class="table-active">
70
121
  <th scope="col" style="width: 40%;">Device Name</th>
@@ -111,105 +162,306 @@
111
162
  </table>
112
163
  </div>
113
164
  </div>
114
- <div id="pageSupport" class="mt-4" style="display: none;">
165
+ <div id="pageSupport" class="mt-4" style="display: none">
115
166
  <p class="text-center lead">Thank you for using <strong>homebridge-wemo</strong></p>
116
- <p class="text-center">The links below will take you to our GitHub wiki</p>
117
- <h4>Setup</h4>
167
+ <h5>Plugin Information</h5>
168
+ <ul>
169
+ <li>This plugin allows you to view and control your Wemo devices within HomeKit. The plugin:</li>
118
170
  <ul>
119
- <li>
120
- <a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Installation" target="_blank"
121
- >Installation</a
122
- >
123
- </li>
124
- <li>
125
- <a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Configuration" target="_blank"
126
- >Configuration</a
127
- >
128
- </li>
129
- <li>
130
- <a href="https://github.com/homebridge/homebridge/wiki/How-to-Install-Alternate-Plugin-Versions" target="_blank"
131
- >Beta Version</a
132
- >
133
- </li>
134
- <li>
135
- <a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Node-Version" target="_blank"
136
- >Node Version</a
137
- >
138
- </li>
171
+ <li>does not require your Wemo credentials as uses local network discovery (SSDP) and local control</li>
172
+ <li>will attempt to control your devices via a local HTTP request</li>
173
+ <li>will attempt to establish a UPnP connection to your devices to listen for external changes (if disabled, HTTP polling is used)</li>
139
174
  </ul>
140
- <h4>Features</h4>
175
+ </ul>
176
+ <p>&gt; [!NOTE]</p>
177
+ <p>&gt; This plugin does not use the Wemo cloud service - it is designed to work entirely on your local network.</p>
178
+ <p>&gt; This means that the plugin should continue to work after the Wemo cloud service is discontinued.</p>
179
+ <p>&gt; See <a href="https://github.com/homebridge-plugins/homebridge-wemo/issues/203" target="_blank">issue #203</a> for more information.</p>
180
+ <h5>Prerequisites</h5>
181
+ <ul>
182
+ <li>To use this plugin, you will need to already have:</li>
141
183
  <ul>
142
- <li>
143
- <a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Supported-Devices" target="_blank"
144
- >Supported Devices</a
145
- >
146
- </li>
147
- </ul>
148
- <h4>Help/About</h4>
149
- <ul>
150
- <li>
151
- <a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Common-Errors" target="_blank"
152
- >Common Errors</a
153
- >
154
- </li>
155
- <li>
156
- <a href="https://github.com/homebridge-plugins/homebridge-wemo/issues/new/choose" target="_blank"
157
- >Support Request</a
158
- >
159
- </li>
160
- <li>
161
- <a href="https://github.com/homebridge-plugins/homebridge-wemo/blob/latest/CHANGELOG.md" target="_blank"
162
- >Changelog</a
163
- >
164
- </li>
165
- <li><a href="https://github.com/sponsors/bwp91" target="_blank">About Me</a></li>
166
- </ul>
167
- <h4>Credits</h4>
168
- <ul>
169
- <li>
170
- To the creator of this plugin:
171
- <a href="https://github.com/rudders" target="_blank">@rudders</a>, and to
172
- <a href="https://github.com/devbobo" target="_blank">@devbobo</a> for his contributions.
173
- </li>
174
- <li>
175
- To the creator of
176
- <a href="https://github.com/timonreinhard/wemo-client" target="_blank">wemo-client</a> (which
177
- is now contained within this plugin):
178
- <a href="https://github.com/timonreinhard" target="_blank">@timonreinhard</a>.
179
- </li>
180
- <li>
181
- To <a href="http://www.hardill.me.uk/wordpress/tag/wemo/" target="_blank">Ben Hardill</a> for
182
- his research on Wemo devices.
183
- </li>
184
- <li>To all users who have helped/tested to enable functionality for new devices.</li>
185
- <li>
186
- To the creators/contributors of
187
- <a href="https://github.com/simont77/fakegato-history" target="_blank">Fakegato</a>:
188
- <a href="https://github.com/simont77" target="_blank">@simont77</a> and
189
- <a href="https://github.com/NorthernMan54" target="_blank">@NorthernMan54</a>.
190
- </li>
191
- <li>
192
- To the creator of the awesome plugin header logo:
193
- <a href="https://www.instagram.com/keryan.me" target="_blank">Keryan Belahcene</a>.
194
- </li>
195
- <li>
196
- To the creators/contributors of
197
- <a href="https://homebridge.io" target="_blank">Homebridge</a> who make this plugin possible.
198
- </li>
199
- </ul>
200
- <h4>Disclaimer</h4>
201
- <ul>
202
- <li>
203
- I am in no way affiliated with Belkin/Wemo and this plugin is a personal project that I
204
- maintain in my free time.
205
- </li>
206
- <li>Use this plugin entirely at your own risk - please see licence for more information.</li>
184
+ <li><a href="https://nodejs.org" target="_blank">Node</a>: latest version of <code>v22</code> or <code>v24</code> - any other major version is not supported.</li>
185
+ <li><a href="https://homebridge.io" target="_blank">Homebridge</a>: <code>v1.6</code> or above - refer to link for more information and installation instructions.</li>
186
+ <li>For the UPnP connection, make sure your Homebridge instance has an allocated IP from the same IP network or VLAN as your Wemo devices. Otherwise, you should disable the UPnP connection to avoid connection errors.</li>
207
187
  </ul>
188
+ </ul>
189
+ <h5>Setup</h5>
190
+ <ul>
191
+ <li><a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Installation" target="_blank">Installation</a></li>
192
+ <li><a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Configuration" target="_blank">Configuration</a></li>
193
+ <li><a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Beta-Version" target="_blank">Beta Version</a></li>
194
+ <li><a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Node-Version" target="_blank">Node Version</a></li>
195
+ </ul>
196
+ <h5>Features</h5>
197
+ <ul>
198
+ <li><a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Supported-Devices" target="_blank">Supported Devices</a></li>
199
+ </ul>
200
+ <h5>Help/About</h5>
201
+ <ul>
202
+ <li><a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Common-Errors" target="_blank">Common Errors</a></li>
203
+ <li><a href="https://github.com/homebridge-plugins/homebridge-wemo/issues/new/choose" target="_blank">Support Request</a></li>
204
+ <li><a href="https://github.com/homebridge-plugins/homebridge-wemo/blob/latest/CHANGELOG.md" target="_blank">Changelog</a></li>
205
+ <li><a href="https://github.com/sponsors/bwp91" target="_blank">About Me</a></li>
206
+ </ul>
207
+ <h5>Credits</h5>
208
+ <ul>
209
+ <li>To the creator of this plugin: <a href="https://github.com/rudders" target="_blank">@rudders</a>, and to <a href="https://github.com/devbobo" target="_blank">@devbobo</a> for his contributions.</li>
210
+ <li>To the creator of <a href="https://github.com/timonreinhard/wemo-client" target="_blank">wemo-client</a> (which is now contained within this plugin): <a href="https://github.com/timonreinhard" target="_blank">@timonreinhard</a>.</li>
211
+ <li>To <a href="http://www.hardill.me.uk/wordpress/tag/wemo/" target="_blank">Ben Hardill</a> for his research on Wemo devices.</li>
212
+ <li>To all users who have helped/tested to enable functionality for new devices.</li>
213
+ <li>To the creators/contributors of <a href="https://github.com/simont77/fakegato-history" target="_blank">Fakegato</a>: <a href="https://github.com/simont77" target="_blank">@simont77</a> and <a href="https://github.com/NorthernMan54" target="_blank">@NorthernMan54</a>.</li>
214
+ <li>To the creator of the awesome plugin header logo: <a href="https://www.instagram.com/keryan.me" target="_blank">Keryan Belahcene</a>.</li>
215
+ <li>To the creators/contributors of <a href="https://homebridge.io" target="_blank">Homebridge</a> who make this plugin possible.</li>
216
+ </ul>
217
+ <h5>Disclaimer</h5>
218
+ <ul>
219
+ <li>I am in no way affiliated with Belkin/Wemo and this plugin is a personal project that I maintain in my free time.</li>
220
+ <li>Use this plugin entirely at your own risk - please see licence for more information.</li>
221
+ </ul>
208
222
  </div>
209
223
  <script>
210
224
  ;(async () => {
211
225
  try {
212
226
  const currentConfig = await homebridge.getPluginConfig()
227
+
228
+ // ===== Device picker (add/remove/hide config entries from the My Devices tab) =====
229
+ // The control state is always computed from a fresh getPluginConfig() call,
230
+ // so staged-but-unsaved edits made in the Settings tab are respected
231
+ const deviceArrays = [
232
+ 'makerTypes',
233
+ 'wemoInsights',
234
+ 'wemoLights',
235
+ 'wemoLinks',
236
+ 'wemoMotions',
237
+ 'wemoOutlets',
238
+ 'wemoOthers',
239
+ ]
240
+
241
+ // Which config array a device belongs in, from its urn device type
242
+ // (mirrors the platform's own switch). The platform merges every array
243
+ // into one lookup by serial, so an unknown type is safe in wemoOthers.
244
+ const urnToArray = {
245
+ 'urn:Belkin:device:bridge:1': 'wemoLinks',
246
+ 'urn:Belkin:device:controllee:1': 'wemoOutlets',
247
+ 'urn:Belkin:device:dimmer:1': 'wemoLights',
248
+ 'urn:Belkin:device:insight:1': 'wemoInsights',
249
+ 'urn:Belkin:device:lightswitch:1': 'wemoOutlets',
250
+ 'urn:Belkin:device:Maker:1': 'makerTypes',
251
+ 'urn:Belkin:device:NetCamSensor:1': 'wemoMotions',
252
+ 'urn:Belkin:device:outdoor:1': 'wemoOutlets',
253
+ 'urn:Belkin:device:sensor:1': 'wemoMotions',
254
+ }
255
+ let pickerAccessories = []
256
+ let removeConfirmTimer
257
+
258
+ // The action buttons always show the settings-page arrow; the row text
259
+ // (and the button's aria-label) says what the arrow will do
260
+ const actionArrow = '<i aria-hidden="true" class="fas fa-arrow-right"></i>'
261
+
262
+ // Compare serial numbers ignoring case and separators, so an entry typed
263
+ // by hand in a different format still counts as the same device
264
+ const looseId = id => (id || '').toString().toUpperCase().replace(/[^A-Z0-9]+/g, '')
265
+
266
+ const getConfigBlocks = async () => {
267
+ const blocks = await homebridge.getPluginConfig()
268
+ if (!blocks.length) {
269
+ blocks.push({ name: 'Wemo' })
270
+ }
271
+ return blocks
272
+ }
273
+
274
+ const findInConfig = (config, serialNumber) => {
275
+ const target = looseId(serialNumber)
276
+ for (const key of deviceArrays) {
277
+ if (Array.isArray(config[key])) {
278
+ const index = config[key].findIndex(entry => entry && looseId(entry.serialNumber) === target)
279
+ if (index !== -1) {
280
+ return { key, index }
281
+ }
282
+ }
283
+ }
284
+ return null
285
+ }
286
+
287
+ const selectedAccessory = () => {
288
+ const serial = document.getElementById('deviceSelect').value
289
+ return pickerAccessories.find(x => x.context.serialNumber === serial)
290
+ }
291
+
292
+ const setHideControl = hidden => {
293
+ const btn = document.getElementById('hideDeviceBtn')
294
+ btn.dataset.hidden = hidden ? 'yes' : 'no'
295
+ btn.innerHTML = actionArrow
296
+ btn.setAttribute('aria-label', hidden ? 'Show this device in HomeKit' : 'Hide this device from HomeKit')
297
+ document.getElementById('hideDeviceTitle').innerHTML = hidden ? 'Show This Device' : 'Hide This Device'
298
+ document.getElementById('hideDeviceText').innerHTML = hidden
299
+ ? 'Show this device in HomeKit again. The config entry is kept.'
300
+ : 'Hide this device from HomeKit. This adds the device to the config if needed.'
301
+ }
302
+
303
+ const setConfigButton = inConfig => {
304
+ const btn = document.getElementById('deviceConfigBtn')
305
+ clearTimeout(removeConfirmTimer)
306
+ delete btn.dataset.confirm
307
+ btn.dataset.state = inConfig ? 'remove' : 'add'
308
+ btn.classList.remove('btn-danger')
309
+ btn.classList.add('btn-primary')
310
+ btn.innerHTML = actionArrow
311
+ btn.setAttribute('aria-label', inConfig ? 'Remove this device from the config' : 'Add this device to the config')
312
+ document.getElementById('deviceConfigTitle').innerHTML = inConfig ? 'Remove This Device' : 'Add This Device'
313
+ document.getElementById('deviceConfigText').innerHTML = inConfig
314
+ ? 'Remove this device from the plugin config.'
315
+ : 'Add this device to the plugin config.'
316
+ }
317
+
318
+ const addDeviceToConfig = (config, acc) => {
319
+ // Link bulbs carry their hub's serial as linkSerialNumber and belong
320
+ // in wemoLights; anything with an unknown type is safe in wemoOthers
321
+ const arrayKey = acc.context.linkSerialNumber
322
+ ? 'wemoLights'
323
+ : urnToArray[acc.context.deviceType] || 'wemoOthers'
324
+ if (!Array.isArray(config[arrayKey])) {
325
+ config[arrayKey] = []
326
+ }
327
+ // label is included so the entry is identifiable in the config editor
328
+ config[arrayKey].push({ label: acc.displayName, serialNumber: acc.context.serialNumber })
329
+ }
330
+
331
+ document.getElementById('deviceConfigBtn').addEventListener('click', async () => {
332
+ try {
333
+ const btn = document.getElementById('deviceConfigBtn')
334
+ const acc = selectedAccessory()
335
+ if (!acc) {
336
+ return
337
+ }
338
+ const blocks = await getConfigBlocks()
339
+ const config = blocks[0]
340
+ const found = findInConfig(config, acc.context.serialNumber)
341
+ if (btn.dataset.state === 'add') {
342
+ // The config may have changed since the button was drawn, so
343
+ // re-check and never add a duplicate - just correct the button
344
+ if (found) {
345
+ setConfigButton(true)
346
+ setHideControl(!!config[found.key][found.index].ignoreDevice)
347
+ homebridge.toast.info(acc.displayName + ' is already in the config.', 'Not Added')
348
+ return
349
+ }
350
+ addDeviceToConfig(config, acc)
351
+ await homebridge.updatePluginConfig(blocks)
352
+ setConfigButton(true)
353
+ setHideControl(false)
354
+ homebridge.toast.success(acc.displayName + ' added - press Save to apply.', 'Added To Config')
355
+ } else {
356
+ if (!found) {
357
+ setConfigButton(false)
358
+ setHideControl(false)
359
+ homebridge.toast.info(acc.displayName + ' is not in the config.', 'Not Removed')
360
+ return
361
+ }
362
+ const entry = config[found.key][found.index]
363
+ const extraKeys = Object.keys(entry).filter(k => !['serialNumber', 'label'].includes(k))
364
+ if (extraKeys.length > 0 && btn.dataset.confirm !== 'yes') {
365
+ // The entry has settings beyond serial and label which would be
366
+ // lost, so ask for a second click within five seconds
367
+ btn.dataset.confirm = 'yes'
368
+ btn.classList.remove('btn-primary')
369
+ btn.classList.add('btn-danger')
370
+ btn.innerHTML = actionArrow
371
+ btn.setAttribute('aria-label', 'Confirm removing this device from the config')
372
+ document.getElementById('deviceConfigText').innerHTML = 'This entry has extra settings which will be lost. Click again to remove it.'
373
+ removeConfirmTimer = setTimeout(() => setConfigButton(true), 5000)
374
+ return
375
+ }
376
+ config[found.key].splice(found.index, 1)
377
+ if (config[found.key].length === 0) {
378
+ delete config[found.key]
379
+ }
380
+ await homebridge.updatePluginConfig(blocks)
381
+ setConfigButton(false)
382
+ setHideControl(false)
383
+ homebridge.toast.success(acc.displayName + ' removed - press Save to apply.', 'Removed From Config')
384
+ }
385
+ } catch (err) {
386
+ homebridge.toast.error(err.message, 'Error')
387
+ }
388
+ })
389
+
390
+ document.getElementById('hideDeviceBtn').addEventListener('click', async () => {
391
+ try {
392
+ const acc = selectedAccessory()
393
+ if (!acc) {
394
+ return
395
+ }
396
+ const blocks = await getConfigBlocks()
397
+ const config = blocks[0]
398
+ let found = findInConfig(config, acc.context.serialNumber)
399
+ const currentlyHidden = document.getElementById('hideDeviceBtn').dataset.hidden === 'yes'
400
+ if (!currentlyHidden) {
401
+ // Hiding needs a config entry to carry the flag, so create one if
402
+ // the device is not in the config yet
403
+ if (!found) {
404
+ addDeviceToConfig(config, acc)
405
+ found = findInConfig(config, acc.context.serialNumber)
406
+ }
407
+ config[found.key][found.index].ignoreDevice = true
408
+ await homebridge.updatePluginConfig(blocks)
409
+ setConfigButton(true)
410
+ setHideControl(true)
411
+ homebridge.toast.success(acc.displayName + ' will be hidden from HomeKit - press Save to apply.', 'Device Hidden')
412
+ } else {
413
+ if (found) {
414
+ // Drop the flag rather than storing ignoreDevice false, to keep
415
+ // the entry clean
416
+ delete config[found.key][found.index].ignoreDevice
417
+ await homebridge.updatePluginConfig(blocks)
418
+ }
419
+ setConfigButton(!!found)
420
+ setHideControl(false)
421
+ homebridge.toast.success(acc.displayName + ' will be shown in HomeKit - press Save to apply.', 'Device Unhidden')
422
+ }
423
+ } catch (err) {
424
+ homebridge.toast.error(err.message, 'Error')
425
+ }
426
+ })
427
+
428
+ document.getElementById('addAllBtn').addEventListener('click', async () => {
429
+ try {
430
+ const blocks = await getConfigBlocks()
431
+ const config = blocks[0]
432
+ let added = 0
433
+ let skipped = 0
434
+ pickerAccessories.forEach(acc => {
435
+ if (!acc.context?.serialNumber) {
436
+ return
437
+ }
438
+ if (findInConfig(config, acc.context.serialNumber)) {
439
+ skipped += 1
440
+ return
441
+ }
442
+ addDeviceToConfig(config, acc)
443
+ added += 1
444
+ })
445
+ if (added > 0) {
446
+ await homebridge.updatePluginConfig(blocks)
447
+ homebridge.toast.success(added + ' device(s) added, ' + skipped + ' already in the config - press Save to apply.', 'Added To Config')
448
+ } else {
449
+ homebridge.toast.info('All devices are already in the config.', 'Nothing To Add')
450
+ }
451
+ const acc = selectedAccessory()
452
+ if (acc) {
453
+ const nowFound = findInConfig(config, acc.context.serialNumber)
454
+ setConfigButton(!!nowFound)
455
+ if (nowFound) {
456
+ setHideControl(!!config[nowFound.key][nowFound.index].ignoreDevice)
457
+ }
458
+ }
459
+ } catch (err) {
460
+ homebridge.toast.error(err.message, 'Error')
461
+ }
462
+ })
463
+ // ===== End device picker =====
464
+
213
465
  showIntro = () => {
214
466
  homebridge.disableSaveButton?.()
215
467
  const introContinue = document.getElementById('introContinue')
@@ -224,7 +476,9 @@
224
476
  }
225
477
  showDevices = async () => {
226
478
  homebridge.showSpinner()
227
- homebridge.disableSaveButton?.()
479
+ // The save button stays enabled here so entries staged by the picker
480
+ // buttons can be saved without switching back to the Settings tab
481
+ homebridge.enableSaveButton?.()
228
482
  homebridge.hideSchemaForm()
229
483
  document.getElementById('menuHome').classList.remove('btn-elegant')
230
484
  document.getElementById('menuHome').classList.add('btn-primary')
@@ -247,6 +501,7 @@
247
501
  : 0
248
502
  })
249
503
  }
504
+ pickerAccessories = cachedAccessories
250
505
  const deviceSelect = document.getElementById('deviceSelect')
251
506
  deviceSelect.innerHTML = ''
252
507
  cachedAccessories.forEach(a => {
@@ -290,6 +545,11 @@
290
545
  '" style="width: 150px;">'
291
546
  : ''
292
547
  document.getElementById('deviceTable').style.display = 'inline-table'
548
+ const configBlocks = await getConfigBlocks()
549
+ const configEntry = findInConfig(configBlocks[0], context.serialNumber)
550
+ setConfigButton(!!configEntry)
551
+ setHideControl(!!(configEntry && configBlocks[0][configEntry.key][configEntry.index].ignoreDevice))
552
+ document.getElementById('configActionList').style.display = 'block'
293
553
  homebridge.hideSpinner()
294
554
  }
295
555
  deviceSelect.addEventListener('change', event => showDeviceInfo(event.target.value))
@@ -300,6 +560,7 @@
300
560
  option.text = 'No Devices'
301
561
  deviceSelect.add(option)
302
562
  deviceSelect.disabled = true
563
+ document.getElementById('configActionList').style.display = 'none'
303
564
  }
304
565
  homebridge.hideSpinner()
305
566
  }
package/lib/platform.js CHANGED
@@ -794,6 +794,9 @@ export default class {
794
794
  const context = {
795
795
  connection: deviceConf.listenerType ? listenerType : disableUPNP,
796
796
  cbURL: device.cbURL,
797
+ // The urn device type lets the UI device picker place a device in the
798
+ // right config array
799
+ deviceType: device.deviceType,
797
800
  firmware: device.firmwareVersion,
798
801
  hidden: false,
799
802
  icon: device.iconList?.icon?.url || false,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@homebridge-plugins/homebridge-wemo",
3
3
  "alias": "Wemo",
4
4
  "type": "module",
5
- "version": "7.5.3",
5
+ "version": "7.6.0-beta.1",
6
6
  "description": "Homebridge plugin to integrate Wemo devices into HomeKit.",
7
7
  "author": {
8
8
  "name": "bwp91",