nayota-show-sdk 1.3.74 → 1.3.75
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/package.json +1 -1
- package/utils/iot-module-specs.js +55 -1
- package/utils/iot-module-specs.test.js +35 -10
package/package.json
CHANGED
|
@@ -360,6 +360,60 @@ function normalizeLegacyPropLine(source = {}, prop = {}, row = {}) {
|
|
|
360
360
|
return null
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
+
const LEGACY_SWITCH_STATUS_KEYWORDS = [
|
|
364
|
+
'开关',
|
|
365
|
+
'电源',
|
|
366
|
+
'启停',
|
|
367
|
+
'启动',
|
|
368
|
+
'运行',
|
|
369
|
+
'switch',
|
|
370
|
+
'power'
|
|
371
|
+
]
|
|
372
|
+
|
|
373
|
+
const LEGACY_SWITCH_STATUS_EXCLUDE_KEYWORDS = [
|
|
374
|
+
'模式',
|
|
375
|
+
'温度',
|
|
376
|
+
'风速',
|
|
377
|
+
'设定',
|
|
378
|
+
'设置',
|
|
379
|
+
'锁屏',
|
|
380
|
+
'锁定',
|
|
381
|
+
'lock',
|
|
382
|
+
'mode',
|
|
383
|
+
'temp',
|
|
384
|
+
'speed',
|
|
385
|
+
'set'
|
|
386
|
+
]
|
|
387
|
+
|
|
388
|
+
function isLegacyBinaryInterval(interval) {
|
|
389
|
+
try {
|
|
390
|
+
const payload = typeof interval === 'string' ? JSON.parse(interval) : interval
|
|
391
|
+
return Array.isArray(payload) && Array.isArray(payload[0]) && payload[0].length === 2
|
|
392
|
+
} catch {
|
|
393
|
+
return false
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function isLegacySwitchOperateStatus(source = {}, interval = '') {
|
|
398
|
+
if (source.propType !== 'Operate' || !isLegacyBinaryInterval(interval)) {
|
|
399
|
+
return false
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const normalized = [
|
|
403
|
+
source.propertyKey,
|
|
404
|
+
source.propName,
|
|
405
|
+
source.name,
|
|
406
|
+
source.code,
|
|
407
|
+
source.shortAddress
|
|
408
|
+
].filter(Boolean).join(' ').toLowerCase()
|
|
409
|
+
|
|
410
|
+
if (LEGACY_SWITCH_STATUS_EXCLUDE_KEYWORDS.some(keyword => normalized.includes(keyword))) {
|
|
411
|
+
return false
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return LEGACY_SWITCH_STATUS_KEYWORDS.some(keyword => normalized.includes(keyword))
|
|
415
|
+
}
|
|
416
|
+
|
|
363
417
|
function normalizeLegacyNumber(value) {
|
|
364
418
|
if (value === undefined || value === null || value === '') {
|
|
365
419
|
return null
|
|
@@ -468,7 +522,7 @@ function normalizeLegacyEasyListProp(source = {}, row = {}) {
|
|
|
468
522
|
const interval = prop.interval || source.interval || source.valueMap || ''
|
|
469
523
|
const line = normalizeLegacyPropLine(source, prop, row)
|
|
470
524
|
const isMain = Boolean(source.isMain)
|
|
471
|
-
const isStatus = Boolean(source.isStatus)
|
|
525
|
+
const isStatus = Boolean(source.isStatus || isLegacySwitchOperateStatus(source, interval))
|
|
472
526
|
const isNumber = Boolean(source.isNumber)
|
|
473
527
|
const isImport = Boolean(source.isImport || isMain || isStatus || isNumber)
|
|
474
528
|
|
|
@@ -168,14 +168,29 @@ describe('iotModuleSpecs devices easyList legacy compatibility', () => {
|
|
|
168
168
|
name: '模式设定',
|
|
169
169
|
isStatus: true,
|
|
170
170
|
line: true,
|
|
171
|
-
value:
|
|
172
|
-
valueStr: '
|
|
171
|
+
value: 0,
|
|
172
|
+
valueStr: '制冷',
|
|
173
173
|
interval: '[["制冷","制热"],[0,1]]',
|
|
174
174
|
valueAt: '2026-04-25T06:30:00.000Z',
|
|
175
175
|
prop: {
|
|
176
176
|
id: 'device-prop-mode'
|
|
177
177
|
}
|
|
178
178
|
},
|
|
179
|
+
{
|
|
180
|
+
id: 'twin-prop-switch',
|
|
181
|
+
propId: 'device-prop-switch',
|
|
182
|
+
propertyKey: 'powerSwitch',
|
|
183
|
+
name: '开关',
|
|
184
|
+
propType: 'Operate',
|
|
185
|
+
line: true,
|
|
186
|
+
value: 1,
|
|
187
|
+
valueStr: '开',
|
|
188
|
+
interval: '[["关","开"],[0,1]]',
|
|
189
|
+
valueAt: '2026-04-25T06:30:30.000Z',
|
|
190
|
+
prop: {
|
|
191
|
+
id: 'device-prop-switch'
|
|
192
|
+
}
|
|
193
|
+
},
|
|
179
194
|
{
|
|
180
195
|
id: 'twin-prop-electric',
|
|
181
196
|
propId: 'device-prop-electric',
|
|
@@ -199,14 +214,15 @@ describe('iotModuleSpecs devices easyList legacy compatibility', () => {
|
|
|
199
214
|
|
|
200
215
|
const row = response.data.rows[0]
|
|
201
216
|
const modeProp = row.props[1]
|
|
202
|
-
const
|
|
217
|
+
const switchProp = row.props[2]
|
|
218
|
+
const electricProp = row.props[3]
|
|
203
219
|
|
|
204
220
|
expect(row._id).toBe('twin-1')
|
|
205
221
|
expect(row.status).toEqual({
|
|
206
222
|
value: 1,
|
|
207
|
-
label: '
|
|
208
|
-
valueStr: '
|
|
209
|
-
total:
|
|
223
|
+
label: '开',
|
|
224
|
+
valueStr: '开',
|
|
225
|
+
total: 3,
|
|
210
226
|
open: 1
|
|
211
227
|
})
|
|
212
228
|
expect(modeProp).toEqual(
|
|
@@ -216,8 +232,8 @@ describe('iotModuleSpecs devices easyList legacy compatibility', () => {
|
|
|
216
232
|
isStatus: true,
|
|
217
233
|
isImport: true,
|
|
218
234
|
line: true,
|
|
219
|
-
value:
|
|
220
|
-
valueStr: '
|
|
235
|
+
value: 0,
|
|
236
|
+
valueStr: '制冷',
|
|
221
237
|
interval: '[["制冷","制热"],[0,1]]',
|
|
222
238
|
valueAt: '2026-04-25T06:30:00.000Z'
|
|
223
239
|
})
|
|
@@ -226,12 +242,21 @@ describe('iotModuleSpecs devices easyList legacy compatibility', () => {
|
|
|
226
242
|
expect.objectContaining({
|
|
227
243
|
_id: 'device-prop-mode',
|
|
228
244
|
line: true,
|
|
229
|
-
value:
|
|
230
|
-
valueStr: '
|
|
245
|
+
value: 0,
|
|
246
|
+
valueStr: '制冷',
|
|
231
247
|
interval: '[["制冷","制热"],[0,1]]',
|
|
232
248
|
valueAt: '2026-04-25T06:30:00.000Z'
|
|
233
249
|
})
|
|
234
250
|
)
|
|
251
|
+
expect(switchProp).toEqual(
|
|
252
|
+
expect.objectContaining({
|
|
253
|
+
propType: 'Operate',
|
|
254
|
+
isStatus: true,
|
|
255
|
+
isImport: true,
|
|
256
|
+
value: 1,
|
|
257
|
+
valueStr: '开'
|
|
258
|
+
})
|
|
259
|
+
)
|
|
235
260
|
expect(electricProp).toEqual(
|
|
236
261
|
expect.objectContaining({
|
|
237
262
|
isMain: true,
|