Skip to content

Commit

Permalink
Fix alexa power state default attribute (#1461)
Browse files Browse the repository at this point in the history
Signed-off-by: jsetton <jeremy.setton@gmail.com>
  • Loading branch information
jsetton authored Aug 4, 2022
1 parent f222794 commit c9d912d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ export default {

// Switchable Attributes
PowerState: {
itemTypes: ['Color', 'Dimmer', 'Number', 'String', 'Switch'],
itemTypes: ['Color', 'Dimmer', 'Switch'],
customTypes: ['Number', 'String'],
parameters: (item) => [
...(item.type === 'Number' || item.type === 'String'
? [p.valueMapping('OFF', true), p.valueMapping('ON', true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ export default {
supportedAttributes: ['TargetTemperature', 'CurrentTemperature', ...fanAttributes]
},
AirFreshener: {
defaultAttributes: ['FanSpeed'],
defaultAttributes: ['PowerState', 'FanSpeed'],
supportedAttributes: fanAttributes
},
AirPurifier: {
defaultAttributes: ['FanSpeed'],
defaultAttributes: ['PowerState', 'FanSpeed'],
supportedAttributes: fanAttributes
},
Automobile: {
Expand Down Expand Up @@ -118,11 +118,11 @@ export default {
groupParameters: blindParameters
},
BluetoothSpeaker: {
defaultAttributes: ['VolumeLevel'],
defaultAttributes: ['PowerState', 'VolumeLevel'],
supportedAttributes: ['BatteryLevel', ...entertainmentAttributes]
},
Camera: {
defaultAttributes: ['CameraStream'],
defaultAttributes: ['PowerState', 'CameraStream'],
supportedAttributes: cameraAttributes
},
ChristmasTree: {
Expand Down Expand Up @@ -156,15 +156,15 @@ export default {
supportedAttributes: doorAttributes
},
Doorbell: {
defaultAttributes: ['CameraStream'],
defaultAttributes: ['PowerState', 'CameraStream'],
supportedAttributes: cameraAttributes
},
Dryer: {
defaultAttributes: ['PowerState'],
supportedAttributes: genericDeviceAttributes
},
Fan: {
defaultAttributes: ['FanSpeed'],
defaultAttributes: ['PowerState', 'FanSpeed'],
supportedAttributes: fanAttributes
},
GameConsole: {
Expand All @@ -177,7 +177,7 @@ export default {
supportedAttributes: ['ObstacleAlert', ...doorAttributes]
},
Headphones: {
defaultAttributes: ['VolumeLevel'],
defaultAttributes: ['PowerState', 'VolumeLevel'],
supportedAttributes: ['BatteryLevel', ...entertainmentAttributes]
},
Hub: {
Expand Down Expand Up @@ -211,7 +211,7 @@ export default {
supportedAttributes: ['MotionDetectionState', ...sensorAttributes]
},
MusicSystem: {
defaultAttributes: ['Playback'],
defaultAttributes: ['PowerState', 'Playback'],
supportedAttributes: entertainmentAttributes
},
NetworkHardware: {
Expand Down Expand Up @@ -243,7 +243,7 @@ export default {
supportsGroup: false
},
Screen: {
defaultAttributes: ['PowerState'],
defaultAttributes: ['PowerState', 'Channel'],
supportedAttributes: entertainmentAttributes
},
SecurityPanel: {
Expand All @@ -269,11 +269,11 @@ export default {
supportedAttributes: genericDeviceAttributes
},
Speaker: {
defaultAttributes: ['VolumeLevel'],
defaultAttributes: ['PowerState', 'VolumeLevel'],
supportedAttributes: entertainmentAttributes
},
StreamingDevice: {
defaultAttributes: ['Playback'],
defaultAttributes: ['PowerState', 'Playback'],
supportedAttributes: entertainmentAttributes
},
Switch: {
Expand All @@ -286,7 +286,7 @@ export default {
groupParameters: networkParameters
},
Television: {
defaultAttributes: ['Channel'],
defaultAttributes: ['PowerState', 'Channel'],
supportedAttributes: entertainmentAttributes
},
TemperatureSensor: {
Expand All @@ -299,7 +299,7 @@ export default {
groupParameters: (item) => [p.scale(item, true)]
},
VacuumCleaner: {
defaultAttributes: ['VacuumMode'],
defaultAttributes: ['PowerState', 'VacuumMode'],
supportedAttributes: ['VacuumMode', 'FanSpeed', 'BatteryLevel', ...genericDeviceAttributes]
},
Washer: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ for (const type of Object.keys(deviceTypes)) {
}

for (const attribute of supportedAttributes) {
const { itemTypes = [], parameters = [], ...properties } = deviceAttributes[attribute]
const { itemTypes = [], customTypes = [], parameters = [], ...properties } = deviceAttributes[attribute]
classes[`${type}.${attribute}`] = {}
for (const itemType of itemTypes) {
for (const itemType of [...itemTypes, ...customTypes]) {
classes[`${type}.${attribute}`][itemType] = { parameters: [defaultParameters].concat(parameters), ...properties }
}
}
Expand Down

0 comments on commit c9d912d

Please sign in to comment.