From d7a62cc98166695c298b98360728203281373589 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 9 Nov 2021 00:26:12 -0500 Subject: [PATCH] Remove navigation attribute (#404) Signed-off-by: jsetton --- USAGE.md | 46 +--- lambda/alexa/smarthome/capabilities/index.js | 1 - .../capabilities/keypadController.js | 66 ------ lambda/alexa/smarthome/constants.js | 3 - .../smarthome/device/attributes/index.js | 1 - .../smarthome/device/attributes/navigation.js | 39 ---- .../smarthome/device/types/entertainment.js | 2 - lambda/alexa/smarthome/handlers/index.js | 1 - .../smarthome/handlers/keypadController.js | 75 ------- lambda/alexa/smarthome/properties/index.js | 1 - .../alexa/smarthome/properties/keystroke.js | 205 ------------------ .../cases/discovery/streamingDevice.test.js | 52 +---- lambda/test/alexa/cases/index.js | 1 - .../test/alexa/cases/keypadController.test.js | 93 -------- 14 files changed, 6 insertions(+), 580 deletions(-) delete mode 100644 lambda/alexa/smarthome/capabilities/keypadController.js delete mode 100644 lambda/alexa/smarthome/device/attributes/navigation.js delete mode 100644 lambda/alexa/smarthome/handlers/keypadController.js delete mode 100644 lambda/alexa/smarthome/properties/keystroke.js delete mode 100644 lambda/test/alexa/cases/keypadController.test.js diff --git a/USAGE.md b/USAGE.md index 09da9668..7a3297b1 100644 --- a/USAGE.md +++ b/USAGE.md @@ -81,7 +81,6 @@ The skill connects your openHAB setup through the [myopenHAB.org](http://myopenH * New security [arm state](#armstate) errors handling. * Support for [input](#input) custom mappings. * Support for [playback stop](#playbackstop) requests. - * Support for [onscreen navigation](#navigation) requests. * Support for [thermostat hold](#thermostathold) setting and [thermostat fan](#thermostatfan) mode. * Added new [custom asset ids](#custom-asset-catalog). * Added new [custom semantic extensions](#custom-semantic-catalog). @@ -245,7 +244,7 @@ Switch Oscillate "Oscillate" (Fan) {alexa="FanOscillate"} Switch Power "Power" (Fan) {alexa="PowerState"} ``` -A stereo with volume, mute, input, channel, playback, navigation, equalizer and power on/off controls. +A stereo with volume, mute, input, channel, playback, equalizer and power on/off controls. ```xtend Group Stereo "Stereo" {alexa="Speaker"} @@ -256,7 +255,6 @@ String Input "Input" (Stereo) {alexa="Input" [supportedInputs="HDMI1,TV"] String Channel "Channel" (Stereo) {alexa="Channel"} Player Playback "Playback" (Stereo) {alexa="Playback"} Switch Stop "Stop" (Stereo) {alexa="PlaybackStop"} -String Navigate "Navigate" (Stereo) {alexa="Navigation" [UP="up",DOWN="down",LEFT="left",RIGHT="right",SELECT="select"]} Number Bass "Bass" (Stereo) {alexa="EqualizerBass" [range="-10:10"]} Number Midrange "Mid" (Stereo) {alexa="EqualizerMidrange" [range="-10:10"]} Number Treble "Treble" (Stereo) {alexa="EqualizerTreble" [range="-10:10"]} @@ -503,7 +501,7 @@ Device Types | Supported Attributes | Description `Automobile` | [`BatteryLevel`](#batterylevel), [`FanSpeed`](#fanspeed), [`LockState`](#lockstate), [`PowerState`](#powerstate), [`CurrentTemperature`](#currenttemperature) | A motor vehicle (automobile, car). `AutomobileAccessory` | [`BatteryLevel`](#batterylevel), [`CameraStream`](#camerastream), [`FanSpeed`](#fanspeed), [`PowerState`](#powerstate) | A smart device in an automobile, such as a dash camera. `Blind`, `Curtain`, `Shade` | _[`OpenState`](#openstate)_, _[`PositionState`](#positionstate)_, [`TiltAngle`](#tiltAngle), [`TargetOpenState`](#targetopenstate), [`CurrentOpenState`](#currentopenstate) | A window covering on the inside of a structure. -`BluetoothSpeaker` | _[`PowerState`](#powerstate)_, _[`VolumeLevel`](#volumelevel)_, [`MuteState`](#mutestate), [`EqualizerBass`](#equalizerbass), [`EqualizerMidrange`](#equalizermidrange), [`EqualizerTreble`](#equalizertreble), [`EqualizerMode`](#equalizermode), [`Channel`](#channel), [`Input`](#input), [`Playback`](#playback), [`PlaybackStop`](#playbackstop), [`Navigation`](#navigation), [`BatteryLevel`](#batterylevel) | A speaker that connects to an audio source over Bluetooth. +`BluetoothSpeaker` | _[`PowerState`](#powerstate)_, _[`VolumeLevel`](#volumelevel)_, [`MuteState`](#mutestate), [`EqualizerBass`](#equalizerbass), [`EqualizerMidrange`](#equalizermidrange), [`EqualizerTreble`](#equalizertreble), [`EqualizerMode`](#equalizermode), [`Channel`](#channel), [`Input`](#input), [`Playback`](#playback), [`PlaybackStop`](#playbackstop), [`BatteryLevel`](#batterylevel) | A speaker that connects to an audio source over Bluetooth. `Camera` | _[`PowerState`](#powerstate)_, _[`CameraStream`](#camerastream)_, [`BatteryLevel`](#batterylevel) | A security device with video or photo functionality. `ChristmasTree` | Same as `Light` | A religious holiday decoration that often contains lights. `CoffeeMaker` | _[`PowerState`](#powerstate)_ | A device that makes coffee. @@ -536,11 +534,11 @@ Device Types | Supported Attributes | Description `SecuritySystem` | Same as `SecurityPanel` | A security system. `Shutter`, `Awning` | Same as `Blind` | A window covering on the outside of a structure. `SlowCooker` | _[`PowerState`](#powerstate)_ | An electric cooking device that sits on a countertop, cooks at low temperatures, and is often shaped like a cooking pot. -`Speaker` | _[`PowerState`](#powerstate)_, _[`VolumeLevel`](#volumelevel)_, [`MuteState`](#mutestate), [`EqualizerBass`](#equalizerbass), [`EqualizerMidrange`](#equalizermidrange), [`EqualizerTreble`](#equalizertreble), [`EqualizerMode`](#equalizermode), [`Channel`](#channel), [`Input`](#input), [`Playback`](#playback), [`PlaybackStop`](#playbackstop), [`Navigation`](#navigation) | A speaker or speaker system. -`StreamingDevice` | _[`PowerState`](#powerstate)_, _[`Playback`](#playback)_, [`PlaybackStop`](#playbackstop), [`Navigation`](#navigation), [`Channel`](#channel), [`Input`](#input), [`VolumeLevel`](#volumelevel), [`MuteState`](#mutestate), [`EqualizerBass`](#equalizerbass), [`EqualizerMidrange`](#equalizermidrange), [`EqualizerTreble`](#equalizertreble), [`EqualizerMode`](#equalizermode) | A streaming device such as Apple TV, Chromecast, or Roku. +`Speaker` | _[`PowerState`](#powerstate)_, _[`VolumeLevel`](#volumelevel)_, [`MuteState`](#mutestate), [`EqualizerBass`](#equalizerbass), [`EqualizerMidrange`](#equalizermidrange), [`EqualizerTreble`](#equalizertreble), [`EqualizerMode`](#equalizermode), [`Channel`](#channel), [`Input`](#input), [`Playback`](#playback), [`PlaybackStop`](#playbackstop) | A speaker or speaker system. +`StreamingDevice` | _[`PowerState`](#powerstate)_, _[`Playback`](#playback)_, [`PlaybackStop`](#playbackstop), [`Channel`](#channel), [`Input`](#input), [`VolumeLevel`](#volumelevel), [`MuteState`](#mutestate), [`EqualizerBass`](#equalizerbass), [`EqualizerMidrange`](#equalizermidrange), [`EqualizerTreble`](#equalizertreble), [`EqualizerMode`](#equalizermode) | A streaming device such as Apple TV, Chromecast, or Roku. `Switch` | _[`PowerState`](#powerstate)_, _[`PowerLevel`](#powerlevel)_, _[`Percentage`](#percentage)_ | A switch wired directly to the electrical system. A switch can control a variety of devices. For lighting devices, use `Light` instead. `Tablet` | _[`PowerState`](#powerstate)_, [`BatteryLevel`](#batterylevel), [`NetworkAccess`](#networkaccess) | A tablet computer. -`Television` | _[`PowerState`](#powerstate)_, _[`Channel`](#channel)_, [`Input`](#input), [`VolumeLevel`](#volumelevel), [`MuteState`](#mutestate), [`EqualizerBass`](#equalizerbass), [`EqualizerMidrange`](#equalizermidrange), [`EqualizerTreble`](#equalizertreble), [`EqualizerMode`](#equalizermode), [`Playback`](#playback), [`PlaybackStop`](#playbackstop), [`Navigation`](#navigation) | A television. +`Television` | _[`PowerState`](#powerstate)_, _[`Channel`](#channel)_, [`Input`](#input), [`VolumeLevel`](#volumelevel), [`MuteState`](#mutestate), [`EqualizerBass`](#equalizerbass), [`EqualizerMidrange`](#equalizermidrange), [`EqualizerTreble`](#equalizertreble), [`EqualizerMode`](#equalizermode), [`Playback`](#playback), [`PlaybackStop`](#playbackstop) | A television. `TemperatureSensor` | _[`CurrentTemperature`](#currenttemperature)_, [`BatteryLevel`](#batterylevel) | An endpoint that reports temperature, but does not control it. The temperature data of the endpoint doesn't appear in the Alexa app. If your endpoint also controls temperature, use `Thermostat` instead. `Thermostat` | _[`HeatingCoolingMode`](#heatingcoolingmode)_, [`TargetTemperature`](#targettemperature), [`CoolingSetpoint`](#coolingsetpoint), [`HeatingSetpoint`](#heatingsetpoint), [`EcoCoolingSetpoint`](#ecocoolingsetpoint), [`EcoHeatingSetpoint`](#ecoheatingsetpoint), [`ThermostatHold`](#thermostathold), [`ThermostatFan`](#thermostatfan), [`CurrentTemperature`](#currenttemperature), [`CurrentHumidity`](#currenthumidity), [`BatteryLevel`](#batterylevel) | An endpoint that controls temperature, stand-alone air conditioners, or heaters with direct temperature control. If your endpoint senses temperature but does not control it, use `TemperatureSensor` instead. `VacuumCleaner` | _[`PowerState`](#powerstate)_, _[`VacuumMode`](#vacuummode)_, [`FanSpeed`](#fanspeed), [`BatteryLevel`](#batterylevel) | A vacuum cleaner. @@ -921,39 +919,6 @@ Items that represent the playback stop command of a AV device. This needs to be * Utterance examples: * *Alexa, stop ``.* -#### `Navigation` - -Items that represent the onscreen navigation of a AV device. - -* Supported item types: - * String [UP="up", DOWN="down", LEFT="left", RIGHT="right", SELECT="select", PAGE_UP="pageup", PAGE_DOWN="pagedown", PAGE_LEFT="pageleft", PAGE_RIGHT="pageright", INFO="info", MORE="more", BACK="back"] -* Supported metadata parameters: - * UP=`` - * DOWN=`` - * LEFT=`` - * RIGHT=`` - * SELECT=`` - * PAGE_UP=`` - * PAGE_DOWN=`` - * PAGE_LEFT=`` - * PAGE_RIGHT=`` - * INFO=`` - * MORE=`` - * BACK=`` - * supportedKeys=`` - * comma delimited list (e.g. `supportedKeys="UP,DOWN,LEFT,RIGHT,SELECT"`) - * supported keys are UP, DOWN, LEFT, RIGHT, SELECT, PAGE_UP, PAGE_DOWN, PAGE_LEFT, PAGE_RIGHT, INFO, MORE, BACK - * defaults to, depending on the parameters provided, either user-based or item type-based default mappings. -* Utterance examples: - * *Alexa, go left on ``.* - * *Alexa, move down on ``.* - * *Alexa, scroll right on ``.* - * *Alexa, page up on ``.* - * *Alexa, select this on ``.* - * *Alexa, navigate back on ``.* - * *Alexa, show details on ``.* - * *Alexa, show info on ``.* - ### Fan Attributes #### `FanSpeed` @@ -1923,7 +1888,6 @@ ColorController | [`Color`](#color) | `de-DE`, `en-AU`, `en-CA`, `en-GB`, `en-IN ColorTemperatureController | [`ColorTemperature`](#colortemperature) | `de-DE`, `en-AU`, `en-CA`, `en-GB`, `en-IN`, `en-US`, `es-ES`, `fr-FR`, `hi-IN`, `it-IT`, `ja-JP`, `pt-BR` ContactSensor | [`ContactDetectionState`](#contactdetectionstate) | `de-DE`, `en-AU`, `en-CA`, `en-IN`, `en-US`, `es-ES`, `it-IT`, `ja-JP` EqualizerController | [`EqualizerBass`](#equalizerbass), [`EqualizerMidrange`](#equalizermidrange), [`EqualizerTreble`](#equalizertreble), [`EqualizerMode`](#equalizermode) | `de-DE`, `en-IN`, `en-US`, `es-ES`, `it-IT`, `ja-JP`, `pt-BR` -KeypadController | [`Navigation`](#navigation) | `en-GB`, `en-US`, `es-MX` LockController | [`LockState`](#lockstate) | `de-DE`, `en-AU`, `en-CA`, `en-GB`, `en-IN`, `en-US`, `es-ES`, `es-MX`, `es-US`, `fr-CA`, `fr-FR`, `hi-IN`, `it-IT`, `ja-JP`, `pt_BR` ModeController | [`Mode`](#mode), [`FanDirection`](#fandirection), [`FanSpeed`](#fanspeed), [`Input`](#input), [`OpenState`](#openstate), [`PositionState`](#positionstate), [`TiltAngle`](#tiltangle), [`ThermostatFan`](#thermostatfan), [`VacuumMode`](#vacuummode) | `de-DE`, `en-AU`, `en-CA`, `en-GB`, `en-IN`, `en-US`, `es-ES`, `es-MX`, `fr-CA`, `fr-FR`, `it-IT`, `ja-JP` MotionSensor | [`MotionDetectionState`](#motiondetectionstate) | `de-DE`, `en-AU`, `en-CA`, `en-IN`, `en-US`, `es-ES`, `it-IT`, `ja-JP`, `pt-BR` diff --git a/lambda/alexa/smarthome/capabilities/index.js b/lambda/alexa/smarthome/capabilities/index.js index c12dc9cb..b60fdc9a 100644 --- a/lambda/alexa/smarthome/capabilities/index.js +++ b/lambda/alexa/smarthome/capabilities/index.js @@ -28,7 +28,6 @@ module.exports = { [Capability.ENDPOINT_HEALTH]: require('./endpointHealth'), [Capability.EQUALIZER_CONTROLLER]: require('./equalizerController'), [Capability.INPUT_CONTROLLER]: require('./inputController'), - [Capability.KEYPAD_CONTROLLER]: require('./keypadController'), [Capability.LOCK_CONTROLLER]: require('./lockController'), [Capability.MODE_CONTROLLER]: require('./modeController'), [Capability.MOTION_SENSOR]: require('./motionSensor'), diff --git a/lambda/alexa/smarthome/capabilities/keypadController.js b/lambda/alexa/smarthome/capabilities/keypadController.js deleted file mode 100644 index 4d90eed8..00000000 --- a/lambda/alexa/smarthome/capabilities/keypadController.js +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2010-2021 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ - -const AlexaCapability = require('./capability'); -const AlexaDisplayCategory = require('../category'); -const { Interface, Property } = require('../constants'); -const { Keystroke } = require('../properties'); - -/** - * Defines Alexa.KeypadController interface capability class - * https://developer.amazon.com/docs/device-apis/alexa-keypadcontroller.html - * @extends AlexaCapability - */ -class KeypadController extends AlexaCapability { - /** - * Returns interface - * @return {String} - */ - get interface() { - return Interface.ALEXA_KEYPAD_CONTROLLER; - } - - /** - * Returns supported properties - * @return {Object} - */ - get supportedProperties() { - return { - [Property.KEYSTROKE]: Keystroke - }; - } - - /** - * Returns default display categories - * @return {Array} - */ - get defaultDisplayCategories() { - return [AlexaDisplayCategory.STREAMING_DEVICE]; - } - - /** - * Returns alexa interface - * @return {Object} - */ - getAlexaInterface() { - // Get capability interface from parent method - const capability = super.getAlexaInterface(); - const { supportedKeys } = this.getProperty({ name: Property.KEYSTROKE }); - - capability.keys = supportedKeys; - - return capability; - } -} - -module.exports = KeypadController; diff --git a/lambda/alexa/smarthome/constants.js b/lambda/alexa/smarthome/constants.js index aaef718b..5659972f 100644 --- a/lambda/alexa/smarthome/constants.js +++ b/lambda/alexa/smarthome/constants.js @@ -26,7 +26,6 @@ const Capability = Object.freeze({ ENDPOINT_HEALTH: 'EndpointHealth', EQUALIZER_CONTROLLER: 'EqualizerController', INPUT_CONTROLLER: 'InputController', - KEYPAD_CONTROLLER: 'KeypadController', LOCK_CONTROLLER: 'LockController', MODE_CONTROLLER: 'ModeController', MOTION_SENSOR: 'MotionSensor', @@ -65,7 +64,6 @@ const Interface = Object.freeze({ ALEXA_ENDPOINT_HEALTH: 'Alexa.EndpointHealth', ALEXA_EQUALIZER_CONTROLLER: 'Alexa.EqualizerController', ALEXA_INPUT_CONTROLLER: 'Alexa.InputController', - ALEXA_KEYPAD_CONTROLLER: 'Alexa.KeypadController', ALEXA_LOCK_CONTROLLER: 'Alexa.LockController', ALEXA_MODE_CONTROLLER: 'Alexa.ModeController', ALEXA_MOTION_SENSOR: 'Alexa.MotionSensor', @@ -108,7 +106,6 @@ const Property = Object.freeze({ EQUALIZER_MODE: 'mode', FIRE_ALARM: 'fireAlarm', INPUT: 'input', - KEYSTROKE: 'keystroke', LOCK_STATE: 'lockState', LOWER_SETPOINT: 'lowerSetpoint', MODE: 'mode', diff --git a/lambda/alexa/smarthome/device/attributes/index.js b/lambda/alexa/smarthome/device/attributes/index.js index 1e1b2fd5..e075a367 100644 --- a/lambda/alexa/smarthome/device/attributes/index.js +++ b/lambda/alexa/smarthome/device/attributes/index.js @@ -48,7 +48,6 @@ module.exports = { Mode: require('./mode'), MotionDetectionState: require('./motionDetectionState'), MuteState: require('./muteState'), - Navigation: require('./navigation'), NetworkAccess: require('./networkAccess'), ObstacleAlert: require('./obstacleAlert'), OpenState: require('./openState'), diff --git a/lambda/alexa/smarthome/device/attributes/navigation.js b/lambda/alexa/smarthome/device/attributes/navigation.js deleted file mode 100644 index 37761b31..00000000 --- a/lambda/alexa/smarthome/device/attributes/navigation.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2010-2021 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ - -const { Capability, Property } = require('@alexa/smarthome/constants'); -const DeviceAttribute = require('./attribute'); - -/** - * Defines navigation attribute class - * @extends DeviceAttribute - */ -class Navigation extends DeviceAttribute { - /** - * Returns supported names - * @return {Array} - */ - static get supportedNames() { - return ['Navigation']; - } - - /** - * Returns capabilities - * @return {Array} - */ - static getCapabilities() { - return [{ name: Capability.KEYPAD_CONTROLLER, property: Property.KEYSTROKE }]; - } -} - -module.exports = Navigation; diff --git a/lambda/alexa/smarthome/device/types/entertainment.js b/lambda/alexa/smarthome/device/types/entertainment.js index f4be49b5..ed3e6613 100644 --- a/lambda/alexa/smarthome/device/types/entertainment.js +++ b/lambda/alexa/smarthome/device/types/entertainment.js @@ -19,7 +19,6 @@ const { Input, Playback, PlaybackStop, - Navigation, EqualizerBass, EqualizerMidrange, EqualizerTreble, @@ -43,7 +42,6 @@ class Entertainment extends GenericDevice { Input, Playback, PlaybackStop, - Navigation, EqualizerBass, EqualizerMidrange, EqualizerTreble, diff --git a/lambda/alexa/smarthome/handlers/index.js b/lambda/alexa/smarthome/handlers/index.js index d3a536be..e4c85224 100644 --- a/lambda/alexa/smarthome/handlers/index.js +++ b/lambda/alexa/smarthome/handlers/index.js @@ -26,7 +26,6 @@ module.exports = { Discovery: require('./discovery'), EqualizerController: require('./equalizerController'), InputController: require('./inputController'), - KeypadController: require('./keypadController'), LockController: require('./lockController'), ModeController: require('./modeController'), NetworkingAccessController: require('./networkingAccessController'), diff --git a/lambda/alexa/smarthome/handlers/keypadController.js b/lambda/alexa/smarthome/handlers/keypadController.js deleted file mode 100644 index 21a59492..00000000 --- a/lambda/alexa/smarthome/handlers/keypadController.js +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2010-2021 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ - -const { Interface, Property } = require('../constants'); -const { InvalidValueError } = require('../errors'); -const AlexaHandler = require('./handler'); - -/** - * Defines Alexa.KeypadController interface handler class - * https://developer.amazon.com/docs/device-apis/alexa-keypadcontroller.html#directives - * @extends AlexaHandler - */ -class KeypadController extends AlexaHandler { - /** - * Defines send keystroke directive - * @type {String} - */ - static SEND_KEYSTROKE = 'SendKeystroke'; - - /** - * Defines handler namespace - * @return {String} - */ - static get namespace() { - return Interface.ALEXA_KEYPAD_CONTROLLER; - } - - /** - * Defines handler supported directives - * @return {Object} - */ - static get directives() { - return { - [KeypadController.SEND_KEYSTROKE]: this.sendKeystroke - }; - } - - /** - * Sends keystroke - * @param {Object} directive - * @param {Object} openhab - * @return {Promise} - */ - static async sendKeystroke(directive, openhab) { - const property = directive.endpoint.getCapabilityProperty({ - interface: directive.namespace, - property: Property.KEYSTROKE - }); - const { item, supportedKeys } = property; - const keystroke = directive.payload.keystroke; - - // Throw invalid value error if requested keystroke not supported - if (!supportedKeys.includes(keystroke)) { - throw new InvalidValueError(`${item.name} doesn't support keystroke [${keystroke}]`); - } - - const command = property.getCommand(keystroke); - - await openhab.sendCommand(item.name, command); - - return directive.response(); - } -} - -module.exports = KeypadController; diff --git a/lambda/alexa/smarthome/properties/index.js b/lambda/alexa/smarthome/properties/index.js index cc6edb76..b1f7c263 100644 --- a/lambda/alexa/smarthome/properties/index.js +++ b/lambda/alexa/smarthome/properties/index.js @@ -33,7 +33,6 @@ module.exports = { EqualizerMode: require('./equalizerMode'), Generic: require('./generic'), Input: require('./input'), - Keystroke: require('./keystroke'), LockState: require('./lockState'), LowerSetpoint: require('./lowerSetpoint'), Mode: require('./mode'), diff --git a/lambda/alexa/smarthome/properties/keystroke.js b/lambda/alexa/smarthome/properties/keystroke.js deleted file mode 100644 index 2b7bfc0d..00000000 --- a/lambda/alexa/smarthome/properties/keystroke.js +++ /dev/null @@ -1,205 +0,0 @@ -/** - * Copyright (c) 2010-2021 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ - -const { ItemType } = require('@openhab/constants'); -const { Parameter, ParameterType } = require('../metadata'); -const AlexaProperty = require('./property'); - -/** - * Defines keystroke property class - * @extends AlexaProperty - */ -class Keystroke extends AlexaProperty { - /** - * Defines up keystroke - * @type {String} - */ - static UP = 'UP'; - - /** - * Defines down keystroke - * @type {String} - */ - static DOWN = 'DOWN'; - - /** - * Defines left keystroke - * @type {String} - */ - static LEFT = 'LEFT'; - - /** - * Defines right keystroke - * @type {String} - */ - static RIGHT = 'RIGHT'; - - /** - * Defines select keystroke - * @type {String} - */ - static SELECT = 'SELECT'; - - /** - * Defines page up keystroke - * @type {String} - */ - static PAGE_UP = 'PAGE_UP'; - - /** - * Defines page down keystroke - * @type {String} - */ - static PAGE_DOWN = 'PAGE_DOWN'; - - /** - * Defines page left keystroke - * @type {String} - */ - static PAGE_LEFT = 'PAGE_LEFT'; - - /** - * Defines page right keystroke - * @type {String} - */ - static PAGE_RIGHT = 'PAGE_RIGHT'; - - /** - * Defines info keystroke - * @type {String} - */ - static INFO = 'INFO'; - - /** - * Defines more keystroke - * @type {String} - */ - static MORE = 'MORE'; - - /** - * Defines back keystroke - * @type {String} - */ - static BACK = 'BACK'; - - /** - * Returns supported item types - * @return {Array} - */ - get supportedItemTypes() { - return [ItemType.STRING]; - } - - /** - * Returns supported parameters and their type - * @return {Object} - */ - get supportedParameters() { - return { - [Parameter.SUPPORTED_KEYS]: ParameterType.LIST - }; - } - - /** - * Returns supported values - * https://developer.amazon.com/docs/device-apis/alexa-keypadcontroller.html#keystroke-property - * @return {Array} - */ - get supportedValues() { - return [ - Keystroke.UP, - Keystroke.DOWN, - Keystroke.LEFT, - Keystroke.RIGHT, - Keystroke.SELECT, - Keystroke.PAGE_UP, - Keystroke.PAGE_DOWN, - Keystroke.PAGE_LEFT, - Keystroke.PAGE_RIGHT, - Keystroke.INFO, - Keystroke.MORE, - Keystroke.BACK - ]; - } - - /** - * Returns if is reportable - * @return {Boolean} - */ - get isReportable() { - return false; - } - - /** - * Returns if is valid - * @return {Boolean} - */ - get isValid() { - return this.supportedKeys.length > 0; - } - - /** - * Returns default value map - * @return {Object} - */ - get defaultValueMap() { - return { - [Keystroke.UP]: 'up', - [Keystroke.DOWN]: 'down', - [Keystroke.LEFT]: 'left', - [Keystroke.RIGHT]: 'right', - [Keystroke.SELECT]: 'select', - [Keystroke.PAGE_UP]: 'pageup', - [Keystroke.PAGE_DOWN]: 'pagedown', - [Keystroke.PAGE_LEFT]: 'pageleft', - [Keystroke.PAGE_RIGHT]: 'pageright', - [Keystroke.INFO]: 'info', - [Keystroke.MORE]: 'more', - [Keystroke.BACK]: 'back' - }; - } - - /** - * Returns default keys based on value map - * @return {Array} - */ - get defaultKeys() { - return Object.keys(this.valueMap); - } - - /** - * Returns supported keys based on parameter - * @return {Array} - */ - get supportedKeys() { - return this.parameters[Parameter.SUPPORTED_KEYS] || this.defaultKeys; - } - - /** - * Updates parameters - * @param {Object} item - * @param {Object} metadata - * @param {Object} settings - */ - updateParameters(item, metadata, settings) { - const parameters = this.parameters; - // Update parameters from parent method - super.updateParameters(item, metadata, settings); - - const keys = parameters[Parameter.SUPPORTED_KEYS]; - // Update supported keys parameter removing unsupported values if defined - parameters[Parameter.SUPPORTED_KEYS] = keys && keys.filter((value) => this.supportedValues.includes(value)); - } -} - -module.exports = Keystroke; diff --git a/lambda/test/alexa/cases/discovery/streamingDevice.test.js b/lambda/test/alexa/cases/discovery/streamingDevice.test.js index b6151ad5..dcfb5475 100644 --- a/lambda/test/alexa/cases/discovery/streamingDevice.test.js +++ b/lambda/test/alexa/cases/discovery/streamingDevice.test.js @@ -24,18 +24,6 @@ module.exports = { } }, members: [ - { - type: 'String', - name: 'navigation1', - metadata: { - alexa: { - value: 'Navigation', - config: { - supportedKeys: 'UP,DOWN,LEFT,RIGHT,SELECT,FOOBAR' - } - } - } - }, { type: 'Player', name: 'playback1', @@ -82,16 +70,6 @@ module.exports = { } } }, - { - type: 'String', - name: 'navigation3', - label: 'Streaming Device Navigation 3', - metadata: { - alexa: { - value: 'Navigation' - } - } - }, { type: 'Player', name: 'playback3', @@ -105,20 +83,13 @@ module.exports = { ], expected: { gStreamingDevice1: { - capabilities: ['Alexa.KeypadController', 'Alexa.PlaybackController', 'Alexa'], + capabilities: ['Alexa.PlaybackController', 'Alexa'], displayCategories: ['STREAMING_DEVICE'], friendlyName: 'Streaming Device 1', parameters: { - 'Alexa.KeypadController.keys': ['UP', 'DOWN', 'LEFT', 'RIGHT', 'SELECT'], 'Alexa.PlaybackController.supportedOperations': ['Play', 'Pause', 'Next', 'Previous', 'Stop'] }, cookie: [ - { - name: 'KeypadController', - property: 'keystroke', - parameters: { supportedKeys: ['UP', 'DOWN', 'LEFT', 'RIGHT', 'SELECT'] }, - item: { name: 'navigation1', type: 'String' } - }, { name: 'PlaybackController', property: 'playback', @@ -132,27 +103,6 @@ module.exports = { displayCategories: ['STREAMING_DEVICE'], friendlyName: 'Streaming Device 2' }, - navigation3: { - capabilities: ['Alexa.KeypadController', 'Alexa'], - displayCategories: ['STREAMING_DEVICE'], - friendlyName: 'Streaming Device Navigation 3', - parameters: { - 'Alexa.KeypadController.keys': [ - 'UP', - 'DOWN', - 'LEFT', - 'RIGHT', - 'SELECT', - 'PAGE_UP', - 'PAGE_DOWN', - 'PAGE_LEFT', - 'PAGE_RIGHT', - 'INFO', - 'MORE', - 'BACK' - ] - } - }, playback3: { capabilities: ['Alexa.PlaybackController', 'Alexa'], displayCategories: ['STREAMING_DEVICE'], diff --git a/lambda/test/alexa/cases/index.js b/lambda/test/alexa/cases/index.js index 62a77327..eafad383 100644 --- a/lambda/test/alexa/cases/index.js +++ b/lambda/test/alexa/cases/index.js @@ -76,7 +76,6 @@ module.exports = { ], EqualizerController: [require('./equalizerController.test.js')], InputController: [require('./inputController.test.js')], - KeypadController: [require('./keypadController.test.js')], LockController: [require('./lockController.test.js')], ModeController: [require('./modeController.test.js')], NetworkingAccessController: [require('./networkingAccessController.test.js')], diff --git a/lambda/test/alexa/cases/keypadController.test.js b/lambda/test/alexa/cases/keypadController.test.js deleted file mode 100644 index a97cbe1f..00000000 --- a/lambda/test/alexa/cases/keypadController.test.js +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Copyright (c) 2010-2021 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ - -module.exports = [ - { - description: 'send keystroke', - directive: { - header: { - namespace: 'Alexa.KeypadController', - name: 'SendKeystroke' - }, - endpoint: { - endpointId: 'tvNavigation', - cookie: { - capabilities: JSON.stringify([ - { - name: 'KeypadController', - property: 'keystroke', - parameters: { supportedKeys: ['UP', 'DOWN', 'LEFT', 'RIGHT', 'SELECT'] }, - item: { name: 'tvNavigation', type: 'String' } - } - ]) - } - }, - payload: { - keystroke: 'SELECT' - } - }, - expected: { - alexa: { - context: { - properties: [] - }, - event: { - header: { - namespace: 'Alexa', - name: 'Response' - } - } - }, - openhab: [{ name: 'tvNavigation', value: 'select' }] - } - }, - { - description: 'send keystroke invalid value error', - directive: { - header: { - namespace: 'Alexa.KeypadController', - name: 'SendKeystroke' - }, - endpoint: { - endpointId: 'tvNavigation', - cookie: { - capabilities: JSON.stringify([ - { - name: 'KeypadController', - property: 'keystroke', - parameters: { supportedKeys: ['UP', 'DOWN', 'LEFT', 'RIGHT', 'SELECT'] }, - item: { name: 'tvNavigation', type: 'String' } - } - ]) - } - }, - payload: { - keystroke: 'INFO' - } - }, - expected: { - alexa: { - event: { - header: { - namespace: 'Alexa', - name: 'ErrorResponse' - }, - payload: { - type: 'INVALID_VALUE', - message: "tvNavigation doesn't support keystroke [INFO]" - } - } - } - } - } -];