@homebridge-plugins/homebridge-wemo 7.0.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +809 -0
  2. package/LICENSE +21 -0
  3. package/README.md +66 -0
  4. package/config.schema.json +814 -0
  5. package/eslint.config.js +50 -0
  6. package/lib/connection/http.js +174 -0
  7. package/lib/connection/upnp.js +155 -0
  8. package/lib/device/coffee.js +167 -0
  9. package/lib/device/crockpot.js +380 -0
  10. package/lib/device/dimmer.js +280 -0
  11. package/lib/device/heater.js +416 -0
  12. package/lib/device/humidifier.js +379 -0
  13. package/lib/device/index.js +39 -0
  14. package/lib/device/insight.js +353 -0
  15. package/lib/device/lightswitch.js +154 -0
  16. package/lib/device/link-bulb.js +467 -0
  17. package/lib/device/link-hub.js +63 -0
  18. package/lib/device/maker-garage.js +426 -0
  19. package/lib/device/maker-switch.js +202 -0
  20. package/lib/device/motion.js +148 -0
  21. package/lib/device/outlet.js +148 -0
  22. package/lib/device/purifier.js +468 -0
  23. package/lib/device/simulation/purifier-insight.js +357 -0
  24. package/lib/device/simulation/purifier.js +159 -0
  25. package/lib/device/simulation/switch-insight.js +315 -0
  26. package/lib/device/simulation/switch.js +154 -0
  27. package/lib/fakegato/LICENSE +21 -0
  28. package/lib/fakegato/fakegato-history.js +814 -0
  29. package/lib/fakegato/fakegato-storage.js +108 -0
  30. package/lib/fakegato/fakegato-timer.js +125 -0
  31. package/lib/fakegato/uuid.js +27 -0
  32. package/lib/homebridge-ui/public/index.html +315 -0
  33. package/lib/homebridge-ui/server.js +10 -0
  34. package/lib/index.js +8 -0
  35. package/lib/platform.js +1423 -0
  36. package/lib/utils/colour.js +135 -0
  37. package/lib/utils/constants.js +129 -0
  38. package/lib/utils/eve-chars.js +130 -0
  39. package/lib/utils/functions.js +52 -0
  40. package/lib/utils/lang-en.js +125 -0
  41. package/package.json +70 -0
