From d915c8aec96a1959b8b97b161ac9c7dd74224e47 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 4 Jan 2023 19:31:39 -0500 Subject: [PATCH] Limit alexa parameter state description options (#1621) Signed-off-by: jsetton --- .../assets/definitions/metadata/alexa/constants.js | 2 ++ .../assets/definitions/metadata/alexa/parameters.js | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/constants.js b/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/constants.js index 0bfb11ae1d..d54b02c1b0 100644 --- a/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/constants.js +++ b/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/constants.js @@ -26,6 +26,8 @@ export const PLAYBACK_OPERATIONS = ['Play', 'Pause', 'Previous', 'Next', 'Rewind export const PLAYBACK_STEPS = ['PLAY', 'PAUSE', 'STOP', 'START_OVER', 'PREVIOUS', 'NEXT', 'REWIND', 'FAST_FORWARD'] +export const STATE_DESCRIPTION_OPTIONS_LIMIT = 150 + export const TEMPERATURE_SCALES = ['CELSIUS', 'FAHRENHEIT'] export const THERMOSTAT_MODES = ['OFF', 'HEAT', 'COOL', 'ECO', 'AUTO'] diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/parameters.js b/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/parameters.js index 716a4b3978..cfbfe10b02 100644 --- a/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/parameters.js +++ b/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/parameters.js @@ -3,6 +3,7 @@ import { EQUALIZER_MODES, LANGUAGES, PLAYBACK_OPERATIONS, + STATE_DESCRIPTION_OPTIONS_LIMIT, TEMPERATURE_SCALES, THERMOSTAT_MODES, UNITS_OF_MEASURE @@ -232,7 +233,8 @@ export default { stateDescription.options && stateDescription.options .filter((option) => !isNaN(option.value)) - .map((option) => `${option.value}=${option.label}`), + .map((option) => `${option.value}=${option.label}`) + .slice(0, STATE_DESCRIPTION_OPTIONS_LIMIT), placeholder: placeholder.replace(/,/g, '\n'), multiple: true }), @@ -356,7 +358,9 @@ export default { default: stateDescription && stateDescription.options && - stateDescription.options.map((option) => `${option.value}=${option.label}`), + stateDescription.options + .map((option) => `${option.value}=${option.label}`) + .slice(0, STATE_DESCRIPTION_OPTIONS_LIMIT), placeholder: placeholder.replace(/,/g, '\n'), multiple: true, required: !stateDescription || !stateDescription.options || !stateDescription.options.length @@ -370,7 +374,9 @@ export default { default: stateDescription && stateDescription.options && - stateDescription.options.map((option) => `${option.value}=${option.label}`), + stateDescription.options + .map((option) => `${option.value}=${option.label}`) + .slice(0, STATE_DESCRIPTION_OPTIONS_LIMIT), placeholder: 'Normal=Normal:Cottons\nWhites=Whites', multiple: true, required: !stateDescription || !stateDescription.options || !stateDescription.options.length