From be31305093aac7232c145e443033a36ed4623b77 Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Sun, 1 Dec 2024 23:36:56 -0600 Subject: [PATCH 1/6] Add bulk set parameters to inovelli switches --- .../config/devices/0x031e/lzw30-sn.json | 160 ++++++------- .../config/devices/0x031e/lzw31-sn.json | 6 +- .../config/config/devices/0x031e/lzw36.json | 216 +++++------------- .../0x031e/templates/inovelli_templates.json | 9 + .../config/devices/0x031e/vzw31-sn.json | 5 + 5 files changed, 152 insertions(+), 244 deletions(-) diff --git a/packages/config/config/devices/0x031e/lzw30-sn.json b/packages/config/config/devices/0x031e/lzw30-sn.json index 089a0b980e4f..8385976ae355 100644 --- a/packages/config/config/devices/0x031e/lzw30-sn.json +++ b/packages/config/config/devices/0x031e/lzw30-sn.json @@ -17,7 +17,7 @@ "paramInformation": [ { "#": "1", - "$import": "~/templates/master_template.json#state_after_power_failure_prev_on_off" + "$import": "templates/inovelli_templates.json#state_after_power_failure_prev_on_off" }, { "#": "2", @@ -208,83 +208,8 @@ ] }, { - "#": "9", - "label": "LED Strip Timeout", - "valueSize": 1, - "unit": "seconds", - "minValue": 0, - "maxValue": 10, - "defaultValue": 0, - "options": [ - { - "label": "Stay off", - "value": 0 - } - ] - }, - { - "#": "10", - "label": "Active Power Reports", - "valueSize": 1, - "unit": "%", - "minValue": 0, - "maxValue": 100, - "defaultValue": 10 - }, - { - "#": "11", - "label": "Periodic Power & Energy Reports", - "valueSize": 2, - "unit": "seconds", - "minValue": 0, - "maxValue": 32767, - "defaultValue": 3600 - }, - { - "#": "12", - "label": "Energy Reports", - "valueSize": 1, - "unit": "%", - "minValue": 0, - "maxValue": 100, - "defaultValue": 10 - }, - { - "#": "13", - "$if": "firmwareVersion >= 1.17", - "label": "Load Type", - "valueSize": 1, - "defaultValue": 0, - "allowManualEntry": false, - "options": [ - { - "label": "Automatically detect load type", - "value": 0 - }, - { - "label": "Manually set for special load type", - "value": 1 - } - ] - }, - { - "#": "51", - "$if": "firmwareVersion >= 1.19", - "label": "Instant On", - "description": "Enabling this disables the 700ms button delay and multi-tap scenes.", - "valueSize": 1, - "defaultValue": 1, - "allowManualEntry": false, - "options": [ - { - "label": "Enabled", - "value": 0 - }, - { - "label": "Disabled", - "value": 1 - } - ] + "#": "8", + "$import": "templates/inovelli_templates.json#bulk_set_led_effect" }, { "#": "8[0xff]", @@ -421,6 +346,85 @@ "value": 4 } ] + }, + { + "#": "9", + "label": "LED Strip Timeout", + "valueSize": 1, + "unit": "seconds", + "minValue": 0, + "maxValue": 10, + "defaultValue": 0, + "options": [ + { + "label": "Stay off", + "value": 0 + } + ] + }, + { + "#": "10", + "label": "Active Power Reports", + "valueSize": 1, + "unit": "%", + "minValue": 0, + "maxValue": 100, + "defaultValue": 10 + }, + { + "#": "11", + "label": "Periodic Power & Energy Reports", + "valueSize": 2, + "unit": "seconds", + "minValue": 0, + "maxValue": 32767, + "defaultValue": 3600 + }, + { + "#": "12", + "label": "Energy Reports", + "valueSize": 1, + "unit": "%", + "minValue": 0, + "maxValue": 100, + "defaultValue": 10 + }, + { + "#": "13", + "$if": "firmwareVersion >= 1.17", + "label": "Load Type", + "valueSize": 1, + "defaultValue": 0, + "allowManualEntry": false, + "options": [ + { + "label": "Automatically detect load type", + "value": 0 + }, + { + "label": "Manually set for special load type", + "value": 1 + } + ] + }, + { + "#": "51", + "$if": "firmwareVersion >= 1.19", + "label": "Instant On", + "description": "Enabling this disables the 700ms button delay and multi-tap scenes.", + "valueSize": 1, + "defaultValue": 1, + "allowManualEntry": false, + "options": [ + { + "label": "Enabled", + "value": 0 + }, + { + "label": "Disabled", + "value": 1 + } + ] } ], "metadata": { diff --git a/packages/config/config/devices/0x031e/lzw31-sn.json b/packages/config/config/devices/0x031e/lzw31-sn.json index 049ff78a25c4..1723568bc0d5 100644 --- a/packages/config/config/devices/0x031e/lzw31-sn.json +++ b/packages/config/config/devices/0x031e/lzw31-sn.json @@ -376,13 +376,15 @@ "label": "LED Indicator: Brightness When Off", "defaultValue": 1 }, + { + "#": "16", + "$import": "templates/inovelli_templates.json#bulk_set_led_effect" + }, { "#": "16[0xff]", "$import": "#paramInformation/13", "label": "LED Indicator: Effect Color", "valueSize": 4, - "minValue": 0, - "maxValue": 255, "defaultValue": 0, "unsigned": true, "options": [ diff --git a/packages/config/config/devices/0x031e/lzw36.json b/packages/config/config/devices/0x031e/lzw36.json index 44517c6fdac0..845d10ad751f 100644 --- a/packages/config/config/devices/0x031e/lzw36.json +++ b/packages/config/config/devices/0x031e/lzw36.json @@ -595,102 +595,9 @@ ] }, { - "#": "24[0x7f000000]", - "label": "Light LED Effect Type", - "valueSize": 4, - "defaultValue": 0, - "unsigned": true, - "allowManualEntry": false, - "options": [ - { - "label": "Off", - "value": 0 - }, - { - "label": "Solid", - "value": 1 - }, - { - "label": "Chase", - "value": 2 - }, - { - "label": "Fast blink", - "value": 3 - }, - { - "label": "Slow blink", - "value": 4 - }, - { - "label": "Pulse", - "value": 5 - } - ] - }, - { - "#": "24[0xff0000]", - "label": "Light LED Effect Duration", - "description": "0 = disabled, 1 to 60 = seconds, 61 to 120 = minutes (minus 60), 121 - 254 = hours (minus 120), 255 = indefinitely", - "valueSize": 4, - "minValue": 0, - "maxValue": 255, - "defaultValue": 255, - "unsigned": true - }, - { - "#": "24[0xff00]", - "label": "Light LED Effect Brightness", - "valueSize": 4, - "defaultValue": 3, - "unsigned": true, - "allowManualEntry": false, - "options": [ - { - "label": "Off", - "value": 0 - }, - { - "label": "10%", - "value": 1 - }, - { - "label": "20%", - "value": 2 - }, - { - "label": "30%", - "value": 3 - }, - { - "label": "40%", - "value": 4 - }, - { - "label": "50%", - "value": 5 - }, - { - "label": "60%", - "value": 6 - }, - { - "label": "70%", - "value": 7 - }, - { - "label": "80%", - "value": 8 - }, - { - "label": "90%", - "value": 9 - }, - { - "label": "100%", - "value": 10 - } - ] + "#": "24", + "$import": "templates/inovelli_templates.json#bulk_set_led_effect", + "label": "Bulk Set Light LED Effect" }, { "#": "24[0xff]", @@ -737,52 +644,8 @@ ] }, { - "#": "25[0x7f000000]", - "label": "Fan LED Effect Type", - "valueSize": 4, - "defaultValue": 0, - "unsigned": true, - "allowManualEntry": false, - "options": [ - { - "label": "Off", - "value": 0 - }, - { - "label": "Solid", - "value": 1 - }, - { - "label": "Chase", - "value": 2 - }, - { - "label": "Fast blink", - "value": 3 - }, - { - "label": "Slow blink", - "value": 4 - }, - { - "label": "Pulse", - "value": 5 - } - ] - }, - { - "#": "25[0xff0000]", - "label": "Fan LED Effect Duration", - "description": "0 = disabled, 1 to 60 = seconds, 61 to 120 = minutes (minus 60), 121 - 254 = hours (minus 120), 255 = indefinitely", - "valueSize": 4, - "minValue": 0, - "maxValue": 255, - "defaultValue": 255, - "unsigned": true - }, - { - "#": "25[0xff00]", - "label": "Fan LED Effect Brightness", + "#": "24[0xff00]", + "label": "Light LED Effect Brightness", "valueSize": 4, "defaultValue": 3, "unsigned": true, @@ -835,49 +698,74 @@ ] }, { - "#": "25[0xff]", - "label": "Fan LED Effect Color", - "description": "Uses a scaled hue value (realHue / 360 * 255).", + "#": "24[0xff0000]", + "label": "Light LED Effect Duration", + "description": "0 = disabled, 1 to 60 = seconds, 61 to 120 = minutes (minus 60), 121 - 254 = hours (minus 120), 255 = indefinitely", "valueSize": 4, "minValue": 0, "maxValue": 255, + "defaultValue": 255, + "unsigned": true + }, + { + "#": "24[0x7f000000]", + "label": "Light LED Effect Type", + "valueSize": 4, "defaultValue": 0, "unsigned": true, + "allowManualEntry": false, "options": [ { - "label": "Red", + "label": "Off", "value": 0 }, { - "label": "Orange", - "value": 21 - }, - { - "label": "Yellow", - "value": 42 - }, - { - "label": "Green", - "value": 85 + "label": "Solid", + "value": 1 }, { - "label": "Cyan", - "value": 127 + "label": "Chase", + "value": 2 }, { - "label": "Blue", - "value": 170 + "label": "Fast blink", + "value": 3 }, { - "label": "Violet", - "value": 212 + "label": "Slow blink", + "value": 4 }, { - "label": "Pink", - "value": 234 + "label": "Pulse", + "value": 5 } ] }, + { + "#": "25", + "$import": "templates/inovelli_templates.json#bulk_set_led_effect", + "label": "Bulk Set Fan LED Effect" + }, + { + "#": "25[0xff]", + "label": "Fan LED Effect Color", + "$import": "#paramInformation/24[0xff]" + }, + { + "#": "25[0xff00]", + "label": "Fan LED Effect Brightness", + "$import": "#paramInformation/24[0xff00]" + }, + { + "#": "25[0xff0000]", + "label": "Fan LED Effect Duration", + "$import": "#paramInformation/24[0xff0000]" + }, + { + "#": "25[0x7f000000]", + "label": "Fan LED Effect Type", + "$import": "#paramInformation/24[0x7f000000]" + }, { "#": "26", "label": "Light LED Strip Timeout", diff --git a/packages/config/config/devices/0x031e/templates/inovelli_templates.json b/packages/config/config/devices/0x031e/templates/inovelli_templates.json index 5af3797d4fb3..84621a359b49 100644 --- a/packages/config/config/devices/0x031e/templates/inovelli_templates.json +++ b/packages/config/config/devices/0x031e/templates/inovelli_templates.json @@ -390,5 +390,14 @@ "value": 255 } ] + }, + "bulk_set_led_effect": { + "label": "Bulk Set LED Effect", + "valueSize": 4, + "minValue": 0, + "maxValue": 4294967296, + "defaultValue": 0, + "description": "Set the LED Effect using the sum of each individual effect parameter (color + (brightness * 256) + (duration * 65536) + (effect * 16777216))", + "unsigned": true } } diff --git a/packages/config/config/devices/0x031e/vzw31-sn.json b/packages/config/config/devices/0x031e/vzw31-sn.json index c9660a68ad74..f6a61436db37 100644 --- a/packages/config/config/devices/0x031e/vzw31-sn.json +++ b/packages/config/config/devices/0x031e/vzw31-sn.json @@ -589,6 +589,11 @@ "$import": "~/templates/master_template.json#base_0-100_nounit", "label": "Default All LED Strip Brightness When Off" }, + { + "#": "99", + "$import": "templates/inovelli_templates.json#bulk_set_led_effect", + "label": "Bulk Set LED Strip Effect" + }, { "#": "99[0xff]", "$import": "templates/inovelli_templates.json#led_effect_duration", From 7e7d01be97136fa158a4ac75a08cef26273181b3 Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Sun, 1 Dec 2024 23:51:52 -0600 Subject: [PATCH 2/6] Fix bad template link --- packages/config/config/devices/0x031e/lzw30-sn.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config/config/devices/0x031e/lzw30-sn.json b/packages/config/config/devices/0x031e/lzw30-sn.json index 8385976ae355..b02b766daba9 100644 --- a/packages/config/config/devices/0x031e/lzw30-sn.json +++ b/packages/config/config/devices/0x031e/lzw30-sn.json @@ -17,7 +17,7 @@ "paramInformation": [ { "#": "1", - "$import": "templates/inovelli_templates.json#state_after_power_failure_prev_on_off" + "$import": "~/templates/master_template.json#state_after_power_failure_prev_on_off" }, { "#": "2", From 0e993bf074fd9c6055a5549dcd210c4333f23547 Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Mon, 2 Dec 2024 00:03:43 -0600 Subject: [PATCH 3/6] Fix max val --- .../config/devices/0x031e/templates/inovelli_templates.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config/config/devices/0x031e/templates/inovelli_templates.json b/packages/config/config/devices/0x031e/templates/inovelli_templates.json index 84621a359b49..fc03de5c11b9 100644 --- a/packages/config/config/devices/0x031e/templates/inovelli_templates.json +++ b/packages/config/config/devices/0x031e/templates/inovelli_templates.json @@ -395,7 +395,7 @@ "label": "Bulk Set LED Effect", "valueSize": 4, "minValue": 0, - "maxValue": 4294967296, + "maxValue": 4294967295, "defaultValue": 0, "description": "Set the LED Effect using the sum of each individual effect parameter (color + (brightness * 256) + (duration * 65536) + (effect * 16777216))", "unsigned": true From d2c4667422147c1d0c00abfc576f9c6dd1806b85 Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Mon, 2 Dec 2024 00:28:14 -0600 Subject: [PATCH 4/6] Fix duplicate labels - test skip lint --- packages/config/config/devices/0x031e/lzw36.json | 16 ++++++++-------- .../0x031e/templates/inovelli_templates.json | 3 ++- packages/config/maintenance/lintConfigFiles.ts | 10 +++++++++- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/packages/config/config/devices/0x031e/lzw36.json b/packages/config/config/devices/0x031e/lzw36.json index 845d10ad751f..5337e208e536 100644 --- a/packages/config/config/devices/0x031e/lzw36.json +++ b/packages/config/config/devices/0x031e/lzw36.json @@ -748,23 +748,23 @@ }, { "#": "25[0xff]", - "label": "Fan LED Effect Color", - "$import": "#paramInformation/24[0xff]" + "$import": "#paramInformation/24[0xff]", + "label": "Fan LED Effect Color" }, { "#": "25[0xff00]", - "label": "Fan LED Effect Brightness", - "$import": "#paramInformation/24[0xff00]" + "$import": "#paramInformation/24[0xff00]", + "label": "Fan LED Effect Brightness" }, { "#": "25[0xff0000]", - "label": "Fan LED Effect Duration", - "$import": "#paramInformation/24[0xff0000]" + "$import": "#paramInformation/24[0xff0000]", + "label": "Fan LED Effect Duration" }, { "#": "25[0x7f000000]", - "label": "Fan LED Effect Type", - "$import": "#paramInformation/24[0x7f000000]" + "$import": "#paramInformation/24[0x7f000000]", + "label": "Fan LED Effect Type" }, { "#": "26", diff --git a/packages/config/config/devices/0x031e/templates/inovelli_templates.json b/packages/config/config/devices/0x031e/templates/inovelli_templates.json index fc03de5c11b9..645eabe5e7a6 100644 --- a/packages/config/config/devices/0x031e/templates/inovelli_templates.json +++ b/packages/config/config/devices/0x031e/templates/inovelli_templates.json @@ -398,6 +398,7 @@ "maxValue": 4294967295, "defaultValue": 0, "description": "Set the LED Effect using the sum of each individual effect parameter (color + (brightness * 256) + (duration * 65536) + (effect * 16777216))", - "unsigned": true + "unsigned": true, + "lintSkip": ["duplicatedPartials"] } } diff --git a/packages/config/maintenance/lintConfigFiles.ts b/packages/config/maintenance/lintConfigFiles.ts index ff4090e43851..3066452754b9 100644 --- a/packages/config/maintenance/lintConfigFiles.ts +++ b/packages/config/maintenance/lintConfigFiles.ts @@ -1048,7 +1048,15 @@ Consider converting this parameter to unsigned using ${ // Check if there are partial parameters and non-partials with the same number const duplicatedPartials = distinct( partialParams.map(([key]) => key.parameter), - ).filter((parameter) => paramInformation.has({ parameter })); + ).filter((parameter) => { + // Check if any parameter has the lintSkip flag for duplicatedPartials + const param = paramInformation.get({ parameter }); + if (param?.lintSkip?.includes("duplicatedPartials")) { + return false; + } + return paramInformation.has({ parameter }); + }); + if (duplicatedPartials.length) { addError( file, From 93c0c82dce1553250bc725c548e6ba179958282f Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Mon, 2 Dec 2024 01:35:57 -0600 Subject: [PATCH 5/6] Add lintSkip option --- packages/config/maintenance/lintConfigFiles.ts | 5 +++++ packages/config/src/devices/ParamInformation.ts | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/packages/config/maintenance/lintConfigFiles.ts b/packages/config/maintenance/lintConfigFiles.ts index 3066452754b9..18d4fa0ff5c1 100644 --- a/packages/config/maintenance/lintConfigFiles.ts +++ b/packages/config/maintenance/lintConfigFiles.ts @@ -1052,6 +1052,11 @@ Consider converting this parameter to unsigned using ${ // Check if any parameter has the lintSkip flag for duplicatedPartials const param = paramInformation.get({ parameter }); if (param?.lintSkip?.includes("duplicatedPartials")) { + addWarning( + file, + `Skipping "duplicatedPartials" lint check for parameter #${parameter} due to "lintSkip" configuration.`, + variant + ); return false; } return paramInformation.has({ parameter }); diff --git a/packages/config/src/devices/ParamInformation.ts b/packages/config/src/devices/ParamInformation.ts index 986cbb71eb30..a116eec4ca7b 100644 --- a/packages/config/src/devices/ParamInformation.ts +++ b/packages/config/src/devices/ParamInformation.ts @@ -164,6 +164,18 @@ Parameter #${parameterNumber}: allowManualEntry must be false or omitted!`, this.allowManualEntry = definition.allowManualEntry ?? (this.readOnly ? false : true); + if ( + definition.lintSkip != undefined + && (!isArray(definition.lintSkip) || !definition.lintSkip.every((rule: unknown) => typeof rule === "string")) + ) { + throwInvalidConfig( + "devices", + `packages/config/config/devices/${parent.filename}: +Parameter #${parameterNumber} has an invalid lintSkip property. It must be an array of strings.`, + ); + } + this.lintSkip = definition.lintSkip ?? []; + if ( isArray(definition.options) && !definition.options.every( @@ -200,6 +212,7 @@ Parameter #${parameterNumber}: options is malformed!`, public readonly readOnly?: true; public readonly writeOnly?: true; public readonly allowManualEntry: boolean; + public readonly lintSkip?: string[]; public readonly options: readonly ConditionalConfigOption[]; public readonly condition?: string; @@ -224,6 +237,7 @@ Parameter #${parameterNumber}: options is malformed!`, "readOnly", "writeOnly", "allowManualEntry", + "lintSkip", ]), options: evaluateDeep(this.options, deviceId, true), }; From 1391505ea473956d7c0eb57321c5724c2bd86fa7 Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Mon, 2 Dec 2024 01:48:11 -0600 Subject: [PATCH 6/6] yarn fmt --- packages/config/maintenance/lintConfigFiles.ts | 6 +++--- packages/config/src/devices/ParamInformation.ts | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/config/maintenance/lintConfigFiles.ts b/packages/config/maintenance/lintConfigFiles.ts index 18d4fa0ff5c1..9843d69f8cc7 100644 --- a/packages/config/maintenance/lintConfigFiles.ts +++ b/packages/config/maintenance/lintConfigFiles.ts @@ -1055,13 +1055,13 @@ Consider converting this parameter to unsigned using ${ addWarning( file, `Skipping "duplicatedPartials" lint check for parameter #${parameter} due to "lintSkip" configuration.`, - variant - ); + variant, + ); return false; } return paramInformation.has({ parameter }); }); - + if (duplicatedPartials.length) { addError( file, diff --git a/packages/config/src/devices/ParamInformation.ts b/packages/config/src/devices/ParamInformation.ts index a116eec4ca7b..25738d5df93a 100644 --- a/packages/config/src/devices/ParamInformation.ts +++ b/packages/config/src/devices/ParamInformation.ts @@ -166,7 +166,10 @@ Parameter #${parameterNumber}: allowManualEntry must be false or omitted!`, if ( definition.lintSkip != undefined - && (!isArray(definition.lintSkip) || !definition.lintSkip.every((rule: unknown) => typeof rule === "string")) + && (!isArray(definition.lintSkip) + || !definition.lintSkip.every((rule: unknown) => + typeof rule === "string" + )) ) { throwInvalidConfig( "devices",