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 62764d3db9..739d84dee5 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 @@ -45,23 +45,52 @@ export default { itemTypes: ['Dimmer', 'Rollershutter'], parameters: (item) => [ p.inverted(item.type === 'Rollershutter'), - p.presets(item.stateDescription, '20=Morning,60=Afternoon,80=Evening:@Setting.Night', true), - p.language(item.settings && item.settings.regional.language) + p.presets(item.stateDescription, '20=Morning,60=Afternoon,80=Evening:@Setting.Night'), + p.language(item.settings && item.settings.regional.language), + p.actionMappings( + { default: 'value' }, + 'Close=0,Open=100,Lower=0,Raise=100', + (config) => { + if (item.type === 'Dimmer') { + return config.inverted === true + ? ['Close=100', 'Open=0', 'Lower=100', 'Raise=0'] + : ['Close=0', 'Open=100', 'Lower=0', 'Raise=100'] + } + if (item.type === 'Rollershutter') { + return ['Close=DOWN', 'Open=UP', 'Lower=DOWN', 'Raise=UP', 'Stop=STOP'] + } + } + ) ] }, TiltAngle: { itemTypes: ['Dimmer', 'Number', 'Number:Angle', 'Rollershutter'], parameters: (item) => [ p.inverted(item.type === 'Rollershutter'), - p.presets(item.stateDescription, '20=Morning,60=Afternoon,80=Evening:@Setting.Night', true), - p.language(item.settings && item.settings.regional.language) + p.presets(item.stateDescription, '20=Morning,60=Afternoon,80=Evening:@Setting.Night'), + p.language(item.settings && item.settings.regional.language), + p.actionMappings( + { default: 'value' }, + 'Close=0,Open=100', + (config) => { + if (item.type === 'Dimmer') { + return config.inverted === true ? ['Close=100', 'Open=0'] : ['Close=0', 'Open=100'] + } + if (item.type === 'Number' || item.type === 'Number:Angle') { + return config.inverted === true ? ['Close=90', 'Open=0'] : ['Close=-90', 'Open=0'] + } + if (item.type === 'Rollershutter') { + return ['Close=DOWN', 'Open=UP', 'Stop=STOP'] + } + } + ) ] }, // Entertainment Attributes Channel: { itemTypes: ['Number', 'String'], - parameters: () => [p.channelMappings(), p.retrievable()] + parameters: (item) => [p.channelMappings(item.stateDescription), p.channelRange(), p.retrievable()] }, Input: { itemTypes: ['Number', 'String'], diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/devicetypes.js b/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/devicetypes.js index bfb1bf39e9..13e08f63de 100644 --- a/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/devicetypes.js +++ b/bundles/org.openhab.ui/web/src/assets/definitions/metadata/alexa/devicetypes.js @@ -79,8 +79,8 @@ export default { supportsGroup: false }, AirConditioner: { - defaultAttributes: ['HeatingCoolingMode'], - supportedAttributes: ['HeatingCoolingMode', 'TargetTemperature', 'CurrentTemperature', ...fanAttributes] + defaultAttributes: ['PowerState'], + supportedAttributes: ['PowerState', 'TargetTemperature', 'CurrentTemperature', ...fanAttributes] }, AirFreshener: { defaultAttributes: ['FanSpeed'], @@ -96,6 +96,7 @@ export default { 'FanSpeed', 'LockState', 'PowerState', + 'TargetTemperature', 'CurrentTemperature', ...genericAttributes ] 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 381c0ff7bf..0a4f8582a9 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 @@ -18,13 +18,15 @@ import { } from './helpers.js' export default { - actionMappings: (format, placeholder) => ({ + actionMappings: (format, placeholder, defaultValue) => ({ name: 'actionMappings', label: 'Action Mappings', description: `Each mapping formatted as ${getSemanticFormat('action', format)} (${docLink('Semantic Extensions')})`, type: 'TEXT', + default: defaultValue, placeholder: placeholder.replace(/,/g, '\n'), - multiple: true + multiple: true, + advanced: !!defaultValue }), capabilityNames: (defaultValue, placeholder) => ({ name: 'capabilityNames', @@ -36,14 +38,29 @@ export default { multiple: true, required: !defaultValue }), - channelMappings: () => ({ + channelMappings: (stateDescription) => ({ name: 'channelMappings', label: 'Channel Mappings', - description: 'Each mapping formatted as channelName=channelNumber', + description: 'Each mapping formatted as channelNumber=channelName', type: 'TEXT', - placeholder: 'CBS=2\nNBC=4\nABC=7\nPBS=13', + default: + stateDescription && + stateDescription.options && + stateDescription.options + .filter((option) => !isNaN(option.value)) + .map((option) => `${option.value}=${option.label}`), + placeholder: '2=CBS\n4=NBC\n7=ABC\n13=PBS', multiple: true }), + channelRange: () => ({ + name: 'range', + label: 'Channel Range', + description: 'Formatted as minValue:maxValue', + type: 'TEXT', + default: '1:9999', + pattern: '[0-9]+:[0-9]+', + advanced: true + }), colorTemperatureBinding: () => ({ name: 'binding', label: 'Binding/Device Type', @@ -69,7 +86,7 @@ export default { colorTemperatureRange: () => ({ name: 'range', label: 'Temperature Range in Kelvin', - description: 'Formatted as minRange:maxRange', + description: 'Formatted as minValue:maxValue', type: 'TEXT', default: '1000:10000', pattern: '[0-9]+:[0-9]+', @@ -122,7 +139,7 @@ export default { equalizerRange: (defaultValue) => ({ name: 'range', label: 'Equalizer Range', - description: 'Formatted as minRange:maxRange', + description: 'Formatted as minValue:maxValue', type: 'TEXT', default: defaultValue, pattern: '[+-]?[0-9]+:[+-]?[0-9]+' @@ -196,7 +213,7 @@ export default { multiple: true, advanced: true }), - presets: (stateDescription, placeholder, advanced = false) => ({ + presets: (stateDescription, placeholder) => ({ name: 'presets', label: 'Presets', description: @@ -210,8 +227,7 @@ export default { .filter((option) => !isNaN(option.value)) .map((option) => `${option.value}=${option.label}`), placeholder: placeholder.replace(/,/g, '\n'), - multiple: true, - advanced + multiple: true }), primaryControl: () => ({ name: 'primaryControl', @@ -257,7 +273,7 @@ export default { setpointRange: (item) => ({ name: 'setpointRange', label: 'Setpoint Range', - description: 'Formatted as minRange:maxRange', + description: 'Formatted as minValue:maxValue', type: 'TEXT', default: (config) => { const scale = config.scale || getGroupParameter('scale', item.groups) || getTemperatureScale(item)