diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/deviceattributes.js b/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/deviceattributes.js index 7df9dca9de..056dedeb16 100644 --- a/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/deviceattributes.js +++ b/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/deviceattributes.js @@ -309,7 +309,7 @@ export default { }, CurrentTemperature: { itemTypes: ['Number', 'Number:Temperature'], - parameters: (item) => [p.scale(item)] + parameters: (_, item) => [p.scale(item)] }, ContactDetectionState: { itemTypes: ['Contact', 'Switch'], @@ -343,27 +343,27 @@ export default { // Thermostat Attributes TargetTemperature: { itemTypes: ['Number', 'Number:Temperature'], - parameters: (item) => [p.scale(item), p.setpointRange(item), p.retrievable()] + parameters: (_, item) => [p.scale(item), p.setpointRange(item), p.retrievable()] }, CoolingSetpoint: { itemTypes: ['Number', 'Number:Temperature'], requires: ['HeatingSetpoint'], - parameters: (item) => [p.scale(item), p.comfortRange(item), p.setpointRange(item), p.retrievable()] + parameters: (_, item) => [p.scale(item), p.comfortRange(item), p.setpointRange(item), p.retrievable()] }, HeatingSetpoint: { itemTypes: ['Number', 'Number:Temperature'], requires: ['CoolingSetpoint'], - parameters: (item) => [p.scale(item), p.comfortRange(item), p.setpointRange(item), p.retrievable()] + parameters: (_, item) => [p.scale(item), p.comfortRange(item), p.setpointRange(item), p.retrievable()] }, EcoCoolingSetpoint: { itemTypes: ['Number', 'Number:Temperature'], requires: ['EcoHeatingSetpoint'], - parameters: (item) => [p.scale(item), p.comfortRange(item), p.setpointRange(item), p.retrievable()] + parameters: (_, item) => [p.scale(item), p.comfortRange(item), p.setpointRange(item), p.retrievable()] }, EcoHeatingSetpoint: { itemTypes: ['Number', 'Number:Temperature'], requires: ['EcoCoolingSetpoint'], - parameters: (item) => [p.scale(item), p.comfortRange(item), p.setpointRange(item), p.retrievable()] + parameters: (_, item) => [p.scale(item), p.comfortRange(item), p.setpointRange(item), p.retrievable()] }, HeatingCoolingMode: { itemTypes: ['Number', 'String', 'Switch'], diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/helpers.js b/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/helpers.js index 119e3d865c..20b1bb8b7e 100644 --- a/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/helpers.js +++ b/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/helpers.js @@ -53,6 +53,8 @@ export const getSupportedRange = (item, config, defaultValue) => { } export const getTemperatureScale = (item) => { + const scale = getGroupParameter('scale', item.groups) + if (scale) return scale const itemType = item.groupType || item.type const format = (itemType === 'Number:Temperature' && item.unitSymbol) || item.stateDescription?.pattern if (format?.endsWith('°C')) return 'CELSIUS' 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 5153406f11..72c782bbdd 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 @@ -10,7 +10,6 @@ import { } from './constants.js' import { docLink, - getGroupParameter, getOptions, getSemanticFormat, getSupportedRange, @@ -106,11 +105,7 @@ export default { label: 'Comfort Range', type: 'INTEGER', min: 1, - default: (config) => { - const scale = config.scale || getGroupParameter('scale', item.groups) || getTemperatureScale(item) - if (scale === 'CELSIUS') return 1 - if (scale === 'FAHRENHEIT') return 2 - } + default: (config) => (config.scale || getTemperatureScale(item)) === 'FAHRENHEIT' ? 2 : 1 }), connectedTo: (value) => ({ name: 'connectedTo', @@ -286,7 +281,7 @@ export default { name: 'scale', label: 'Scale', type: 'TEXT', - default: getGroupParameter('scale', item.groups) || getTemperatureScale(item), + default: getTemperatureScale(item) === 'FAHRENHEIT' ? 'FAHRENHEIT' : 'CELSIUS', options: getOptions(TEMPERATURE_SCALES), limitToOptions: true, advanced @@ -296,11 +291,7 @@ export default { label: 'Setpoint Range', description: 'Formatted as minValue:maxValue', type: 'TEXT', - default: (config) => { - const scale = config.scale || getGroupParameter('scale', item.groups) || getTemperatureScale(item) - if (scale === 'CELSIUS') return '4:32' - if (scale === 'FAHRENHEIT') return '40:90' - }, + default: (config) => (config.scale || getTemperatureScale(item)) === 'FAHRENHEIT' ? '40:90' : '4:32', pattern: '[+-]?[0-9]+:[+-]?[0-9]+' }), speedLevels: () => ({