Skip to content

Commit

Permalink
Update alexa blind and channel attributes
Browse files Browse the repository at this point in the history
Signed-off-by: jsetton <[email protected]>
  • Loading branch information
jsetton committed Dec 3, 2021
1 parent 51a6d6a commit a3089be
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -96,6 +96,7 @@ export default {
'FanSpeed',
'LockState',
'PowerState',
'TargetTemperature',
'CurrentTemperature',
...genericAttributes
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -36,14 +38,29 @@ export default {
multiple: true,
required: !defaultValue
}),
channelMappings: () => ({
channelMappings: (stateDescription) => ({
name: 'channelMappings',
label: 'Channel Mappings',
description: 'Each mapping formatted as <code>channelName=channelNumber<code>',
description: 'Each mapping formatted as <code>channelNumber=channelName<code>',
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 <code>minValue:maxValue</code>',
type: 'TEXT',
default: '1:9999',
pattern: '[0-9]+:[0-9]+',
advanced: true
}),
colorTemperatureBinding: () => ({
name: 'binding',
label: 'Binding/Device Type',
Expand All @@ -69,7 +86,7 @@ export default {
colorTemperatureRange: () => ({
name: 'range',
label: 'Temperature Range in Kelvin',
description: 'Formatted as <code>minRange:maxRange</code>',
description: 'Formatted as <code>minValue:maxValue</code>',
type: 'TEXT',
default: '1000:10000',
pattern: '[0-9]+:[0-9]+',
Expand Down Expand Up @@ -122,7 +139,7 @@ export default {
equalizerRange: (defaultValue) => ({
name: 'range',
label: 'Equalizer Range',
description: 'Formatted as <code>minRange:maxRange</code>',
description: 'Formatted as <code>minValue:maxValue</code>',
type: 'TEXT',
default: defaultValue,
pattern: '[+-]?[0-9]+:[+-]?[0-9]+'
Expand Down Expand Up @@ -196,7 +213,7 @@ export default {
multiple: true,
advanced: true
}),
presets: (stateDescription, placeholder, advanced = false) => ({
presets: (stateDescription, placeholder) => ({
name: 'presets',
label: 'Presets',
description:
Expand All @@ -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',
Expand Down Expand Up @@ -257,7 +273,7 @@ export default {
setpointRange: (item) => ({
name: 'setpointRange',
label: 'Setpoint Range',
description: 'Formatted as <code>minRange:maxRange</code>',
description: 'Formatted as <code>minValue:maxValue</code>',
type: 'TEXT',
default: (config) => {
const scale = config.scale || getGroupParameter('scale', item.groups) || getTemperatureScale(item)
Expand Down

0 comments on commit a3089be

Please sign in to comment.