@@ -0,0 +1,108 @@
1
+ import fs from 'node:fs'
2
+ import os from 'node:os'
3
+ import path from 'node:path'
4
+
5
+ const hostname = os.hostname().split('.')[0]
6
+
7
+ export default class {
8
+ constructor(params) {
9
+ if (!params) {
10
+ params = {}
11
+ }
12
+ this.writers = []
13
+ this.log = params.log || {}
14
+ if (!this.log) {
15
+ this.log = () => {}
16
+ }
17
+ this.addingWriter = false
18
+ }
19
+
20
+ addWriter(service, params) {
21
+ if (!this.addingWriter) {
22
+ this.addingWriter = true
23
+ if (!params) {
24
+ params = {}
25
+ }
26
+ this.log('[%s] FGS addWriter().', service.accessoryName)
27
+ const newWriter = {
28
+ service,
29
+ callback: params.callback,
30
+ fileName: `${hostname}_${service.accessoryName}_persist.json`,
31
+ }
32
+ const onReady = typeof params.onReady === 'function' ? params.onReady : () => {}
33
+ newWriter.storageHandler = fs
34
+ newWriter.path = params.path || path.join(os.homedir(), '.homebridge')
35
+ this.writers.push(newWriter)
36
+ this.addingWriter = false
37
+ onReady()
38
+ } else {
39
+ setTimeout(() => this.addWriter(service, params), 100)
40
+ }
41
+ }
42
+
43
+ getWriter(service) {
44
+ return this.writers.find(ele => ele.service === service)
45
+ }
46
+
47
+ _getWriterIndex(service) {
48
+ return this.writers.findIndex(ele => ele.service === service)
49
+ }
50
+
51
+ getWriters() {
52
+ return this.writers
53
+ }
54
+
55
+ delWriter(service) {
56
+ const index = this._getWriterIndex(service)
57
+ this.writers.splice(index, 1)
58
+ }
59
+
60
+ write(params) {
61
+ if (!this.writing) {
62
+ this.writing = true
63
+ const writer = this.getWriter(params.service)
64
+ const callBack = typeof params.callback === 'function'
65
+ ? params.callback
66
+ : typeof writer.callback === 'function'
67
+ ? writer.callback
68
+ : () => {}
69
+ const fileLoc = path.join(writer.path, writer.fileName)
70
+ this.log(
71
+ '[%s] FGS write file [%s] [%s].',
72
+ params.service.accessoryName,
73
+ fileLoc,
74
+ params.data.substr(1, 80),
75
+ )
76
+ writer.storageHandler.writeFile(fileLoc, params.data, 'utf8', (...args) => {
77
+ this.writing = false
78
+ callBack(args)
79
+ })
80
+ } else {
81
+ setTimeout(() => this.write(params), 100)
82
+ }
83
+ }
84
+
85
+ read(params) {
86
+ const writer = this.getWriter(params.service)
87
+ const callBack = typeof params.callback === 'function'
88
+ ? params.callback
89
+ : typeof writer.callback === 'function'
90
+ ? writer.callback
91
+ : () => {}
92
+ const fileLoc = path.join(writer.path, writer.fileName)
93
+ this.log('[%s] FGS read file [%s].', params.service.accessoryName, fileLoc)
94
+ writer.storageHandler.readFile(fileLoc, 'utf8', callBack)
95
+ }
96
+
97
+ remove(params) {
98
+ const writer = this.getWriter(params.service)
99
+ const callBack = typeof params.callback === 'function'
100
+ ? params.callback
101
+ : typeof writer.callback === 'function'
102
+ ? writer.callback
103
+ : () => {}
104
+ const fileLoc = path.join(writer.path, writer.fileName)
105
+ this.log('[%s] FGS delete file [%s].', params.service.accessoryName, fileLoc)
106
+ writer.storageHandler.unlink(fileLoc, callBack)
107
+ }
108
+ }
@@ -0,0 +1,125 @@
1
+ export default class {
2
+ constructor(params) {
3
+ if (!params) {
4
+ params = {}
5
+ }
6
+ this.subscribedServices = []
7
+ this.minutes = params.minutes || 10
8
+ this.intervalID = null
9
+ this.running = false
10
+ this.log = params.log || {}
11
+ if (!this.log) {
12
+ this.log = () => {}
13
+ }
14
+ }
15
+
16
+ subscribe(service, callback) {
17
+ this.log('[%s] FGT new subscription.', service.accessoryName)
18
+ const newService = {
19
+ service,
20
+ callback,
21
+ backLog: [],
22
+ previousBackLog: [],
23
+ previousAvrg: {},
24
+ }
25
+ this.subscribedServices.push(newService)
26
+ }
27
+
28
+ getSubscriber(service) {
29
+ return this.subscribedServices.find(el => el.service === service)
30
+ }
31
+
32
+ _getSubscriberIndex(service) {
33
+ return this.subscribedServices.findIndex(el => el.service === service)
34
+ }
35
+
36
+ getSubscribers() {
37
+ return this.subscribedServices
38
+ }
39
+
40
+ unsubscribe(service) {
41
+ const index = this._getSubscriberIndex(service)
42
+ this.subscribedServices.splice(index, 1)
43
+ if (this.subscribedServices.length === 0 && this.running) {
44
+ this.stop()
45
+ }
46
+ }
47
+
48
+ start() {
49
+ this.log('Starting global FGT [%s minutes].', this.minutes)
50
+ if (this.running) {
51
+ this.stop()
52
+ }
53
+ this.running = true
54
+ this.intervalID = setInterval(this.executeCallbacks.bind(this), this.minutes * 60 * 1000)
55
+ }
56
+
57
+ stop() {
58
+ this.log('Stopping global FGT.')
59
+ clearInterval(this.intervalID)
60
+ this.running = false
61
+ this.intervalID = null
62
+ }
63
+
64
+ executeCallbacks() {
65
+ this.log('FGT executeCallbacks().')
66
+ if (this.subscribedServices.length !== 0) {
67
+ for (const s in this.subscribedServices) {
68
+ if (Object.prototype.hasOwnProperty.call(this.subscribedServices, s)) {
69
+ const service = this.subscribedServices[s]
70
+ if (typeof service.callback === 'function') {
71
+ service.previousAvrg = service.callback({
72
+ backLog: service.backLog,
73
+ previousAvrg: service.previousAvrg,
74
+ timer: this,
75
+ immediate: false,
76
+ })
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+
83
+ executeImmediateCallback(service) {
84
+ this.log('[%s] FGT executeImmediateCallback().', service.accessoryName)
85
+ if (typeof service.callback === 'function' && service.backLog.length) {
86
+ service.callback({
87
+ backLog: service.backLog,
88
+ timer: this,
89
+ immediate: true,
90
+ })
91
+ }
92
+ }
93
+
94
+ addData(params) {
95
+ const data = params.entry
96
+ const { service } = params
97
+ const immediateCallback = params.immediateCallback || false
98
+ this.log(
99
+ '[%s] FGT addData() [%s] immediate [%s].',
100
+ service.accessoryName,
101
+ data,
102
+ immediateCallback,
103
+ )
104
+ if (immediateCallback) {
105
+ this.getSubscriber(service).backLog[0] = data
106
+ } else {
107
+ this.getSubscriber(service).backLog.push(data)
108
+ }
109
+ if (immediateCallback) {
110
+ this.executeImmediateCallback(this.getSubscriber(service))
111
+ }
112
+ if (!this.running) {
113
+ this.start()
114
+ }
115
+ }
116
+
117
+ emptyData(service) {
118
+ this.log('[%s] FGT emptyData().', service.accessoryName)
119
+ const source = this.getSubscriber(service)
120
+ if (source.backLog.length) {
121
+ source.previousBackLog = source.backLog
122
+ }
123
+ source.backLog = []
124
+ }
125
+ }
@@ -0,0 +1,27 @@
1
+ // https://github.com/homebridge/HAP-NodeJS/blob/master/src/lib/util/uuid.ts
2
+
3
+ function isValid(UUID) {
4
+ const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
5
+ return uuidRegex.test(UUID)
6
+ }
7
+
8
+ function toLongFormUUID(uuid, base = '-0000-1000-8000-0026BB765291') {
9
+ const shortRegex = /^[0-9a-f]{1,8}$/i
10
+ if (isValid(uuid)) {
11
+ return uuid.toUpperCase()
12
+ }
13
+ if (!shortRegex.test(uuid)) {
14
+ throw new TypeError('uuid was not a valid UUID or short form UUID')
15
+ }
16
+ if (!isValid(`00000000${base}`)) {
17
+ throw new TypeError('base was not a valid base UUID')
18
+ }
19
+ return ((`00000000${uuid}`).substr(-8) + base).toUpperCase()
20
+ }
21
+
22
+ function toShortFormUUID(uuid, base = '-0000-1000-8000-0026BB765291') {
23
+ uuid = toLongFormUUID(uuid, base)
24
+ return uuid.substr(0, 8)
25
+ }
26
+
27
+ export { toLongFormUUID, toShortFormUUID }
@@ -0,0 +1,315 @@
1
+ <p class="text-center">
2
+ <img
3
+ src="https://user-images.githubusercontent.com/43026681/126868557-d0983348-d124-4247-bea9-7dcc62849cdf.png"
4
+ alt="homebridge-wemo logo"
5
+ style="width: 60%;"
6
+ />
7
+ </p>
8
+ <div id="pageIntro" class="text-center" style="display: none;">
9
+ <p class="lead">Thank you for installing <strong>homebridge-wemo</strong></p>
10
+ <p>Remember to click Save on the next page</p>
11
+ <button type="button" class="btn btn-primary" id="introContinue">Continue &rarr;</button>
12
+ </div>
13
+ <div
14
+ id="menuWrapper"
15
+ class="btn-group w-100 mb-0"
16
+ role="group"
17
+ aria-label="UI Menu"
18
+ style="display: none;"
19
+ >
20
+ <button type="button" class="btn btn-primary ml-0" id="menuSettings">Settings</button>
21
+ <button type="button" class="btn btn-primary" id="menuDevices">My Devices</button>
22
+ <button type="button" class="btn btn-primary mr-0" id="menuHome">Support</button>
23
+ </div>
24
+ <div id="pageDevices" class="mt-4" style="display: none;">
25
+ <div id="deviceInfo">
26
+ <form>
27
+ <div class="form-group">
28
+ <select class="form-control" id="deviceSelect"></select>
29
+ </div>
30
+ </form>
31
+ <table class="table w-100" id="deviceTable" style="display: none;">
32
+ <thead>
33
+ <tr class="table-active">
34
+ <th scope="col" style="width: 40%;">Device Name</th>
35
+ <th scope="col" style="width: 60%;" id="displayName"></th>
36
+ </tr>
37
+ </thead>
38
+ <tbody>
39
+ <tr>
40
+ <th scope="row">HTTP Status</th>
41
+ <td id="http_status"></td>
42
+ </tr>
43
+ <tr>
44
+ <th scope="row">UPnP Status</th>
45
+ <td id="upnp_status"></td>
46
+ </tr>
47
+ <tr>
48
+ <th scope="row">IP Address</th>
49
+ <td id="ipAddress"></td>
50
+ </tr>
51
+ <tr>
52
+ <th scope="row">Port</th>
53
+ <td id="port"></td>
54
+ </tr>
55
+ <tr>
56
+ <th scope="row">UPnP Info</th>
57
+ <td id="upnpInfo"></td>
58
+ </tr>
59
+ <tr>
60
+ <th scope="row">Serial Number</th>
61
+ <td id="serialNumber"></td>
62
+ </tr>
63
+ <tr>
64
+ <th scope="row">MAC Address</th>
65
+ <td id="macAddress"></td>
66
+ </tr>
67
+ <tr>
68
+ <th scope="row">Firmware</th>
69
+ <td id="firmware"></td>
70
+ </tr>
71
+ <tr>
72
+ <td colspan="2" style="text-align: center" id="imgIcon"></td>
73
+ </tr>
74
+ </tbody>
75
+ </table>
76
+ </div>
77
+ </div>
78
+ <div id="pageSupport" class="mt-4" style="display: none;">
79
+ <p class="text-center lead">Thank you for using <strong>homebridge-wemo</strong></p>
80
+ <p class="text-center">The links below will take you to our GitHub wiki</p>
81
+ <h4>Setup</h4>
82
+ <ul>
83
+ <li>
84
+ <a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Installation" target="_blank"
85
+ >Installation</a
86
+ >
87
+ </li>
88
+ <li>
89
+ <a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Configuration" target="_blank"
90
+ >Configuration</a
91
+ >
92
+ </li>
93
+ <li>
94
+ <a href="https://github.com/homebridge/homebridge/wiki/How-to-Install-Alternate-Plugin-Versions" target="_blank"
95
+ >Beta Version</a
96
+ >
97
+ </li>
98
+ <li>
99
+ <a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Node-Version" target="_blank"
100
+ >Node Version</a
101
+ >
102
+ </li>
103
+ </ul>
104
+ <h4>Features</h4>
105
+ <ul>
106
+ <li>
107
+ <a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Supported-Devices" target="_blank"
108
+ >Supported Devices</a
109
+ >
110
+ </li>
111
+ </ul>
112
+ <h4>Help/About</h4>
113
+ <ul>
114
+ <li>
115
+ <a href="https://github.com/homebridge-plugins/homebridge-wemo/wiki/Common-Errors" target="_blank"
116
+ >Common Errors</a
117
+ >
118
+ </li>
119
+ <li>
120
+ <a href="https://github.com/homebridge-plugins/homebridge-wemo/issues/new/choose" target="_blank"
121
+ >Support Request</a
122
+ >
123
+ </li>
124
+ <li>
125
+ <a href="https://github.com/homebridge-plugins/homebridge-wemo/blob/latest/CHANGELOG.md" target="_blank"
126
+ >Changelog</a
127
+ >
128
+ </li>
129
+ <li><a href="https://github.com/sponsors/bwp91" target="_blank">About Me</a></li>
130
+ </ul>
131
+ <h4>Credits</h4>
132
+ <ul>
133
+ <li>
134
+ To the creator of this plugin:
135
+ <a href="https://github.com/rudders" target="_blank">@rudders</a>, and to
136
+ <a href="https://github.com/devbobo" target="_blank">@devbobo</a> for his contributions.
137
+ </li>
138
+ <li>
139
+ To the creator of
140
+ <a href="https://github.com/timonreinhard/wemo-client" target="_blank">wemo-client</a> (which
141
+ is now contained within this plugin):
142
+ <a href="https://github.com/timonreinhard" target="_blank">@timonreinhard</a>.
143
+ </li>
144
+ <li>
145
+ To <a href="http://www.hardill.me.uk/wordpress/tag/wemo/" target="_blank">Ben Hardill</a> for
146
+ his research on Wemo devices.
147
+ </li>
148
+ <li>To all users who have helped/tested to enable functionality for new devices.</li>
149
+ <li>
150
+ To the creators/contributors of
151
+ <a href="https://github.com/simont77/fakegato-history" target="_blank">Fakegato</a>:
152
+ <a href="https://github.com/simont77" target="_blank">@simont77</a> and
153
+ <a href="https://github.com/NorthernMan54" target="_blank">@NorthernMan54</a>.
154
+ </li>
155
+ <li>
156
+ To the creator of the awesome plugin header logo:
157
+ <a href="https://www.instagram.com/keryan.me" target="_blank">Keryan Belahcene</a>.
158
+ </li>
159
+ <li>
160
+ To the creators/contributors of
161
+ <a href="https://homebridge.io" target="_blank">Homebridge</a> who make this plugin possible.
162
+ </li>
163
+ </ul>
164
+ <h4>Disclaimer</h4>
165
+ <ul>
166
+ <li>
167
+ I am in no way affiliated with Belkin/Wemo and this plugin is a personal project that I
168
+ maintain in my free time.
169
+ </li>
170
+ <li>Use this plugin entirely at your own risk - please see licence for more information.</li>
171
+ </ul>
172
+ </div>
173
+ <script>
174
+ ;(async () => {
175
+ try {
176
+ const currentConfig = await homebridge.getPluginConfig()
177
+ showIntro = () => {
178
+ const introContinue = document.getElementById('introContinue')
179
+ introContinue.addEventListener('click', () => {
180
+ homebridge.showSpinner()
181
+ homebridge.disableSaveButton?.()
182
+ document.getElementById('pageIntro').style.display = 'none'
183
+ document.getElementById('menuWrapper').style.display = 'inline-flex'
184
+ showSettings()
185
+ homebridge.hideSpinner()
186
+ })
187
+ document.getElementById('pageIntro').style.display = 'block'
188
+ }
189
+ showDevices = async () => {
190
+ homebridge.showSpinner()
191
+ homebridge.disableSaveButton?.()
192
+ homebridge.hideSchemaForm()
193
+ document.getElementById('menuHome').classList.remove('btn-elegant')
194
+ document.getElementById('menuHome').classList.add('btn-primary')
195
+ document.getElementById('menuDevices').classList.add('btn-elegant')
196
+ document.getElementById('menuDevices').classList.remove('btn-primary')
197
+ document.getElementById('menuSettings').classList.remove('btn-elegant')
198
+ document.getElementById('menuSettings').classList.add('btn-primary')
199
+ document.getElementById('pageSupport').style.display = 'none'
200
+ document.getElementById('pageDevices').style.display = 'block'
201
+ const cachedAccessories =
202
+ typeof homebridge.getCachedAccessories === 'function'
203
+ ? await homebridge.getCachedAccessories()
204
+ : await homebridge.request('/getCachedAccessories')
205
+ if (cachedAccessories.length > 0) {
206
+ cachedAccessories.sort((a, b) => {
207
+ return a.displayName.toLowerCase() > b.displayName.toLowerCase()
208
+ ? 1
209
+ : b.displayName.toLowerCase() > a.displayName.toLowerCase()
210
+ ? -1
211
+ : 0
212
+ })
213
+ }
214
+ const deviceSelect = document.getElementById('deviceSelect')
215
+ deviceSelect.innerHTML = ''
216
+ cachedAccessories.forEach(a => {
217
+ const option = document.createElement('option')
218
+ option.text = a.displayName
219
+ option.value = a.context.serialNumber
220
+ deviceSelect.add(option)
221
+ })
222
+ showDeviceInfo = async serialNumber => {
223
+ homebridge.showSpinner()
224
+ const thisAcc = cachedAccessories.find(x => x.context.serialNumber === serialNumber)
225
+ const context = thisAcc.context
226
+ document.getElementById('displayName').innerHTML = thisAcc.displayName
227
+ document.getElementById('http_status').innerHTML = context.httpOnline
228
+ ? '<i class="fas fa-circle mr-1 green-text"></i> Yes'
229
+ : '<i class="fas fa-circle mr-1 red-text"></i> No'
230
+ document.getElementById('upnp_status').innerHTML = context.upnpOnline
231
+ ? '<i class="fas fa-circle mr-1 green-text"></i> Yes'
232
+ : '<i class="fas fa-circle mr-1 red-text"></i> No'
233
+ document.getElementById('ipAddress').innerHTML = context.ipAddress || 'N/A'
234
+ document.getElementById('port').innerHTML = context.port || 'N/A'
235
+ document.getElementById('upnpInfo').innerHTML =
236
+ context.ipAddress && context.port
237
+ ? '<a href="http://' +
238
+ context.ipAddress +
239
+ ':' +
240
+ context.port +
241
+ '/setup.xml" target="_blank" class="primary-text">Visit XML &rarr;</a>'
242
+ : 'N/A'
243
+ document.getElementById('serialNumber').innerHTML = context.serialNumber || 'N/A'
244
+ document.getElementById('macAddress').innerHTML = context.macAddress || 'N/A'
245
+ document.getElementById('firmware').innerHTML = context.firmware || 'N/A'
246
+ document.getElementById('imgIcon').innerHTML =
247
+ context.icon && context.ipAddress && context.port
248
+ ? '<img src="http://' +
249
+ context.ipAddress +
250
+ ':' +
251
+ context.port +
252
+ '/' +
253
+ context.icon +
254
+ '" style="width: 150px;">'
255
+ : ''
256
+ document.getElementById('deviceTable').style.display = 'inline-table'
257
+ homebridge.hideSpinner()
258
+ }
259
+ deviceSelect.addEventListener('change', event => showDeviceInfo(event.target.value))
260
+ if (cachedAccessories.length > 0) {
261
+ showDeviceInfo(cachedAccessories[0].context.serialNumber)
262
+ } else {
263
+ const option = document.createElement('option')
264
+ option.text = 'No Devices'
265
+ deviceSelect.add(option)
266
+ deviceSelect.disabled = true
267
+ }
268
+ homebridge.hideSpinner()
269
+ }
270
+ showSupport = () => {
271
+ homebridge.showSpinner()
272
+ homebridge.disableSaveButton?.()
273
+ homebridge.hideSchemaForm()
274
+ document.getElementById('menuHome').classList.add('btn-elegant')
275
+ document.getElementById('menuHome').classList.remove('btn-primary')
276
+ document.getElementById('menuDevices').classList.remove('btn-elegant')
277
+ document.getElementById('menuDevices').classList.add('btn-primary')
278
+ document.getElementById('menuSettings').classList.remove('btn-elegant')
279
+ document.getElementById('menuSettings').classList.add('btn-primary')
280
+ document.getElementById('pageSupport').style.display = 'block'
281
+ document.getElementById('pageDevices').style.display = 'none'
282
+ homebridge.hideSpinner()
283
+ }
284
+ showSettings = () => {
285
+ homebridge.showSpinner()
286
+ homebridge.enableSaveButton?.()
287
+ document.getElementById('menuHome').classList.remove('btn-elegant')
288
+ document.getElementById('menuHome').classList.add('btn-primary')
289
+ document.getElementById('menuDevices').classList.remove('btn-elegant')
290
+ document.getElementById('menuDevices').classList.add('btn-primary')
291
+ document.getElementById('menuSettings').classList.add('btn-elegant')
292
+ document.getElementById('menuSettings').classList.remove('btn-primary')
293
+ document.getElementById('pageSupport').style.display = 'none'
294
+ document.getElementById('pageDevices').style.display = 'none'
295
+ homebridge.showSchemaForm()
296
+ homebridge.hideSpinner()
297
+ }
298
+ menuHome.addEventListener('click', () => showSupport())
299
+ menuDevices.addEventListener('click', () => showDevices())
300
+ menuSettings.addEventListener('click', () => showSettings())
301
+ if (currentConfig.length) {
302
+ document.getElementById('menuWrapper').style.display = 'inline-flex'
303
+ showSettings()
304
+ } else {
305
+ currentConfig.push({ name: 'Wemo' })
306
+ await homebridge.updatePluginConfig(currentConfig)
307
+ showIntro()
308
+ }
309
+ } catch (err) {
310
+ homebridge.toast.error(err.message, 'Error')
311
+ } finally {
312
+ homebridge.hideSpinner()
313
+ }
314
+ })()
315
+ </script>
@@ -0,0 +1,10 @@
1
+ import { HomebridgePluginUiServer } from '@homebridge/plugin-ui-utils'
2
+
3
+ class PluginUiServer extends HomebridgePluginUiServer {
4
+ constructor() {
5
+ super()
6
+ this.ready()
7
+ }
8
+ }
9
+
10
+ (() => new PluginUiServer())()
package/lib/index.js ADDED
@@ -0,0 +1,8 @@
1
+ import { createRequire } from 'node:module'
2
+
3
+ import wemoPlatform from './platform.js'
4
+
5
+ const require = createRequire(import.meta.url)
6
+ const plugin = require('../package.json')
7
+
8
+ export default hb => hb.registerPlatform(plugin.alias, wemoPlatform)