node-red-contrib-homekit-bridged 1.7.0-dev.1 → 1.7.0-dev.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/LICENSE +1 -1
- package/build/lib/HAPHostNode.js +20 -9
- package/build/lib/HAPServiceNode.js +4 -2
- package/build/lib/HAPServiceNode2.js +4 -2
- package/build/lib/api.js +11 -10
- package/build/lib/hap/HAPCharacteristic.d.ts +9 -0
- package/build/lib/hap/HAPCharacteristic.js +6 -0
- package/build/lib/hap/HAPService.d.ts +6 -0
- package/build/lib/hap/HAPService.js +6 -0
- package/build/lib/hap/eve-app/EveCharacteristics.d.ts +20 -0
- package/build/lib/hap/eve-app/EveCharacteristics.js +89 -0
- package/build/lib/hap/eve-app/EveServices.d.ts +5 -0
- package/build/lib/hap/eve-app/EveServices.js +20 -0
- package/build/lib/types/HAPHostConfigType.d.ts +2 -0
- package/build/lib/types/HAPHostNodeType.d.ts +2 -3
- package/build/lib/types/HAPServiceNodeType.d.ts +2 -1
- package/build/lib/types/PublishTimersType.d.ts +0 -1
- package/build/lib/types/hap-nodejs/BonjourMulticastOptions.d.ts +10 -0
- package/build/lib/types/hap-nodejs/BonjourMulticastOptions.js +2 -0
- package/build/lib/utils/NodeStatusUtils.d.ts +0 -1
- package/build/lib/utils/ServiceUtils.js +101 -28
- package/build/lib/utils/ServiceUtils2.js +17 -23
- package/build/nodes/bridge.html +87 -18
- package/build/nodes/nrchkb.html +148 -117
- package/build/nodes/service.html +6 -5
- package/build/nodes/service2.html +6 -5
- package/build/nodes/standalone.html +93 -24
- package/package.json +16 -16
package/build/nodes/nrchkb.html
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
border-radius: .25rem;
|
|
8
8
|
margin-right: 60px;
|
|
9
9
|
}
|
|
10
|
+
|
|
10
11
|
.alert-warning {
|
|
11
12
|
color: #856404;
|
|
12
13
|
background-color: #fff3cd;
|
|
@@ -56,55 +57,55 @@
|
|
|
56
57
|
|
|
57
58
|
$('#node-input-customCharacteristics-container').css('min-height', '150px').css('min-width', '550px').editableList({
|
|
58
59
|
addItem: function (container, i, opt) {
|
|
59
|
-
$(
|
|
60
|
+
$('.properties-accordion').accordion('option', 'active', false)
|
|
60
61
|
|
|
61
62
|
const {name, UUID, ...props} = opt
|
|
62
63
|
|
|
63
64
|
container.css({
|
|
64
65
|
overflow: 'hidden',
|
|
65
66
|
whiteSpace: 'nowrap'
|
|
66
|
-
})
|
|
67
|
+
})
|
|
67
68
|
|
|
68
|
-
const fragment = document.createDocumentFragment()
|
|
69
|
-
const row1 = $('<div/>', {style:
|
|
70
|
-
const row2 = $('<div/>', {style:
|
|
71
|
-
const row3 = $('<div/>', {style:
|
|
69
|
+
const fragment = document.createDocumentFragment()
|
|
70
|
+
const row1 = $('<div/>', {style: 'display:flex; align-items: center;'}).appendTo(fragment)
|
|
71
|
+
const row2 = $('<div/>', {style: 'display:flex; margin-top:8px; align-items: center;'}).appendTo(fragment)
|
|
72
|
+
const row3 = $('<div/>', {style: 'margin-top:8px; align-items: center;'}).appendTo(fragment)
|
|
72
73
|
|
|
73
74
|
$('<div/>', {
|
|
74
|
-
style:
|
|
75
|
-
required:
|
|
75
|
+
style: 'display:inline-block;text-align:left; width:120px; padding-left:10px; box-sizing:border-box;',
|
|
76
|
+
required: 'required'
|
|
76
77
|
})
|
|
77
78
|
.text('UUID ')
|
|
78
|
-
.appendTo(row1)
|
|
79
|
-
$('<input/>', {class:
|
|
79
|
+
.appendTo(row1)
|
|
80
|
+
$('<input/>', {class: 'property-uuid', type: 'text'})
|
|
80
81
|
.val(UUID ? UUID : uuidv4)
|
|
81
82
|
.appendTo(row1)
|
|
82
83
|
|
|
83
84
|
$('<div/>', {
|
|
84
|
-
style:
|
|
85
|
-
required:
|
|
85
|
+
style: 'display:inline-block;text-align:left; width:120px; padding-left:10px; box-sizing:border-box;',
|
|
86
|
+
required: 'required'
|
|
86
87
|
})
|
|
87
88
|
.text('Name ')
|
|
88
|
-
.appendTo(row2)
|
|
89
|
-
$('<input/>', {class:
|
|
89
|
+
.appendTo(row2)
|
|
90
|
+
$('<input/>', {class: 'property-name', type: 'text'})
|
|
90
91
|
.val(name)
|
|
91
92
|
.appendTo(row2)
|
|
92
93
|
|
|
93
|
-
const row3_properties_accordion = $('<div/>', {class:
|
|
94
|
-
.appendTo(row3)
|
|
94
|
+
const row3_properties_accordion = $('<div/>', {class: 'properties-accordion'})
|
|
95
|
+
.appendTo(row3)
|
|
95
96
|
|
|
96
|
-
$('<h3/>').text('Properties').appendTo(row3_properties_accordion)
|
|
97
|
+
$('<h3/>').text('Properties').appendTo(row3_properties_accordion)
|
|
97
98
|
|
|
98
|
-
const row3_properties = $('<div/>', {class:
|
|
99
|
+
const row3_properties = $('<div/>', {class: 'properties'}).appendTo(row3_properties_accordion)
|
|
99
100
|
|
|
100
|
-
const formatRow = $('<div/>', {class:
|
|
101
|
+
const formatRow = $('<div/>', {class: 'form-row'}).appendTo(row3_properties)
|
|
101
102
|
$('<label/>', {
|
|
102
|
-
class:
|
|
103
|
-
htmlFor:
|
|
104
|
-
}).text('Format *').appendTo(formatRow)
|
|
103
|
+
class: 'form-row',
|
|
104
|
+
htmlFor: 'property-format'
|
|
105
|
+
}).text('Format *').appendTo(formatRow)
|
|
105
106
|
const formatInput = $('<select/>', {
|
|
106
|
-
class:
|
|
107
|
-
required:
|
|
107
|
+
class: 'property-format',
|
|
108
|
+
required: 'required'
|
|
108
109
|
}).appendTo(formatRow)
|
|
109
110
|
$('<option/>').val(undefined).text('Choose...').appendTo(formatInput)
|
|
110
111
|
$('<option/>').val('bool').text('BOOL').appendTo(formatInput)
|
|
@@ -121,9 +122,9 @@
|
|
|
121
122
|
$('<option/>').val('dict').text('DICTIONARY').appendTo(formatInput)
|
|
122
123
|
formatInput.val(props.format)
|
|
123
124
|
|
|
124
|
-
const unitRow = $('<div/>', {class:
|
|
125
|
-
$('<label/>', {class:
|
|
126
|
-
const unitSelect = $('<select/>', {class:
|
|
125
|
+
const unitRow = $('<div/>', {class: 'form-row'}).appendTo(row3_properties)
|
|
126
|
+
$('<label/>', {class: 'form-row', htmlFor: 'property-unit'}).text('Unit').appendTo(unitRow)
|
|
127
|
+
const unitSelect = $('<select/>', {class: 'property-unit'}).appendTo(unitRow)
|
|
127
128
|
$('<option/>').val(undefined).text('Choose...').appendTo(unitSelect)
|
|
128
129
|
$('<option/>').val('celsius').text('CELSIUS').appendTo(unitSelect)
|
|
129
130
|
$('<option/>').val('percentage').text('PERCENTAGE').appendTo(unitSelect)
|
|
@@ -132,14 +133,14 @@
|
|
|
132
133
|
$('<option/>').val('seconds').text('SECONDS').appendTo(unitSelect)
|
|
133
134
|
unitSelect.val(props.unit)
|
|
134
135
|
|
|
135
|
-
const permsRow = $('<div/>', {class:
|
|
136
|
+
const permsRow = $('<div/>', {class: 'form-row'}).appendTo(row3_properties)
|
|
136
137
|
$('<label/>', {
|
|
137
|
-
class:
|
|
138
|
-
htmlFor:
|
|
138
|
+
class: 'form-row',
|
|
139
|
+
htmlFor: 'property-perms'
|
|
139
140
|
}).text('Permissions').appendTo(permsRow)
|
|
140
141
|
const permsSelect = $('<select/>', {
|
|
141
|
-
class:
|
|
142
|
-
multiple:
|
|
142
|
+
class: 'property-perms',
|
|
143
|
+
multiple: 'multiple'
|
|
143
144
|
}).appendTo(permsRow)
|
|
144
145
|
$('<option/>').val('pr').text('PAIRED_READ / READ').appendTo(permsSelect)
|
|
145
146
|
$('<option/>').val('pw').text('PAIRED_WRITE / WRITE').appendTo(permsSelect)
|
|
@@ -150,94 +151,94 @@
|
|
|
150
151
|
$('<option/>').val('wr').text('WRITE_RESPONSE').appendTo(permsSelect)
|
|
151
152
|
permsSelect.val(props.perms)
|
|
152
153
|
|
|
153
|
-
const evRow = $('<div/>', {class:
|
|
154
|
+
const evRow = $('<div/>', {class: 'form-row'}).appendTo(row3_properties)
|
|
154
155
|
$('<label/>', {
|
|
155
|
-
class:
|
|
156
|
-
htmlFor:
|
|
156
|
+
class: 'form-row',
|
|
157
|
+
htmlFor: 'property-ev'
|
|
157
158
|
}).text('Event Notifications').appendTo(evRow)
|
|
158
159
|
$('<input/>', {
|
|
159
|
-
class:
|
|
160
|
-
type:
|
|
160
|
+
class: 'property-ev',
|
|
161
|
+
type: 'checkbox',
|
|
161
162
|
checked: props.ev
|
|
162
163
|
}).appendTo(evRow)
|
|
163
164
|
|
|
164
|
-
const descriptionRow = $('<div/>', {class:
|
|
165
|
+
const descriptionRow = $('<div/>', {class: 'form-row'}).appendTo(row3_properties)
|
|
165
166
|
$('<label/>', {
|
|
166
|
-
class:
|
|
167
|
-
htmlFor:
|
|
167
|
+
class: 'form-row',
|
|
168
|
+
htmlFor: 'property-description'
|
|
168
169
|
}).text('Description').appendTo(descriptionRow)
|
|
169
170
|
$('<input/>', {
|
|
170
|
-
class:
|
|
171
|
+
class: 'property-description',
|
|
171
172
|
type: 'text'
|
|
172
173
|
}).appendTo(descriptionRow).val(props.description)
|
|
173
174
|
|
|
174
|
-
const minValueRow = $('<div/>', {class:
|
|
175
|
+
const minValueRow = $('<div/>', {class: 'form-row'}).appendTo(row3_properties)
|
|
175
176
|
$('<label/>', {
|
|
176
|
-
class:
|
|
177
|
-
htmlFor:
|
|
177
|
+
class: 'form-row',
|
|
178
|
+
htmlFor: 'property-minValue'
|
|
178
179
|
}).text('Minimum Value').appendTo(minValueRow)
|
|
179
180
|
$('<input/>', {
|
|
180
|
-
class:
|
|
181
|
+
class: 'property-minValue',
|
|
181
182
|
type: 'number'
|
|
182
183
|
}).appendTo(minValueRow).val(props.minValue)
|
|
183
184
|
|
|
184
|
-
const maxValueRow = $('<div/>', {class:
|
|
185
|
+
const maxValueRow = $('<div/>', {class: 'form-row'}).appendTo(row3_properties)
|
|
185
186
|
$('<label/>', {
|
|
186
|
-
class:
|
|
187
|
-
htmlFor:
|
|
187
|
+
class: 'form-row',
|
|
188
|
+
htmlFor: 'property-maxValue'
|
|
188
189
|
}).text('Maximum Value').appendTo(maxValueRow)
|
|
189
190
|
$('<input/>', {
|
|
190
|
-
class:
|
|
191
|
+
class: 'property-maxValue',
|
|
191
192
|
type: 'number'
|
|
192
193
|
}).appendTo(maxValueRow).val(props.maxValue)
|
|
193
194
|
|
|
194
|
-
const minStepRow = $('<div/>', {class:
|
|
195
|
+
const minStepRow = $('<div/>', {class: 'form-row'}).appendTo(row3_properties)
|
|
195
196
|
$('<label/>', {
|
|
196
|
-
class:
|
|
197
|
-
htmlFor:
|
|
197
|
+
class: 'form-row',
|
|
198
|
+
htmlFor: 'property-minStep'
|
|
198
199
|
}).text('Minimum Step').appendTo(minStepRow)
|
|
199
200
|
$('<input/>', {
|
|
200
|
-
class:
|
|
201
|
+
class: 'property-minStep',
|
|
201
202
|
type: 'number'
|
|
202
203
|
}).appendTo(minStepRow).val(props.minStep)
|
|
203
204
|
|
|
204
|
-
const maxLenRow = $('<div/>', {class:
|
|
205
|
+
const maxLenRow = $('<div/>', {class: 'form-row'}).appendTo(row3_properties)
|
|
205
206
|
$('<label/>', {
|
|
206
|
-
class:
|
|
207
|
-
htmlFor:
|
|
207
|
+
class: 'form-row',
|
|
208
|
+
htmlFor: 'property-maxLen'
|
|
208
209
|
}).text('Maximum Length').appendTo(maxLenRow)
|
|
209
210
|
$('<input/>', {
|
|
210
|
-
class:
|
|
211
|
+
class: 'property-maxLen',
|
|
211
212
|
type: 'number'
|
|
212
213
|
}).appendTo(maxLenRow).val(props.maxLen)
|
|
213
214
|
|
|
214
|
-
const maxDataLenRow = $('<div/>', {class:
|
|
215
|
+
const maxDataLenRow = $('<div/>', {class: 'form-row'}).appendTo(row3_properties)
|
|
215
216
|
$('<label/>', {
|
|
216
|
-
class:
|
|
217
|
-
htmlFor:
|
|
217
|
+
class: 'form-row',
|
|
218
|
+
htmlFor: 'property-maxDataLen'
|
|
218
219
|
}).text('Maximum Data Length').appendTo(maxDataLenRow)
|
|
219
220
|
$('<input/>', {
|
|
220
|
-
class:
|
|
221
|
+
class: 'property-maxDataLen',
|
|
221
222
|
type: 'number'
|
|
222
223
|
}).appendTo(maxDataLenRow).val(props.maxDataLen)
|
|
223
224
|
|
|
224
|
-
const validValuesRow = $('<div/>', {class:
|
|
225
|
+
const validValuesRow = $('<div/>', {class: 'form-row'}).appendTo(row3_properties)
|
|
225
226
|
$('<label/>', {
|
|
226
|
-
class:
|
|
227
|
-
htmlFor:
|
|
227
|
+
class: 'form-row',
|
|
228
|
+
htmlFor: 'property-validValues'
|
|
228
229
|
}).text('Valid Values').appendTo(validValuesRow)
|
|
229
230
|
$('<input/>', {
|
|
230
|
-
class:
|
|
231
|
+
class: 'property-validValues',
|
|
231
232
|
type: 'text'
|
|
232
233
|
}).appendTo(validValuesRow).val(props.validValues)
|
|
233
234
|
|
|
234
|
-
const validValueRangesRow = $('<div/>', {class:
|
|
235
|
+
const validValueRangesRow = $('<div/>', {class: 'form-row'}).appendTo(row3_properties)
|
|
235
236
|
const validValueRangesLabel = $('<label/>', {
|
|
236
|
-
class:
|
|
237
|
-
htmlFor:
|
|
237
|
+
class: 'form-row property-validValueRanges-label',
|
|
238
|
+
htmlFor: 'property-validValueRanges'
|
|
238
239
|
}).text('Valid Value Ranges: ').appendTo(validValueRangesRow)
|
|
239
240
|
const validValueRangesSlider = $('<div/>', {
|
|
240
|
-
class:
|
|
241
|
+
class: 'property-validValueRanges',
|
|
241
242
|
type: 'text'
|
|
242
243
|
}).appendTo(validValueRangesRow)
|
|
243
244
|
|
|
@@ -247,19 +248,19 @@
|
|
|
247
248
|
max: 500,
|
|
248
249
|
values: props.validValueRanges,
|
|
249
250
|
slide: function (event, ui) {
|
|
250
|
-
validValueRangesLabel.text(
|
|
251
|
+
validValueRangesLabel.text('Valid Value Ranges: [' + ui.values[0] + ', ' + ui.values[1] + ']')
|
|
251
252
|
}
|
|
252
|
-
})
|
|
253
|
-
validValueRangesLabel.text(
|
|
253
|
+
})
|
|
254
|
+
validValueRangesLabel.text('Valid Value Ranges: [' + validValueRangesSlider.slider('values', 0) + ', ' + validValueRangesSlider.slider('values', 1) + ']')
|
|
254
255
|
|
|
255
|
-
const adminOnlyAccessRow = $('<div/>', {class:
|
|
256
|
+
const adminOnlyAccessRow = $('<div/>', {class: 'form-row'}).appendTo(row3_properties)
|
|
256
257
|
$('<label/>', {
|
|
257
|
-
class:
|
|
258
|
-
htmlFor:
|
|
258
|
+
class: 'form-row',
|
|
259
|
+
htmlFor: 'property-adminOnlyAccess'
|
|
259
260
|
}).text('Admin Only Access').appendTo(adminOnlyAccessRow)
|
|
260
261
|
const adminOnlyAccessSelect = $('<select/>', {
|
|
261
|
-
class:
|
|
262
|
-
multiple:
|
|
262
|
+
class: 'property-adminOnlyAccess',
|
|
263
|
+
multiple: 'multiple'
|
|
263
264
|
}).appendTo(adminOnlyAccessRow)
|
|
264
265
|
$('<option/>').val(0).text('READ').appendTo(adminOnlyAccessSelect)
|
|
265
266
|
$('<option/>').val(1).text('WRITE').appendTo(adminOnlyAccessSelect)
|
|
@@ -269,30 +270,30 @@
|
|
|
269
270
|
row3_properties_accordion.accordion({
|
|
270
271
|
collapsible: true,
|
|
271
272
|
active: 'UUID' in opt ? false : 0,
|
|
272
|
-
heightStyle:
|
|
273
|
-
})
|
|
273
|
+
heightStyle: 'content'
|
|
274
|
+
})
|
|
274
275
|
|
|
275
|
-
container[0].appendChild(fragment)
|
|
276
|
+
container[0].appendChild(fragment)
|
|
276
277
|
},
|
|
277
278
|
removable: true,
|
|
278
279
|
sortable: true
|
|
279
|
-
})
|
|
280
|
+
})
|
|
280
281
|
|
|
281
282
|
for (let i = 0; i < config.customCharacteristics.length; i++) {
|
|
282
|
-
const customCharacteristic = config.customCharacteristics[i]
|
|
283
|
-
$(
|
|
283
|
+
const customCharacteristic = config.customCharacteristics[i]
|
|
284
|
+
$('#node-input-customCharacteristics-container').editableList('addItem', customCharacteristic)
|
|
284
285
|
}
|
|
285
286
|
},
|
|
286
287
|
oneditresize: function (size) {
|
|
287
|
-
const rows = $(
|
|
288
|
-
let height = size.height
|
|
288
|
+
const rows = $('#dialog-form>div:not(.node-input-customCharacteristics-container-row)')
|
|
289
|
+
let height = size.height
|
|
289
290
|
for (let i = 0; i < rows.length; i++) {
|
|
290
|
-
height -= $(rows[i]).outerHeight(true)
|
|
291
|
+
height -= $(rows[i]).outerHeight(true)
|
|
291
292
|
}
|
|
292
|
-
const editorRow = $(
|
|
293
|
-
height -= (parseInt(editorRow.css(
|
|
294
|
-
height += 16
|
|
295
|
-
$(
|
|
293
|
+
const editorRow = $('#dialog-form>div.node-input-customCharacteristics-container-row')
|
|
294
|
+
height -= (parseInt(editorRow.css('marginTop')) + parseInt(editorRow.css('marginBottom')))
|
|
295
|
+
height += 16
|
|
296
|
+
$('#node-input-customCharacteristics-container').editableList('height', height)
|
|
296
297
|
}
|
|
297
298
|
})
|
|
298
299
|
}
|
|
@@ -352,27 +353,27 @@
|
|
|
352
353
|
|
|
353
354
|
const saveCustomCharacteristics = function (self) {
|
|
354
355
|
const customCharacteristics = []
|
|
355
|
-
const items = $(
|
|
356
|
+
const items = $('#node-input-customCharacteristics-container').editableList('items')
|
|
356
357
|
|
|
357
358
|
items.each(function () {
|
|
358
|
-
const item = $(this)
|
|
359
|
-
const name = item.find(
|
|
360
|
-
const UUID = item.find(
|
|
361
|
-
const format = item.find(
|
|
362
|
-
const unit = item.find(
|
|
363
|
-
const perms = item.find(
|
|
364
|
-
const ev = item.find(
|
|
365
|
-
const description = item.find(
|
|
366
|
-
const minValue = item.find(
|
|
367
|
-
const maxValue = item.find(
|
|
368
|
-
const minStep = item.find(
|
|
369
|
-
const maxLen = item.find(
|
|
370
|
-
const maxDataLen = item.find(
|
|
371
|
-
const validValues = item.find(
|
|
372
|
-
const validValueRangesMin = item.find(
|
|
373
|
-
const validValueRangesMax = item.find(
|
|
359
|
+
const item = $(this)
|
|
360
|
+
const name = item.find('.property-name').val()
|
|
361
|
+
const UUID = item.find('.property-uuid').val()
|
|
362
|
+
const format = item.find('.property-format').val()
|
|
363
|
+
const unit = item.find('.property-unit').val()
|
|
364
|
+
const perms = item.find('.property-perms').val()
|
|
365
|
+
const ev = item.find('.property-ev').prop('checked')
|
|
366
|
+
const description = item.find('.property-description').val()
|
|
367
|
+
const minValue = item.find('.property-minValue').val()
|
|
368
|
+
const maxValue = item.find('.property-maxValue').val()
|
|
369
|
+
const minStep = item.find('.property-minStep').val()
|
|
370
|
+
const maxLen = item.find('.property-maxLen').val()
|
|
371
|
+
const maxDataLen = item.find('.property-maxDataLen').val()
|
|
372
|
+
const validValues = item.find('.property-validValues').val()
|
|
373
|
+
const validValueRangesMin = item.find('.property-validValueRanges').slider('values', 0)
|
|
374
|
+
const validValueRangesMax = item.find('.property-validValueRanges').slider('values', 1)
|
|
374
375
|
const validValueRanges = validValueRangesMin && validValueRangesMax ? [validValueRangesMin, validValueRangesMax] : undefined
|
|
375
|
-
const adminOnlyAccess = item.find(
|
|
376
|
+
const adminOnlyAccess = item.find('.property-adminOnlyAccess').val()
|
|
376
377
|
customCharacteristics.push({
|
|
377
378
|
name,
|
|
378
379
|
UUID,
|
|
@@ -389,8 +390,8 @@
|
|
|
389
390
|
validValues,
|
|
390
391
|
validValueRanges,
|
|
391
392
|
adminOnlyAccess
|
|
392
|
-
})
|
|
393
|
-
})
|
|
393
|
+
})
|
|
394
|
+
})
|
|
394
395
|
|
|
395
396
|
config.customCharacteristics = customCharacteristics
|
|
396
397
|
|
|
@@ -399,27 +400,57 @@
|
|
|
399
400
|
url: 'nrchkb/config',
|
|
400
401
|
dataType: 'json',
|
|
401
402
|
data: {customCharacteristics}
|
|
402
|
-
})
|
|
403
|
+
})
|
|
403
404
|
}
|
|
404
405
|
|
|
405
406
|
const uuidv4 = function () {
|
|
406
407
|
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
|
407
408
|
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
|
408
|
-
)
|
|
409
|
+
)
|
|
409
410
|
}
|
|
410
411
|
|
|
411
412
|
const getRandomIntInclusive = function (min, max) {
|
|
412
|
-
min = Math.ceil(min)
|
|
413
|
-
max = Math.floor(max)
|
|
414
|
-
return Math.floor(Math.random() * (max - min + 1) + min)
|
|
413
|
+
min = Math.ceil(min)
|
|
414
|
+
max = Math.floor(max)
|
|
415
|
+
return Math.floor(Math.random() * (max - min + 1) + min)
|
|
415
416
|
}
|
|
416
417
|
|
|
418
|
+
const forbiddenPinCodes = [
|
|
419
|
+
'00000000',
|
|
420
|
+
'11111111',
|
|
421
|
+
'22222222',
|
|
422
|
+
'33333333',
|
|
423
|
+
'44444444',
|
|
424
|
+
'55555555',
|
|
425
|
+
'66666666',
|
|
426
|
+
'77777777',
|
|
427
|
+
'88888888',
|
|
428
|
+
'99999999',
|
|
429
|
+
'12345678',
|
|
430
|
+
'87654321'
|
|
431
|
+
]
|
|
432
|
+
|
|
417
433
|
const generatePinCode = function () {
|
|
418
|
-
const [a, b, c, d, e, f, g, h] = Array.from({length: 9}, () => getRandomIntInclusive(0, 9))
|
|
434
|
+
const [a, b, c, d, e, f, g, h] = Array.from({length: 9}, () => getRandomIntInclusive(0, 9))
|
|
435
|
+
|
|
436
|
+
if (forbiddenPinCodes.includes(`${a}${b}${c}${d}${e}${f}${g}${h}`)) {
|
|
437
|
+
return generatePinCode()
|
|
438
|
+
}
|
|
439
|
+
|
|
419
440
|
return `${a}${b}${c}${d}-${e}${f}${g}${h}`
|
|
420
441
|
}
|
|
421
442
|
|
|
422
|
-
const
|
|
443
|
+
const validatePinCode = function (value) {
|
|
444
|
+
if (!value) {
|
|
445
|
+
return false
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
if (!RED.validators.regex(/([0-9]{3}-[0-9]{2}-[0-9]{3}|[0-9]{4}-[0-9]{4})/)(value)) {
|
|
449
|
+
return false
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
return !forbiddenPinCodes.includes(value.replaceAll('-', ''))
|
|
453
|
+
}
|
|
423
454
|
</script>
|
|
424
455
|
|
|
425
456
|
<script data-template-name="nrchkb" type="text/x-red">
|
package/build/nodes/service.html
CHANGED
|
@@ -203,13 +203,14 @@
|
|
|
203
203
|
<div class="form-row">
|
|
204
204
|
<label for="node-input-adaptiveLightingOptionsMode"><i class="fa fa-hand-o-up"></i> Mode</label>
|
|
205
205
|
<select id="node-input-adaptiveLightingOptionsMode">
|
|
206
|
-
<option value="
|
|
207
|
-
<option value="1">
|
|
206
|
+
<option value="" selected hidden disabled>AUTOMATIC</option>
|
|
207
|
+
<option value="1">AUTOMATIC</option>
|
|
208
|
+
<option value="2">MANUAL</option>
|
|
208
209
|
</select>
|
|
209
210
|
</div>
|
|
210
211
|
<div class="form-row">
|
|
211
212
|
<label for="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment"><i class="fa fa-thermometer-quarter"></i> Custom Temperature Adjustment</label>
|
|
212
|
-
<input type="
|
|
213
|
+
<input type="number" id="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment" placeholder="0">
|
|
213
214
|
</div>
|
|
214
215
|
</div>
|
|
215
216
|
|
|
@@ -498,10 +499,10 @@
|
|
|
498
499
|
value: false,
|
|
499
500
|
},
|
|
500
501
|
adaptiveLightingOptionsMode: {
|
|
501
|
-
|
|
502
|
+
validate: RED.validators.number(true)
|
|
502
503
|
},
|
|
503
504
|
adaptiveLightingOptionsCustomTemperatureAdjustment: {
|
|
504
|
-
|
|
505
|
+
validate: RED.validators.number(true)
|
|
505
506
|
},
|
|
506
507
|
},
|
|
507
508
|
inputs: 1,
|
|
@@ -203,13 +203,14 @@
|
|
|
203
203
|
<div class="form-row">
|
|
204
204
|
<label for="node-input-adaptiveLightingOptionsMode"><i class="fa fa-hand-o-up"></i> Mode</label>
|
|
205
205
|
<select id="node-input-adaptiveLightingOptionsMode">
|
|
206
|
-
<option value="
|
|
207
|
-
<option value="1">
|
|
206
|
+
<option value="" selected hidden disabled>AUTOMATIC</option>
|
|
207
|
+
<option value="1">AUTOMATIC</option>
|
|
208
|
+
<option value="2">MANUAL</option>
|
|
208
209
|
</select>
|
|
209
210
|
</div>
|
|
210
211
|
<div class="form-row">
|
|
211
212
|
<label for="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment"><i class="fa fa-thermometer-quarter"></i> Custom Temperature Adjustment</label>
|
|
212
|
-
<input type="
|
|
213
|
+
<input type="number" id="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment" placeholder="0">
|
|
213
214
|
</div>
|
|
214
215
|
</div>
|
|
215
216
|
|
|
@@ -508,10 +509,10 @@ if (nrchkbExperimental) {
|
|
|
508
509
|
value: false,
|
|
509
510
|
},
|
|
510
511
|
adaptiveLightingOptionsMode: {
|
|
511
|
-
|
|
512
|
+
validate: RED.validators.number(true)
|
|
512
513
|
},
|
|
513
514
|
adaptiveLightingOptionsCustomTemperatureAdjustment: {
|
|
514
|
-
|
|
515
|
+
validate: RED.validators.number(true)
|
|
515
516
|
},
|
|
516
517
|
},
|
|
517
518
|
inputs: 1,
|