homebridge-cmd4 6.0.0 → 6.0.4
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 +30 -0
- package/Cmd4Accessory.js +115 -143
- package/Cmd4Platform.js +19 -0
- package/RUNNING_CHANGELOG.md +36 -0
- package/docs/Developers.md +1 -1
- package/package.json +2 -2
- package/homebridge-ui/public/index.html.1 +0 -248
- package/homebridge-ui/public/index.html.2 +0 -257
- package/homebridge-ui/public/index.html.3 +0 -265
- package/homebridge-ui/public/index.html.3.1 +0 -244
- package/homebridge-ui/public/index.html.wemo.1 +0 -194
- package/homebridge-ui/public/index.html.wemo.2 +0 -339
- package/homebridge-ui/public/js/main.js.1 +0 -583
- package/homebridge-ui/public/js/main.js.2 +0 -583
- package/homebridge-ui/public/js/main.js.3 +0 -583
- package/homebridge-ui/public/js/schema.js.save +0 -196
- package/homebridge-ui/public/js/wmain.js.1 +0 -152
- package/homebridge-ui/public/js/wmain.js.2 +0 -161
- package/homebridge-ui/server.js.1 +0 -281
- package/homebridge-ui/server.js.2 +0 -281
- package/homebridge-ui/server.js.3 +0 -281
- package/homebridge-ui/server.js.wemo.1 +0 -78
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "schema" }]*/
|
|
2
|
-
|
|
3
|
-
const schema =
|
|
4
|
-
{
|
|
5
|
-
'schema':
|
|
6
|
-
{
|
|
7
|
-
'name':
|
|
8
|
-
{
|
|
9
|
-
'title': 'Name',
|
|
10
|
-
'type': 'string',
|
|
11
|
-
'default': 'MercedesPlatform',
|
|
12
|
-
'description': 'Name for the log.'
|
|
13
|
-
},
|
|
14
|
-
'debug':
|
|
15
|
-
{
|
|
16
|
-
'title': 'Debug',
|
|
17
|
-
'type': 'boolean',
|
|
18
|
-
'description': 'Enables additional output in the log.'
|
|
19
|
-
},
|
|
20
|
-
'accessories':
|
|
21
|
-
{
|
|
22
|
-
'type': 'object',
|
|
23
|
-
'properties':
|
|
24
|
-
{
|
|
25
|
-
'name':
|
|
26
|
-
{
|
|
27
|
-
'title': 'Accessory Name',
|
|
28
|
-
'description': 'The name of your accessory in HomeKit',
|
|
29
|
-
'type': 'string',
|
|
30
|
-
'required': true
|
|
31
|
-
},
|
|
32
|
-
'accessoryCharacteristics':
|
|
33
|
-
{
|
|
34
|
-
'title': 'Accessory Characteristics',
|
|
35
|
-
'description': 'The characteristics for the accessorys typen',
|
|
36
|
-
'type': 'string',
|
|
37
|
-
'required': true
|
|
38
|
-
},
|
|
39
|
-
'polling':
|
|
40
|
-
{
|
|
41
|
-
'title': 'Accessory Polling',
|
|
42
|
-
'description': 'Polling of a characteristics state',
|
|
43
|
-
'type': 'string',
|
|
44
|
-
'required': true
|
|
45
|
-
},
|
|
46
|
-
'electricVehicle':
|
|
47
|
-
{
|
|
48
|
-
'title': 'Electric Vehicle',
|
|
49
|
-
'type': 'boolean',
|
|
50
|
-
'description': 'Check if your accessory is an electric vehicle.'
|
|
51
|
-
},
|
|
52
|
-
'hybridVehicle':
|
|
53
|
-
{
|
|
54
|
-
'title': 'Hybrid Vehicle',
|
|
55
|
-
'type': 'boolean',
|
|
56
|
-
'description': 'Check if your accessory is a hybrid vehicle.'
|
|
57
|
-
},
|
|
58
|
-
'tankBatteryType':
|
|
59
|
-
{
|
|
60
|
-
'title': 'Tank load/Battery Accessory Type',
|
|
61
|
-
'type': 'string',
|
|
62
|
-
'description': 'You can choose between several accessory types for your tank load and/or electric vehicle battery. If \'none\' is choosen, only the tank load (for non electric vehicle) or battery level (electric vehicle) will be shown as a battery service within the accessory.',
|
|
63
|
-
'oneOf': [
|
|
64
|
-
{
|
|
65
|
-
'title': 'Humidity Sensor',
|
|
66
|
-
'enum': [
|
|
67
|
-
'HUMIDITY'
|
|
68
|
-
]
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
'title': 'Lighhtbulb',
|
|
72
|
-
'enum': [
|
|
73
|
-
'LIGHTBULB'
|
|
74
|
-
]
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
},
|
|
78
|
-
'manufacturer':
|
|
79
|
-
{
|
|
80
|
-
'name': 'Manufacturer',
|
|
81
|
-
'type': 'string',
|
|
82
|
-
'description': 'Set the manufacturer name for display in the Home app.'
|
|
83
|
-
},
|
|
84
|
-
'model':
|
|
85
|
-
{
|
|
86
|
-
'title': 'Model',
|
|
87
|
-
'description': 'Accessory model',
|
|
88
|
-
'type': 'string',
|
|
89
|
-
'required': false
|
|
90
|
-
},
|
|
91
|
-
'maxRange':
|
|
92
|
-
{
|
|
93
|
-
'title': 'Max Range',
|
|
94
|
-
'description': 'Maximum distance after full tank load',
|
|
95
|
-
'type': 'integer',
|
|
96
|
-
'required': false
|
|
97
|
-
},
|
|
98
|
-
'polling':
|
|
99
|
-
{
|
|
100
|
-
'title': 'Polling',
|
|
101
|
-
'description': 'Mercedes Me API Polling in seconds',
|
|
102
|
-
'type': 'boolean',
|
|
103
|
-
'required': false,
|
|
104
|
-
'placeholder': false,
|
|
105
|
-
},
|
|
106
|
-
'token':
|
|
107
|
-
{
|
|
108
|
-
'titel': 'Token',
|
|
109
|
-
'type': 'object',
|
|
110
|
-
'properties':
|
|
111
|
-
{
|
|
112
|
-
'access_token':
|
|
113
|
-
{
|
|
114
|
-
'title': 'Access Token',
|
|
115
|
-
'type': 'string',
|
|
116
|
-
'required': true
|
|
117
|
-
},
|
|
118
|
-
'refresh_token':
|
|
119
|
-
{
|
|
120
|
-
'title': 'Refresh Token',
|
|
121
|
-
'type': 'string',
|
|
122
|
-
'required': true
|
|
123
|
-
},
|
|
124
|
-
'token_type':
|
|
125
|
-
{
|
|
126
|
-
'title': 'Token Type',
|
|
127
|
-
'type': 'string',
|
|
128
|
-
'required': true
|
|
129
|
-
},
|
|
130
|
-
'expires_in':
|
|
131
|
-
{
|
|
132
|
-
'title': 'Expires In',
|
|
133
|
-
'type': 'integer',
|
|
134
|
-
'required': true
|
|
135
|
-
},
|
|
136
|
-
'expires_at':
|
|
137
|
-
{
|
|
138
|
-
'title': 'Expires at',
|
|
139
|
-
'type': 'string',
|
|
140
|
-
'required': true
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
'layout': [
|
|
148
|
-
'name',
|
|
149
|
-
'debug',
|
|
150
|
-
'accessories.name',
|
|
151
|
-
'accessories.accessoryCharacteristics',
|
|
152
|
-
'accessories.polling',
|
|
153
|
-
'accessories.electricVehicle',
|
|
154
|
-
'accessories.hybridVehicle',
|
|
155
|
-
'accessories.tankBatteryType',
|
|
156
|
-
{
|
|
157
|
-
'key': 'accessories',
|
|
158
|
-
'type': 'section',
|
|
159
|
-
'title': 'Branding',
|
|
160
|
-
'expandable': true,
|
|
161
|
-
'expanded': false,
|
|
162
|
-
'orderable': false,
|
|
163
|
-
'items': [
|
|
164
|
-
'accessories.manufacturer',
|
|
165
|
-
'accessories.model'
|
|
166
|
-
]
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
'key': 'accessories',
|
|
170
|
-
'type': 'section',
|
|
171
|
-
'title': 'Extras',
|
|
172
|
-
'expandable': true,
|
|
173
|
-
'expanded': false,
|
|
174
|
-
'orderable': false,
|
|
175
|
-
'items': [
|
|
176
|
-
'accessories.maxRange',
|
|
177
|
-
'accessories.polling'
|
|
178
|
-
]
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
'key': 'accessories.token',
|
|
182
|
-
'type': 'section',
|
|
183
|
-
'title': 'Authorization',
|
|
184
|
-
'expandable': true,
|
|
185
|
-
'expanded': false,
|
|
186
|
-
'orderable': false,
|
|
187
|
-
'items': [
|
|
188
|
-
'accessories.token.access_token',
|
|
189
|
-
'accessories.token.refresh_token',
|
|
190
|
-
'accessories.token.token_type',
|
|
191
|
-
'accessories.token.expires_in',
|
|
192
|
-
'accessories.token.expires_at'
|
|
193
|
-
]
|
|
194
|
-
}
|
|
195
|
-
]
|
|
196
|
-
};
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
;(async () => {
|
|
2
|
-
try {
|
|
3
|
-
const currentConfig = await homebridge.getPluginConfig()
|
|
4
|
-
showIntro = () => {
|
|
5
|
-
const introContinue = document.getElementById('introContinue')
|
|
6
|
-
introContinue.addEventListener('click', () => {
|
|
7
|
-
homebridge.showSpinner()
|
|
8
|
-
document.getElementById('pageIntro').style.display = 'none'
|
|
9
|
-
document.getElementById('menuWrapper').style.display = 'inline-flex'
|
|
10
|
-
showSettings()
|
|
11
|
-
homebridge.hideSpinner()
|
|
12
|
-
})
|
|
13
|
-
document.getElementById('pageIntro').style.display = 'block'
|
|
14
|
-
}
|
|
15
|
-
showDevices = async () => {
|
|
16
|
-
homebridge.showSpinner()
|
|
17
|
-
homebridge.hideSchemaForm()
|
|
18
|
-
document.getElementById('menuHome').classList.remove('btn-elegant')
|
|
19
|
-
document.getElementById('menuHome').classList.add('btn-primary')
|
|
20
|
-
document.getElementById('menuDevices').classList.add('btn-elegant')
|
|
21
|
-
document.getElementById('menuDevices').classList.remove('btn-primary')
|
|
22
|
-
document.getElementById('menuSettings').classList.remove('btn-elegant')
|
|
23
|
-
document.getElementById('menuSettings').classList.add('btn-primary')
|
|
24
|
-
document.getElementById('pageSupport').style.display = 'none'
|
|
25
|
-
document.getElementById('pageDevices').style.display = 'block'
|
|
26
|
-
const cachedAccessories =
|
|
27
|
-
typeof homebridge.getCachedAccessories === 'function'
|
|
28
|
-
? await homebridge.getCachedAccessories()
|
|
29
|
-
: await homebridge.request('/getCachedAccessories')
|
|
30
|
-
if (cachedAccessories.length > 0) {
|
|
31
|
-
cachedAccessories.sort((a, b) => {
|
|
32
|
-
return a.displayName.toLowerCase() > b.displayName.toLowerCase()
|
|
33
|
-
? 1
|
|
34
|
-
: b.displayName.toLowerCase() > a.displayName.toLowerCase()
|
|
35
|
-
? -1
|
|
36
|
-
: 0
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
const deviceSelect = document.getElementById('deviceSelect')
|
|
40
|
-
deviceSelect.innerHTML = ''
|
|
41
|
-
cachedAccessories.forEach(a => {
|
|
42
|
-
const option = document.createElement('option')
|
|
43
|
-
option.text = a.displayName
|
|
44
|
-
option.value = a.context.serialNumber
|
|
45
|
-
deviceSelect.add(option)
|
|
46
|
-
})
|
|
47
|
-
showDeviceInfo = async serialNumber => {
|
|
48
|
-
homebridge.showSpinner()
|
|
49
|
-
const thisAcc = cachedAccessories.find(x => x.context.serialNumber === serialNumber)
|
|
50
|
-
const context = thisAcc.context
|
|
51
|
-
document.getElementById('displayName').innerHTML = thisAcc.displayName
|
|
52
|
-
document.getElementById('http_status').innerHTML = context.httpOnline
|
|
53
|
-
? '<i class="fas fa-circle mr-1 green-text"></i> Yes'
|
|
54
|
-
: '<i class="fas fa-circle mr-1 red-text"></i> No'
|
|
55
|
-
document.getElementById('upnp_status').innerHTML = context.upnpOnline
|
|
56
|
-
? '<i class="fas fa-circle mr-1 green-text"></i> Yes'
|
|
57
|
-
: '<i class="fas fa-circle mr-1 red-text"></i> No'
|
|
58
|
-
document.getElementById('ipAddress').innerHTML = context.ipAddress || 'N/A'
|
|
59
|
-
document.getElementById('port').innerHTML = context.port || 'N/A'
|
|
60
|
-
document.getElementById('upnpInfo').innerHTML =
|
|
61
|
-
context.ipAddress && context.port
|
|
62
|
-
? '<a href="http://' +
|
|
63
|
-
context.ipAddress +
|
|
64
|
-
':' +
|
|
65
|
-
context.port +
|
|
66
|
-
'/setup.xml" target="_blank" class="primary-text">Visit XML →</a>'
|
|
67
|
-
: 'N/A'
|
|
68
|
-
document.getElementById('serialNumber').innerHTML = context.serialNumber || 'N/A'
|
|
69
|
-
document.getElementById('macAddress').innerHTML = context.macAddress || 'N/A'
|
|
70
|
-
document.getElementById('firmware').innerHTML = context.firmware || 'N/A'
|
|
71
|
-
document.getElementById('imgIcon').innerHTML =
|
|
72
|
-
context.icon && context.ipAddress && context.port
|
|
73
|
-
? '<img src="http://' +
|
|
74
|
-
context.ipAddress +
|
|
75
|
-
':' +
|
|
76
|
-
context.port +
|
|
77
|
-
'/' +
|
|
78
|
-
context.icon +
|
|
79
|
-
'" style="width: 150px;">'
|
|
80
|
-
: ''
|
|
81
|
-
document.getElementById('deviceTable').style.display = 'inline-table'
|
|
82
|
-
homebridge.hideSpinner()
|
|
83
|
-
}
|
|
84
|
-
deviceSelect.addEventListener('change', event => showDeviceInfo(event.target.value))
|
|
85
|
-
if (cachedAccessories.length > 0) {
|
|
86
|
-
showDeviceInfo(cachedAccessories[0].context.serialNumber)
|
|
87
|
-
} else {
|
|
88
|
-
const option = document.createElement('option')
|
|
89
|
-
option.text = 'No Devices'
|
|
90
|
-
deviceSelect.add(option)
|
|
91
|
-
deviceSelect.disabled = true
|
|
92
|
-
}
|
|
93
|
-
homebridge.hideSpinner()
|
|
94
|
-
}
|
|
95
|
-
showSupport = () => {
|
|
96
|
-
homebridge.showSpinner()
|
|
97
|
-
homebridge.hideSchemaForm()
|
|
98
|
-
document.getElementById('menuHome').classList.add('btn-elegant')
|
|
99
|
-
document.getElementById('menuHome').classList.remove('btn-primary')
|
|
100
|
-
document.getElementById('menuDevices').classList.remove('btn-elegant')
|
|
101
|
-
document.getElementById('menuDevices').classList.add('btn-primary')
|
|
102
|
-
document.getElementById('menuSettings').classList.remove('btn-elegant')
|
|
103
|
-
document.getElementById('menuSettings').classList.add('btn-primary')
|
|
104
|
-
document.getElementById('pageSupport').style.display = 'block'
|
|
105
|
-
document.getElementById('pageDevices').style.display = 'none'
|
|
106
|
-
homebridge.hideSpinner()
|
|
107
|
-
}
|
|
108
|
-
showSettings = () => {
|
|
109
|
-
homebridge.showSpinner()
|
|
110
|
-
document.getElementById('menuHome').classList.remove('btn-elegant')
|
|
111
|
-
document.getElementById('menuHome').classList.add('btn-primary')
|
|
112
|
-
document.getElementById('menuDevices').classList.remove('btn-elegant')
|
|
113
|
-
document.getElementById('menuDevices').classList.add('btn-primary')
|
|
114
|
-
document.getElementById('menuSettings').classList.add('btn-elegant')
|
|
115
|
-
document.getElementById('menuSettings').classList.remove('btn-primary')
|
|
116
|
-
document.getElementById('pageSupport').style.display = 'none'
|
|
117
|
-
document.getElementById('pageDevices').style.display = 'none'
|
|
118
|
-
homebridge.showSchemaForm()
|
|
119
|
-
homebridge.hideSpinner()
|
|
120
|
-
}
|
|
121
|
-
showDisabledBanner = () => {
|
|
122
|
-
document.getElementById('disabledBanner').style.display = 'block'
|
|
123
|
-
}
|
|
124
|
-
enablePlugin = async () => {
|
|
125
|
-
homebridge.showSpinner()
|
|
126
|
-
document.getElementById('disabledBanner').style.display = 'none'
|
|
127
|
-
currentConfig[0].disablePlugin = false
|
|
128
|
-
await homebridge.updatePluginConfig(currentConfig)
|
|
129
|
-
await homebridge.savePluginConfig()
|
|
130
|
-
homebridge.hideSpinner()
|
|
131
|
-
}
|
|
132
|
-
menuHome.addEventListener('click', () => showSupport())
|
|
133
|
-
menuDevices.addEventListener('click', () => showDevices())
|
|
134
|
-
menuSettings.addEventListener('click', () => showSettings())
|
|
135
|
-
disabledEnable.addEventListener('click', () => enablePlugin())
|
|
136
|
-
if (currentConfig.length) {
|
|
137
|
-
document.getElementById('menuWrapper').style.display = 'inline-flex'
|
|
138
|
-
showSettings()
|
|
139
|
-
if (currentConfig[0].disablePlugin) {
|
|
140
|
-
showDisabledBanner()
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
currentConfig.push({ name: 'Cmd4' })
|
|
144
|
-
await homebridge.updatePluginConfig(currentConfig)
|
|
145
|
-
showIntro()
|
|
146
|
-
}
|
|
147
|
-
} catch (err) {
|
|
148
|
-
homebridge.toast.error(err.message, 'Error')
|
|
149
|
-
} finally {
|
|
150
|
-
homebridge.hideSpinner()
|
|
151
|
-
}
|
|
152
|
-
})()
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
;(async () => {
|
|
2
|
-
try {
|
|
3
|
-
const currentConfig = await homebridge.getPluginConfig()
|
|
4
|
-
|
|
5
|
-
function showIntro( )
|
|
6
|
-
{
|
|
7
|
-
const introContinue = document.getElementById('introContinue')
|
|
8
|
-
introContinue.addEventListener('click', () => {
|
|
9
|
-
homebridge.showSpinner()
|
|
10
|
-
document.getElementById('pageIntro').style.display = 'none'
|
|
11
|
-
document.getElementById('menuWrapper').style.display = 'inline-flex'
|
|
12
|
-
showSettings()
|
|
13
|
-
homebridge.hideSpinner()
|
|
14
|
-
})
|
|
15
|
-
document.getElementById('pageIntro').style.display = 'block'
|
|
16
|
-
}
|
|
17
|
-
async function showDevices( )
|
|
18
|
-
{
|
|
19
|
-
homebridge.showSpinner()
|
|
20
|
-
homebridge.hideSchemaForm()
|
|
21
|
-
document.getElementById('menuHome').classList.remove('btn-elegant')
|
|
22
|
-
document.getElementById('menuHome').classList.add('btn-primary')
|
|
23
|
-
document.getElementById('menuDevices').classList.add('btn-elegant')
|
|
24
|
-
document.getElementById('menuDevices').classList.remove('btn-primary')
|
|
25
|
-
document.getElementById('menuSettings').classList.remove('btn-elegant')
|
|
26
|
-
document.getElementById('menuSettings').classList.add('btn-primary')
|
|
27
|
-
document.getElementById('pageSupport').style.display = 'none'
|
|
28
|
-
document.getElementById('pageDevices').style.display = 'block'
|
|
29
|
-
const cachedAccessories =
|
|
30
|
-
typeof homebridge.getCachedAccessories === 'function'
|
|
31
|
-
? await homebridge.getCachedAccessories()
|
|
32
|
-
: await homebridge.request('/getCachedAccessories')
|
|
33
|
-
if (cachedAccessories.length > 0) {
|
|
34
|
-
cachedAccessories.sort((a, b) => {
|
|
35
|
-
return a.displayName.toLowerCase() > b.displayName.toLowerCase()
|
|
36
|
-
? 1
|
|
37
|
-
: b.displayName.toLowerCase() > a.displayName.toLowerCase()
|
|
38
|
-
? -1
|
|
39
|
-
: 0
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
const deviceSelect = document.getElementById('deviceSelect')
|
|
43
|
-
deviceSelect.innerHTML = ''
|
|
44
|
-
cachedAccessories.forEach(a => {
|
|
45
|
-
const option = document.createElement('option')
|
|
46
|
-
option.text = a.displayName
|
|
47
|
-
option.value = a.context.serialNumber
|
|
48
|
-
deviceSelect.add(option)
|
|
49
|
-
})
|
|
50
|
-
//showDeviceInfo = async serialNumber => {
|
|
51
|
-
async function showDeviceInfo( serialNumer )
|
|
52
|
-
{
|
|
53
|
-
homebridge.showSpinner()
|
|
54
|
-
const thisAcc = cachedAccessories.find(x => x.context.serialNumber === serialNumber)
|
|
55
|
-
const context = thisAcc.context
|
|
56
|
-
document.getElementById('displayName').innerHTML = thisAcc.displayName
|
|
57
|
-
document.getElementById('http_status').innerHTML = context.httpOnline
|
|
58
|
-
? '<i class="fas fa-circle mr-1 green-text"></i> Yes'
|
|
59
|
-
: '<i class="fas fa-circle mr-1 red-text"></i> No'
|
|
60
|
-
document.getElementById('upnp_status').innerHTML = context.upnpOnline
|
|
61
|
-
? '<i class="fas fa-circle mr-1 green-text"></i> Yes'
|
|
62
|
-
: '<i class="fas fa-circle mr-1 red-text"></i> No'
|
|
63
|
-
document.getElementById('ipAddress').innerHTML = context.ipAddress || 'N/A'
|
|
64
|
-
document.getElementById('port').innerHTML = context.port || 'N/A'
|
|
65
|
-
document.getElementById('upnpInfo').innerHTML =
|
|
66
|
-
context.ipAddress && context.port
|
|
67
|
-
? '<a href="http://' +
|
|
68
|
-
context.ipAddress +
|
|
69
|
-
':' +
|
|
70
|
-
context.port +
|
|
71
|
-
'/setup.xml" target="_blank" class="primary-text">Visit XML →</a>'
|
|
72
|
-
: 'N/A'
|
|
73
|
-
document.getElementById('serialNumber').innerHTML = context.serialNumber || 'N/A'
|
|
74
|
-
document.getElementById('macAddress').innerHTML = context.macAddress || 'N/A'
|
|
75
|
-
document.getElementById('firmware').innerHTML = context.firmware || 'N/A'
|
|
76
|
-
document.getElementById('imgIcon').innerHTML =
|
|
77
|
-
context.icon && context.ipAddress && context.port
|
|
78
|
-
? '<img src="http://' +
|
|
79
|
-
context.ipAddress +
|
|
80
|
-
':' +
|
|
81
|
-
context.port +
|
|
82
|
-
'/' +
|
|
83
|
-
context.icon +
|
|
84
|
-
'" style="width: 150px;">'
|
|
85
|
-
: ''
|
|
86
|
-
document.getElementById('deviceTable').style.display = 'inline-table'
|
|
87
|
-
homebridge.hideSpinner()
|
|
88
|
-
}
|
|
89
|
-
deviceSelect.addEventListener('change', event => showDeviceInfo(event.target.value))
|
|
90
|
-
if (cachedAccessories.length > 0) {
|
|
91
|
-
showDeviceInfo(cachedAccessories[0].context.serialNumber)
|
|
92
|
-
} else {
|
|
93
|
-
const option = document.createElement('option')
|
|
94
|
-
option.text = 'No Devices'
|
|
95
|
-
deviceSelect.add(option)
|
|
96
|
-
deviceSelect.disabled = true
|
|
97
|
-
}
|
|
98
|
-
homebridge.hideSpinner()
|
|
99
|
-
}
|
|
100
|
-
function showSupport( )
|
|
101
|
-
{
|
|
102
|
-
homebridge.showSpinner()
|
|
103
|
-
homebridge.hideSchemaForm()
|
|
104
|
-
document.getElementById('menuHome').classList.add('btn-elegant')
|
|
105
|
-
document.getElementById('menuHome').classList.remove('btn-primary')
|
|
106
|
-
document.getElementById('menuDevices').classList.remove('btn-elegant')
|
|
107
|
-
document.getElementById('menuDevices').classList.add('btn-primary')
|
|
108
|
-
document.getElementById('menuSettings').classList.remove('btn-elegant')
|
|
109
|
-
document.getElementById('menuSettings').classList.add('btn-primary')
|
|
110
|
-
document.getElementById('pageSupport').style.display = 'block'
|
|
111
|
-
document.getElementById('pageDevices').style.display = 'none'
|
|
112
|
-
homebridge.hideSpinner()
|
|
113
|
-
}
|
|
114
|
-
function showSettings( )
|
|
115
|
-
{
|
|
116
|
-
homebridge.showSpinner()
|
|
117
|
-
document.getElementById('menuHome').classList.remove('btn-elegant')
|
|
118
|
-
document.getElementById('menuHome').classList.add('btn-primary')
|
|
119
|
-
document.getElementById('menuDevices').classList.remove('btn-elegant')
|
|
120
|
-
document.getElementById('menuDevices').classList.add('btn-primary')
|
|
121
|
-
document.getElementById('menuSettings').classList.add('btn-elegant')
|
|
122
|
-
document.getElementById('menuSettings').classList.remove('btn-primary')
|
|
123
|
-
document.getElementById('pageSupport').style.display = 'none'
|
|
124
|
-
document.getElementById('pageDevices').style.display = 'none'
|
|
125
|
-
homebridge.showSchemaForm()
|
|
126
|
-
homebridge.hideSpinner()
|
|
127
|
-
}
|
|
128
|
-
function showDisabledBanner( )
|
|
129
|
-
{
|
|
130
|
-
document.getElementById('disabledBanner').style.display = 'block'
|
|
131
|
-
}
|
|
132
|
-
async function enablePlugin( )
|
|
133
|
-
{
|
|
134
|
-
homebridge.showSpinner()
|
|
135
|
-
document.getElementById('disabledBanner').style.display = 'none'
|
|
136
|
-
currentConfig[0].disablePlugin = false
|
|
137
|
-
await homebridge.updatePluginConfig(currentConfig)
|
|
138
|
-
await homebridge.savePluginConfig()
|
|
139
|
-
homebridge.hideSpinner()
|
|
140
|
-
}
|
|
141
|
-
menuHome.addEventListener('click', () => showSupport())
|
|
142
|
-
menuDevices.addEventListener('click', () => showDevices())
|
|
143
|
-
menuSettings.addEventListener('click', () => showSettings())
|
|
144
|
-
disabledEnable.addEventListener('click', () => enablePlugin())
|
|
145
|
-
if (currentConfig.length) {
|
|
146
|
-
document.getElementById('menuWrapper').style.display = 'inline-flex'
|
|
147
|
-
showSettings()
|
|
148
|
-
if (currentConfig[0].disablePlugin) {
|
|
149
|
-
showDisabledBanner()
|
|
150
|
-
}
|
|
151
|
-
} else {
|
|
152
|
-
currentConfig.push({ name: 'Cmd4' })
|
|
153
|
-
await homebridge.updatePluginConfig(currentConfig)
|
|
154
|
-
showIntro()
|
|
155
|
-
}
|
|
156
|
-
} catch (err) {
|
|
157
|
-
homebridge.toast.error(err.message, 'Error')
|
|
158
|
-
} finally {
|
|
159
|
-
homebridge.hideSpinner()
|
|
160
|
-
}
|
|
161
|
-
})()
|