Skip to content

Commit

Permalink
Fix alexa thermostat attribute parameters (#2364)
Browse files Browse the repository at this point in the history
Breakage introduced by #2194

Signed-off-by: jsetton <jeremy.setton@gmail.com>
  • Loading branch information
jsetton authored Feb 16, 2024
1 parent 02317ea commit 344779a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from './constants.js'
import {
docLink,
getGroupParameter,
getOptions,
getSemanticFormat,
getSupportedRange,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand All @@ -296,11 +291,7 @@ export default {
label: 'Setpoint Range',
description: 'Formatted as <code>minValue:maxValue</code>',
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: () => ({
Expand Down

0 comments on commit 344779a

Please sign in to comment.