homey-lib 2.45.2 → 2.45.3
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/lib/App/index.js +25 -2
- package/package.json +1 -1
- package/webpack/index.js +1 -1
package/lib/App/index.js
CHANGED
|
@@ -371,9 +371,32 @@ class App {
|
|
|
371
371
|
// validate `appJson.drivers[].capabilitiesOptions`
|
|
372
372
|
if (driver.capabilitiesOptions) {
|
|
373
373
|
for (const [capabilityId, capabilityOptions] of Object.entries(driver.capabilitiesOptions)) {
|
|
374
|
-
//
|
|
374
|
+
// Merge canonical + extra values for target_power_mode - canonical always present, extras appended
|
|
375
375
|
if (Capability.isInstanceOfId(capabilityId, 'target_power_mode')) {
|
|
376
|
-
|
|
376
|
+
const canonicalValues = Capability.getCapability('target_power_mode').values;
|
|
377
|
+
const providedValues = Array.isArray(capabilityOptions.values) ? capabilityOptions.values : [];
|
|
378
|
+
|
|
379
|
+
const seenIds = new Set(canonicalValues.map(canonical => canonical.id));
|
|
380
|
+
const extraValues = [];
|
|
381
|
+
|
|
382
|
+
for (const value of providedValues) {
|
|
383
|
+
if (!value || typeof value !== 'object' || typeof value.id !== 'string') continue;
|
|
384
|
+
if (seenIds.has(value.id)) continue;
|
|
385
|
+
seenIds.add(value.id);
|
|
386
|
+
extraValues.push(value);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const RESERVED_PREFIXES = ['homey_', 'device_'];
|
|
390
|
+
const reservedValues = extraValues.filter(value =>
|
|
391
|
+
RESERVED_PREFIXES.some(prefix => value.id.startsWith(prefix))
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
if (reservedValues.length) {
|
|
395
|
+
const ids = reservedValues.map(value => value.id).join(', ');
|
|
396
|
+
throw new Error(`drivers.${driver.id}.capabilitiesOptions.${capabilityId} custom values cannot use reserved prefixes "homey_" or "device_": ${ids}`);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
capabilityOptions.values = [...canonicalValues, ...extraValues];
|
|
377
400
|
}
|
|
378
401
|
|
|
379
402
|
// validate target_power exclude range must include 0
|