From f11901652d1de12a0de26ecff707e9a6c9203cbd Mon Sep 17 00:00:00 2001 From: jsetton Date: Tue, 27 Feb 2024 13:10:38 -0500 Subject: [PATCH] Remove deprecated networking capabilities Signed-off-by: jsetton --- README.md | 2 +- docs/USAGE.md | 80 +------- .../smarthome/capabilities/capability.js | 2 +- lambda/alexa/smarthome/capabilities/index.js | 3 - .../networkingAccessController.js | 65 ------ .../capabilities/networkingConnectedDevice.js | 75 ------- .../networkingHomeNetworkController.js | 38 ---- lambda/alexa/smarthome/catalog.js | 2 +- lambda/alexa/smarthome/constants.js | 11 - .../smarthome/device/attributes/index.js | 1 - .../device/attributes/networkAccess.js | 37 ---- .../alexa/smarthome/device/types/computer.js | 6 +- .../smarthome/device/types/gameConsole.js | 6 +- .../smarthome/device/types/mobileDevice.js | 6 +- .../smarthome/device/types/networkDevice.js | 38 ---- .../smarthome/device/types/networkHardware.js | 9 - lambda/alexa/smarthome/endpoint.js | 15 +- lambda/alexa/smarthome/handlers/discovery.js | 3 +- lambda/alexa/smarthome/handlers/index.js | 1 - .../handlers/networkingAccessController.js | 64 ------ lambda/alexa/smarthome/metadata.js | 6 +- .../smarthome/properties/connectedDevice.js | 118 ----------- lambda/alexa/smarthome/properties/index.js | 2 - .../smarthome/properties/networkAccess.js | 49 ----- lambda/alexa/smarthome/properties/property.js | 5 +- .../alexa/cases/discovery/computer.test.js | 110 +--------- .../test/alexa/cases/discovery/router.test.js | 1 - lambda/test/alexa/cases/index.js | 2 - .../cases/networkingAccessController.test.js | 193 ------------------ lambda/test/utils.test.js | 24 +-- lambda/utils.js | 9 - 31 files changed, 38 insertions(+), 945 deletions(-) delete mode 100644 lambda/alexa/smarthome/capabilities/networkingAccessController.js delete mode 100644 lambda/alexa/smarthome/capabilities/networkingConnectedDevice.js delete mode 100644 lambda/alexa/smarthome/capabilities/networkingHomeNetworkController.js delete mode 100644 lambda/alexa/smarthome/device/attributes/networkAccess.js delete mode 100644 lambda/alexa/smarthome/device/types/networkDevice.js delete mode 100644 lambda/alexa/smarthome/handlers/networkingAccessController.js delete mode 100644 lambda/alexa/smarthome/properties/connectedDevice.js delete mode 100644 lambda/alexa/smarthome/properties/networkAccess.js delete mode 100644 lambda/test/alexa/cases/networkingAccessController.test.js diff --git a/README.md b/README.md index 83c9ab22..a494b8c6 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ To configure your server path and credentials, you will need to setup the CloudF ``` 2. If updating from ASK CLI v1: - 1. Copy relevant settings from `lambda/smarthome/config.js` (ask-cli-v1) to [`ask-resources.json`](ask-resources.json) (ask-cli-v2). If configuring `OpenHABBaseURL`, be aware that it should now point to your server root level and not the rest endpoint. Additionally, move your client certificate to `lambda/ssl` if using that authentication method. + 1. Copy relevant settings from `lambda/smarthome/config.js` (ask-cli-v1) to [`ask-resources.json`](ask-resources.json) (ask-cli-v2). If configuring `OpenHABBaseURL`, beware that it should now point to your server root level and not the rest endpoint. Additionally, move your client certificate to `lambda/ssl` if using that authentication method. 2. Create the ASK CLI states file as `.ask/ask-states.json`, adding the skill ID listed in your [Alexa developer console](https://developer.amazon.com/alexa/console/ask). This will prevent duplicate skills from being created in your account. diff --git a/docs/USAGE.md b/docs/USAGE.md index cf61623a..ddd44bde 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -27,7 +27,6 @@ The skill connects your openHAB setup through the [myopenHAB.org](http://myopenH * [Group Endpoint](#group-endpoint) * [Item State](#item-state) * [Item Unit of Measurement](#item-unit-of-measurement) - * [Networking Capabilities](#networking-capabilities) * [Generic Capabilities](#generic-capabilities) * [Semantic Extensions](#semantic-extensions) * [Item Configuration](#item-configuration) @@ -53,7 +52,6 @@ The skill connects your openHAB setup through the [myopenHAB.org](http://myopenH * [Camera](#camera-attributes) * [Door/Window Covering](#cover-attributes) * [Fan](#fan-attributes) - * [Networking](#networking-attributes) * [Vacuum](#vacuum-attributes) * Updated existing capabilities: * New security [arm state](#armstate) errors handling. @@ -312,22 +310,6 @@ Number:Temperature Temperature2 "Temperature" {alexa="CurrentTemperatu Number:Temperature Temperature3 "Temperature" {alexa="CurrentTemperature"} ``` -## Networking Capabilities - -To interact with the networking capabilities of a router, such as controlling the network access for a specific device, the [networking attributes](#networking-attributes) are available to configure a representation of a home network and its connected devices. - -In order to take advantage of these capabilities, your router must be configured as a [group endpoint](#group-endpoint) based on [`HomeNetwork`](#homenetwork) supported device types. If it doesn't have any other capabilities, it can be an empty group. Likewise, connected devices must be configured based on [`ConnectedDevice`](#connecteddevice) supported device types and metadata parameters. - -```xtend -Group Router "Router" {alexa="Router"} - -Group Laptop "Laptop" (Router) {alexa="Laptop" [macAddress="00:21:86:B5:6E:10"]} -Switch Access1 "Access" (Laptop) {alexa="NetworkAccess"} - -Group Tablet "Tablet" (Router) {alexa="Tablet" [macAddress="00:21:86:B5:6E:11"]} -Switch Access2 "Access" (Tablet) {alexa="NetworkAccess"} -``` - ## Generic Capabilities @@ -520,22 +502,22 @@ Device Types | Supported Attributes | Description `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. -`Computer` | *[`PowerState`](#powerstate)*, [`NetworkAccess`](#networkaccess) | A non-mobile computer, such as a desktop computer. +`Computer` | *[`PowerState`](#powerstate)* | A non-mobile computer, such as a desktop computer. `ContactSensor` | *[`ContactDetectionState`](#contactdetectionstate)*, [`BatteryLevel`](#batterylevel) | An endpoint that detects and reports changes in contact between two surfaces. `Dishwasher` | *[`PowerState`](#powerstate)* | A device that cleans dishes. `Door` | *[`OpenState`](#openstate)*, [`TargetOpenState`](#targetopenstate), [`CurrentOpenState`](#currentopenstate) | A door. `Doorbell` | Same as `Camera` | A doorbell. `Dryer` | *[`PowerState`](#powerstate)* | A device that dries wet clothing. `Fan` | *[`PowerState`](#powerstate)*, *[`FanSpeed`](#fanspeed)*, [`FanDirection`](#fandirection), [`FanOscillate`](#fanoscillate) | A fan. -`GameConsole` | *[`PowerState`](#powerstate)*, [`NetworkAccess`](#networkaccess) | A game console, such as Microsoft Xbox or Nintendo Switch. +`GameConsole` | *[`PowerState`](#powerstate)* | A game console, such as Microsoft Xbox or Nintendo Switch. `GarageDoor` | *[`OpenState`](#openstate)*, [`TargetOpenState`](#targetopenstate), [`CurrentOpenState`](#currentopenstate), [`ObstacleAlert`](#obstaclealert) | A garage door. Supports unlock by voice code. Only supported in `de-DE`, `en-GB`, `en-US`, `es-ES`, `fr-FR`, and `it-IT`. For other languages, use `Door` instead. `Headphones` | Same as `BluetoothSpeaker` | A wearable device that transmits audio directly into the ear. `Hub` | *[`PowerState`](#powerstate)* | A smart-home hub. -`Laptop` | *[`PowerState`](#powerstate)*, [`BatteryLevel`](#batterylevel), [`NetworkAccess`](#networkaccess) | A laptop or other mobile computer. +`Laptop` | *[`PowerState`](#powerstate)*, [`BatteryLevel`](#batterylevel) | A laptop or other mobile computer. `Light` | *[`PowerState`](#powerstate)*, *[`Brightness`](#brightness)*, *[`Color`](#color)*, [`ColorTemperature`](#colortemperature) | A light source or fixture. `Lock` | *[`LockState`](#lockstate)*, [`TargetLockState`](#targetlockstate), [`CurrentLockState`](#currentlockstate), [`BatteryLevel`](#batterylevel) | An endpoint that locks. `Microwave` | *[`PowerState`](#powerstate)* | A microwave oven. -`MobilePhone` | *[`PowerState`](#powerstate)*, [`BatteryLevel`](#batterylevel), [`NetworkAccess`](#networkaccess) | A mobile phone. +`MobilePhone` | *[`PowerState`](#powerstate)*, [`BatteryLevel`](#batterylevel) | A mobile phone. `MotionSensor` | *[`MotionDetectionState`](#motiondetectionstate)*, [`BatteryLevel`](#batterylevel) | An endpoint that detects and reports movement in an area. `MusicSystem` | Same as `StreamingDevice` | A network-connected music system. `NetworkHardware` | *[`PowerState`](#powerstate)* | A network router. @@ -553,15 +535,15 @@ Device Types | Supported Attributes | Description `Speaker` | *[`PowerState`](#powerstate)*, *[`VolumeLevel`](#volumelevel)*, [`VolumeStep`](#volumestep), [`MuteState`](#mutestate), [`MuteStep`](#mutestep), [`EqualizerBass`](#equalizerbass), [`EqualizerMidrange`](#equalizermidrange), [`EqualizerTreble`](#equalizertreble), [`EqualizerMode`](#equalizermode), [`Channel`](#channel), [`ChannelStep`](#channelstep), [`Input`](#input), [`Playback`](#playback), [`PlaybackStop`](#playbackstop), [`PlaybackStep`](#playbackstep) | A speaker or speaker system. `StreamingDevice` | *[`PowerState`](#powerstate)*, *[`Playback`](#playback)*, [`PlaybackStop`](#playbackstop), [`PlaybackStep`](#playbackstep), [`Channel`](#channel), [`ChannelStep`](#channelstep), [`Input`](#input), [`VolumeLevel`](#volumelevel), [`VolumeStep`](#volumestep), [`MuteState`](#mutestate), [`MuteStep`](#mutestep), [`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. +`Tablet` | *[`PowerState`](#powerstate)*, [`BatteryLevel`](#batterylevel) | A tablet computer. `Television` | *[`PowerState`](#powerstate)*, *[`Channel`](#channel)*, [`ChannelStep`](#channelstep), [`Input`](#input), [`VolumeLevel`](#volumelevel), [`VolumeStep`](#volumestep), [`MuteState`](#mutestate), [`MuteStep`](#mutestep), [`EqualizerBass`](#equalizerbass), [`EqualizerMidrange`](#equalizermidrange), [`EqualizerTreble`](#equalizertreble), [`EqualizerMode`](#equalizermode), [`Playback`](#playback), [`PlaybackStop`](#playbackstop), [`PlaybackStep`](#playbackstep) | 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. `Washer` | *[`PowerState`](#powerstate)* | A device that cleans clothing. `WaterHeater` | *[`PowerState`](#powerstate)*, [`TargetTemperature`](#targettemperature), [`CurrentTemperature`](#currenttemperature) | A device that heats water, often consisting of a large tank. -`Wearable`| *[`PowerState`](#powerstate)*, [`BatteryLevel`](#batterylevel), [`NetworkAccess`](#networkaccess) | A network-connected wearable device, such as an Apple Watch, Fitbit, or Samsung Gear. -`Other`| [All attributes](#device-attributes), except [networking](#networking-attributes) and [scenes](#scene-attributes) | An endpoint that doesn't belong to one of the other categories. +`Wearable`| *[`PowerState`](#powerstate)*, [`BatteryLevel`](#batterylevel) | A network-connected wearable device, such as an Apple Watch, Fitbit, or Samsung Gear. +`Other`| [All attributes](#device-attributes), except [scenes](#scene-attributes) | An endpoint that doesn't belong to one of the other categories. ## Device Attributes @@ -1148,51 +1130,6 @@ Items that represents a color temperature. It is important to note that temperat * *Alexa, make the `` whiter.* * *Alexa, set the `` cooler.* -### Networking Attributes - -#### `HomeNetwork` - -Items that represent a network router. This attribute cannot be specified by name. It is automatically added when configuring a [group endpoint](#group-endpoint) as one of the supported [device types](#device-types). - -* Supported device types: - * `NetworkHardware` - * `Router` - -#### `ConnectedDevice` - -Items that represent a network device, such as a computer or mobile phone, connected to a router. This attribute cannot be specified by name. It is automatically added when configuring a [group endpoint](#group-endpoint) as one of the supported [device types](#device-types), that is a member of the group representing the router, as [`HomeNetwork`](#homenetwork), where the device is connected to, and having at least the metadata parameter `macAddress` defined. - -* Supported device types: - * `Computer` - * `GameConsole` - * `Laptop` - * `MobilePhone` - * `Tablet` - * `Wearable` -* Supported metadata parameters: - * hostname=`` - * defaults to `N/A` - * macAddress=`
` - * formatted as EUI-48 or EUI-64 address with colon or dash separators (e.g. `macAddress="00:21:86:B5:6E:10"`) - -#### `NetworkAccess` - -Items that represent the internet/network access control of a Wi-Fi/Ethernet connection to a router. This needs to be paired with [`ConnectedDevice`](#connecteddevice). To enable the access control by voice, you will need to select the configured device in your Alexa app, by going to Devices > Wi-Fi Access > Add a device. To limit the control based on voice profiles, turn on the option in the Wi-Fi Access settings. - -* Supported item types: - * Switch [ALLOWED="ON", BLOCKED="OFF"] -* Supported metadata parameters: - * inverted=`` - * set to true to invert item state - * defaults to false -* Utterance examples: - * *Alexa, pause the Internet for ``.* - * *Alexa, resume the Wi-Fi for ``.* - * *Alexa, enable the Internet for ``.* - * *Alexa, disable the Wi-Fi for ``.* - * *Alexa, turn on the Internet for ``.* - * *Alexa, turn off the Wi-Fi for ``.* - ### Scene Attributes @@ -1959,7 +1896,7 @@ Items that represent components of a device that can be toggled on or off. Multi * Alexa will respond with "Sorry something wrong, to control *device* try disabling the skill and re-enabling it from your Alexa app". * It indicates that Alexa isn't able to control the given device because of an authentication issue. -* To resolve this error, for users that are using the official skill, just disable and re-enable it through the Alexa app. For users that have setup their own custom skill, make sure that the proper credentials were configured in `ask-resources.json`. If running an openHAB 3.x server, make sure that the API Security Implicit User Role setting is enabled. +* To resolve this error, for users that are using the official skill, just disable and re-enable it through the Alexa app. For users that have setup their own custom skill, make sure that the proper credentials were configured in `ask-resources.json`. For openHAB 3.0 and above, make sure that the API Security Implicit User Role setting is enabled. ### Server Not Accessible @@ -1992,7 +1929,6 @@ EqualizerController | [`EqualizerBass`](#equalizerbass), [`EqualizerMidrange`](# LockController | [`LockState`](#lockstate) | `ar-SA`, `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`, `es-US`, `fr-CA`, `fr-FR`, `hi-IN`, `it-IT`, `ja-JP`, `pt-BR` MotionSensor | [`MotionDetectionState`](#motiondetectionstate) | `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` -Networking | [`HomeNetwork`](#homenetwork), [`ConnectedDevice`](#connecteddevice), [`NetworkAccess`](#networkaccess) | `en-US` PercentageController | [`Percentage`](#percentage) | `de-DE`, `en-AU`, `en-CA`, `en-GB`, `en-IN`, `en-US`, `es-ES`, `es-US`, `fr-CA`, `fr-FR`, `hi-IN`, `it-IT`, `ja-JP`, `pt-BR` PlaybackController | [`Playback`](#playback), [`PlaybackStop`](#playbackstop), [`PlaybackStep`](#playbackstep) | `ar-SA`, `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` PlaybackStateReporter | [`Playback`](#playback), [`PlaybackStop`](#playbackstop) | `ar-SA`, `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` diff --git a/lambda/alexa/smarthome/capabilities/capability.js b/lambda/alexa/smarthome/capabilities/capability.js index d2a1f238..8e301ccb 100644 --- a/lambda/alexa/smarthome/capabilities/capability.js +++ b/lambda/alexa/smarthome/capabilities/capability.js @@ -248,7 +248,7 @@ export default class AlexaCapability { /** * Adds property for a given config object - * @param {Object} config [name, component, tag, parameters, item, metadata, settings, groups] + * @param {Object} config [name, component, tag, parameters, item, metadata, settings] */ addProperty(config) { const { name } = config; diff --git a/lambda/alexa/smarthome/capabilities/index.js b/lambda/alexa/smarthome/capabilities/index.js index cf2b5720..2b88f626 100644 --- a/lambda/alexa/smarthome/capabilities/index.js +++ b/lambda/alexa/smarthome/capabilities/index.js @@ -27,9 +27,6 @@ export { default as InputController } from './inputController.js'; export { default as LockController } from './lockController.js'; export { default as ModeController } from './modeController.js'; export { default as MotionSensor } from './motionSensor.js'; -export { default as NetworkingAccessController } from './networkingAccessController.js'; -export { default as NetworkingConnectedDevice } from './networkingConnectedDevice.js'; -export { default as NetworkingHomeNetworkController } from './networkingHomeNetworkController.js'; export { default as PercentageController } from './percentageController.js'; export { default as PlaybackController } from './playbackController.js'; export { default as PlaybackStateReporter } from './playbackStateReporter.js'; diff --git a/lambda/alexa/smarthome/capabilities/networkingAccessController.js b/lambda/alexa/smarthome/capabilities/networkingAccessController.js deleted file mode 100644 index 05d448c4..00000000 --- a/lambda/alexa/smarthome/capabilities/networkingAccessController.js +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (c) 2010-2024 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 - */ - -import AlexaCapability from './capability.js'; -import { Capability, Interface, Property } from '../constants.js'; -import { NetworkAccess } from '../properties/index.js'; - -/** - * Defines Alexa.Networking.AccessController interface capability class - * https://developer.amazon.com/docs/networking/alexa-networking-accesscontroller.html - * @extends AlexaCapability - */ -export default class NetworkingAccessController extends AlexaCapability { - /** - * Returns name - * @return {String} - */ - static get name() { - return Capability.NETWORKING_ACCESS_CONTROLLER; - } - - /** - * Returns interface - * @return {String} - */ - get interface() { - return Interface.ALEXA_NETWORKING_ACCESS_CONTROLLER; - } - - /** - * Returns supported properties - * @return {Object} - */ - get supportedProperties() { - return { - [Property.NETWORK_ACCESS]: NetworkAccess - }; - } - - /** - * Returns required linked capabilities - * @return {Array} - */ - get requiredLinkedCapabilities() { - return [{ name: Capability.NETWORKING_CONNECTED_DEVICE, property: Property.CONNECTED_DEVICE }]; - } - - /** - * Returns capability configuration - * @return {Object} - */ - getCapabilityConfiguration() { - return { supportsScheduling: false }; - } -} diff --git a/lambda/alexa/smarthome/capabilities/networkingConnectedDevice.js b/lambda/alexa/smarthome/capabilities/networkingConnectedDevice.js deleted file mode 100644 index 46e85a69..00000000 --- a/lambda/alexa/smarthome/capabilities/networkingConnectedDevice.js +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2010-2024 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 - */ - -import AlexaCapability from './capability.js'; -import { Capability, Interface, Property } from '../constants.js'; -import { ConnectedDevice } from '../properties/index.js'; - -/** - * Defines Alexa.Networking.ConnectedDevice interface capability class - * https://developer.amazon.com/docs/networking/alexa-networking-connecteddevice.html - * @extends AlexaCapability - */ -export default class NetworkingConnectedDevice extends AlexaCapability { - /** - * Returns name - * @return {String} - */ - static get name() { - return Capability.NETWORKING_CONNECTED_DEVICE; - } - - /** - * Returns interface - * @return {String} - */ - get interface() { - return Interface.ALEXA_NETWORKING_CONNECTED_DEVICE; - } - - /** - * Returns supported properties - * @return {Object} - */ - get supportedProperties() { - return { - [Property.CONNECTED_DEVICE]: ConnectedDevice - }; - } - - /** - * Returns capability configuration - * @return {Object} - */ - getCapabilityConfiguration() { - const configuration = {}; - const { deviceName, hostname, macAddress } = this.getProperty({ name: Property.CONNECTED_DEVICE }); - - configuration.staticDeviceInformation = { deviceName, hostname, macAddress }; - - return configuration; - } - - /** - * Returns relationship - * @return {Object} - */ - getRelationship() { - const relationship = {}; - const { connectedTo: endpointId } = this.getProperty({ name: Property.CONNECTED_DEVICE }); - - relationship.isConnectedBy = { endpointId }; - - return relationship; - } -} diff --git a/lambda/alexa/smarthome/capabilities/networkingHomeNetworkController.js b/lambda/alexa/smarthome/capabilities/networkingHomeNetworkController.js deleted file mode 100644 index 3a9a42db..00000000 --- a/lambda/alexa/smarthome/capabilities/networkingHomeNetworkController.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2010-2024 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 - */ - -import AlexaCapability from './capability.js'; -import { Capability, Interface } from '../constants.js'; - -/** - * Defines Alexa.Networking.HomeNetworkController interface capability class - * https://developer.amazon.com/docs/networking/alexa-networking-homenetworkcontroller.html - * @extends AlexaCapability - */ -export default class NetworkingHomeNetworkController extends AlexaCapability { - /** - * Returns name - * @return {String} - */ - static get name() { - return Capability.NETWORKING_HOME_NETWORK_CONTROLLER; - } - - /** - * Returns interface - * @return {String} - */ - get interface() { - return Interface.ALEXA_NETWORKING_HOME_NETWORK_CONTROLLER; - } -} diff --git a/lambda/alexa/smarthome/catalog.js b/lambda/alexa/smarthome/catalog.js index 3a1a7264..7e8e65a9 100644 --- a/lambda/alexa/smarthome/catalog.js +++ b/lambda/alexa/smarthome/catalog.js @@ -785,7 +785,7 @@ export default class AlexaAssetCatalog extends AlexaGlobalCatalog { /** * Returns custom catalog label values * This is a temporary solution until Amazon provides the ability to upload our own catalog: - * https://developer.amazon.com/docs/device-apis/resources-and-assets.html#upload-your-own-catalog + * https://developer.amazon.com/docs/device-apis/resources-and-assets.html#upload-catalog * * { * '': [ diff --git a/lambda/alexa/smarthome/constants.js b/lambda/alexa/smarthome/constants.js index 3f33c239..46d25b2a 100644 --- a/lambda/alexa/smarthome/constants.js +++ b/lambda/alexa/smarthome/constants.js @@ -29,9 +29,6 @@ export const Capability = Object.freeze({ LOCK_CONTROLLER: 'LockController', MODE_CONTROLLER: 'ModeController', MOTION_SENSOR: 'MotionSensor', - NETWORKING_ACCESS_CONTROLLER: 'NetworkingAccessController', - NETWORKING_CONNECTED_DEVICE: 'NetworkingConnectedDevice', - NETWORKING_HOME_NETWORK_CONTROLLER: 'NetworkingHomeNetworkController', PERCENTAGE_CONTROLLER: 'PercentageController', PLAYBACK_CONTROLLER: 'PlaybackController', PLAYBACK_STATE_REPORTER: 'PlaybackStateReporter', @@ -68,9 +65,6 @@ export const Interface = Object.freeze({ ALEXA_LOCK_CONTROLLER: 'Alexa.LockController', ALEXA_MODE_CONTROLLER: 'Alexa.ModeController', ALEXA_MOTION_SENSOR: 'Alexa.MotionSensor', - ALEXA_NETWORKING_ACCESS_CONTROLLER: 'Alexa.Networking.AccessController', - ALEXA_NETWORKING_CONNECTED_DEVICE: 'Alexa.Networking.ConnectedDevice', - ALEXA_NETWORKING_HOME_NETWORK_CONTROLLER: 'Alexa.Networking.HomeNetworkController', ALEXA_PERCENTAGE_CONTROLLER: 'Alexa.PercentageController', ALEXA_PLAYBACK_CONTROLLER: 'Alexa.PlaybackController', ALEXA_PLAYBACK_STATE_REPORTER: 'Alexa.PlaybackStateReporter', @@ -102,7 +96,6 @@ export const Property = Object.freeze({ CHANNEL_STEP: 'channelStep', COLOR: 'color', COLOR_TEMPERATURE: 'colorTemperatureInKelvin', - CONNECTED_DEVICE: 'connectedDevice', CONNECTIVITY: 'connectivity', DETECTION_STATE: 'detectionState', EQUALIZER_BANDS: 'bands', @@ -113,7 +106,6 @@ export const Property = Object.freeze({ LOWER_SETPOINT: 'lowerSetpoint', MODE: 'mode', MUTED: 'muted', - NETWORK_ACCESS: 'networkAccess', OBSTACLE_ALERT: 'obstacleAlert', PERCENTAGE: 'percentage', PLAYBACK: 'playback', @@ -148,15 +140,12 @@ export const Parameter = Object.freeze({ CAPABILITY_NAMES: 'capabilityNames', CHANNEL_MAPPINGS: 'channelMappings', COMFORT_RANGE: 'comfortRange', - CONNECTED_TO: 'connectedTo', DEFAULT_LEVEL: 'defaultLevel', DEVICE_NAME: 'deviceName', EXIT_DELAY: 'exitDelay', - HOSTNAME: 'hostname', INCREMENT: 'increment', INVERTED: 'inverted', LANGUAGE: 'language', - MAC_ADDRESS: 'macAddress', NON_CONTROLLABLE: 'nonControllable', ORDERED: 'ordered', PASSWORD: 'password', diff --git a/lambda/alexa/smarthome/device/attributes/index.js b/lambda/alexa/smarthome/device/attributes/index.js index 18db8cd3..b139520f 100644 --- a/lambda/alexa/smarthome/device/attributes/index.js +++ b/lambda/alexa/smarthome/device/attributes/index.js @@ -58,7 +58,6 @@ export { default as Mode } from './mode.js'; export { default as MotionDetectionState } from './motionDetectionState.js'; export { default as MuteState } from './muteState.js'; export { default as MuteStep } from './muteStep.js'; -export { default as NetworkAccess } from './networkAccess.js'; export { default as ObstacleAlert } from './obstacleAlert.js'; export { default as OpenState } from './openState.js'; export { default as Percentage } from './percentage.js'; diff --git a/lambda/alexa/smarthome/device/attributes/networkAccess.js b/lambda/alexa/smarthome/device/attributes/networkAccess.js deleted file mode 100644 index 98364cfe..00000000 --- a/lambda/alexa/smarthome/device/attributes/networkAccess.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2010-2024 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 - */ - -import { Capability, Property } from '#alexa/smarthome/constants.js'; -import DeviceAttribute from './attribute.js'; - -/** - * Defines network access attribute class - * @extends DeviceAttribute - */ -export default class NetworkAccess extends DeviceAttribute { - /** - * Returns supported names - * @return {Array} - */ - static get supportedNames() { - return ['NetworkAccess']; - } - - /** - * Returns capabilities - * @return {Array} - */ - static getCapabilities() { - return [{ name: Capability.NETWORKING_ACCESS_CONTROLLER, property: Property.NETWORK_ACCESS }]; - } -} diff --git a/lambda/alexa/smarthome/device/types/computer.js b/lambda/alexa/smarthome/device/types/computer.js index 0736057c..c6df9b03 100644 --- a/lambda/alexa/smarthome/device/types/computer.js +++ b/lambda/alexa/smarthome/device/types/computer.js @@ -12,13 +12,13 @@ */ import AlexaDisplayCategory from '#alexa/smarthome/category.js'; -import NetworkDevice from './networkDevice.js'; +import GenericDevice from './genericDevice.js'; /** * Defines computer device type class - * @extends NetworkDevice + * @extends GenericDevice */ -export default class Computer extends NetworkDevice { +export default class Computer extends GenericDevice { /** * Returns supported names * @return {Array} diff --git a/lambda/alexa/smarthome/device/types/gameConsole.js b/lambda/alexa/smarthome/device/types/gameConsole.js index 49b2a715..63bde722 100644 --- a/lambda/alexa/smarthome/device/types/gameConsole.js +++ b/lambda/alexa/smarthome/device/types/gameConsole.js @@ -12,13 +12,13 @@ */ import AlexaDisplayCategory from '#alexa/smarthome/category.js'; -import NetworkDevice from './networkDevice.js'; +import GenericDevice from './genericDevice.js'; /** * Defines game console device type class - * @extends NetworkDevice + * @extends GenericDevice */ -export default class GameConsole extends NetworkDevice { +export default class GameConsole extends GenericDevice { /** * Returns supported names * @return {Array} diff --git a/lambda/alexa/smarthome/device/types/mobileDevice.js b/lambda/alexa/smarthome/device/types/mobileDevice.js index 31382b6f..4c1933e3 100644 --- a/lambda/alexa/smarthome/device/types/mobileDevice.js +++ b/lambda/alexa/smarthome/device/types/mobileDevice.js @@ -11,14 +11,14 @@ * SPDX-License-Identifier: EPL-2.0 */ -import NetworkDevice from './networkDevice.js'; +import GenericDevice from './genericDevice.js'; import { BatteryLevel } from '../attributes/index.js'; /** * Defines mobile device type class - * @extends NetworkDevice + * @extends GenericDevice */ -export default class MobileDevice extends NetworkDevice { +export default class MobileDevice extends GenericDevice { /** * Returns supported attributes * @return {Array} diff --git a/lambda/alexa/smarthome/device/types/networkDevice.js b/lambda/alexa/smarthome/device/types/networkDevice.js deleted file mode 100644 index 20fe51bc..00000000 --- a/lambda/alexa/smarthome/device/types/networkDevice.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2010-2024 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 - */ - -import { Capability, Property } from '#alexa/smarthome/constants.js'; -import GenericDevice from './genericDevice.js'; -import { NetworkAccess } from '../attributes/index.js'; - -/** - * Defines network device type class - * @extends GenericDevice - */ -export default class NetworkDevice extends GenericDevice { - /** - * Returns supported attributes - * @return {Array} - */ - static get supportedAttributes() { - return [NetworkAccess, ...super.supportedAttributes]; - } - - /** - * Returns group capabilities - * @return {Array} - */ - static get groupCapabilities() { - return [{ name: Capability.NETWORKING_CONNECTED_DEVICE, property: Property.CONNECTED_DEVICE }]; - } -} diff --git a/lambda/alexa/smarthome/device/types/networkHardware.js b/lambda/alexa/smarthome/device/types/networkHardware.js index 9944e4f1..b9dce023 100644 --- a/lambda/alexa/smarthome/device/types/networkHardware.js +++ b/lambda/alexa/smarthome/device/types/networkHardware.js @@ -12,7 +12,6 @@ */ import AlexaDisplayCategory from '#alexa/smarthome/category.js'; -import { Capability } from '#alexa/smarthome/constants.js'; import GenericDevice from './genericDevice.js'; /** @@ -28,14 +27,6 @@ export default class NetworkHardware extends GenericDevice { return ['NetworkHardware']; } - /** - * Returns group capabilities - * @return {Array} - */ - static get groupCapabilities() { - return [{ name: Capability.NETWORKING_HOME_NETWORK_CONTROLLER }]; - } - /** * Returns display categories * @return {Array} diff --git a/lambda/alexa/smarthome/endpoint.js b/lambda/alexa/smarthome/endpoint.js index 8d3f14cd..e320f516 100644 --- a/lambda/alexa/smarthome/endpoint.js +++ b/lambda/alexa/smarthome/endpoint.js @@ -307,9 +307,8 @@ export default class AlexaEndpoint { * @param {Object} item * @param {Object} metadata * @param {Object} settings - * @param {Array} groups */ - addCapability({ name, instance, property, component, tag, parameters, item, metadata, settings, groups }) { + addCapability({ name, instance, property, component, tag, parameters, item, metadata, settings }) { // Define instance name for generic capabilities using capability/item names, if not defined already if (!instance && item) { instance = `${name.replace(/Controller$/, '')}:${item.name}`; @@ -325,7 +324,7 @@ export default class AlexaEndpoint { if (typeof capability !== 'undefined') { // Add property to capability if name defined if (typeof property !== 'undefined') { - capability.addProperty({ name: property, component, tag, parameters, item, metadata, settings, groups }); + capability.addProperty({ name: property, component, tag, parameters, item, metadata, settings }); } // Add capability to list if new instance if (index === -1) { @@ -449,9 +448,8 @@ export default class AlexaEndpoint { * Sets group endpoint based on given item * @param {Object} item * @param {Object} settings - * @param {Array} groups */ - setGroup(item, settings, groups) { + setGroup(item, settings) { // Initialize alexa metadata object const metadata = new AlexaMetadata(item, settings); @@ -466,7 +464,7 @@ export default class AlexaEndpoint { this.group = { deviceType, config: deviceType.getConfig(metadata) }; // Add device type group capabilities for (const capability of deviceType.groupCapabilities) { - this.addCapability({ ...capability, item, metadata, settings, groups }); + this.addCapability({ ...capability, item, metadata, settings }); } // Add device type display categories this.addDisplayCategories(deviceType.displayCategories); @@ -541,10 +539,9 @@ export default class AlexaEndpoint { * Returns new endpoint object based on item object * @param {Object} item * @param {Object} settings - * @param {Array} groups * @return {Object} */ - static fromItem(item, settings, groups) { + static fromItem(item, settings) { // Initialize alexa endpoint object using item name as id const endpoint = new AlexaEndpoint(item.name); // Set endpoint details @@ -552,7 +549,7 @@ export default class AlexaEndpoint { // Set group endpoint if is group type, otherwise add item capabilities to endpoint if (endpoint.type === ItemType.GROUP) { - endpoint.setGroup(item, settings, groups); + endpoint.setGroup(item, settings); } else { endpoint.addItemCapabilities(item, settings); } diff --git a/lambda/alexa/smarthome/handlers/discovery.js b/lambda/alexa/smarthome/handlers/discovery.js index e17ea1fc..fffaa58d 100644 --- a/lambda/alexa/smarthome/handlers/discovery.js +++ b/lambda/alexa/smarthome/handlers/discovery.js @@ -65,7 +65,6 @@ export default class Discovery extends AlexaHandler { // - all items // - server settings const [items, settings] = await Promise.all([openhab.getAllItems(), openhab.getServerSettings()]); - const groups = items.filter((item) => item.type === ItemType.GROUP && !item.groupType); const endpoints = []; const groupItems = []; @@ -74,7 +73,7 @@ export default class Discovery extends AlexaHandler { // Iterate over items retrieved for (const item of items) { // Create new endpoint from item - const endpoint = AlexaEndpoint.fromItem(item, settings, groups); + const endpoint = AlexaEndpoint.fromItem(item, settings); // Skip item if endpoint friendly name not defined or if already part of a group if (!endpoint.friendlyName || groupItems.includes(item.name)) { continue; diff --git a/lambda/alexa/smarthome/handlers/index.js b/lambda/alexa/smarthome/handlers/index.js index 630e8f5b..80bbe616 100644 --- a/lambda/alexa/smarthome/handlers/index.js +++ b/lambda/alexa/smarthome/handlers/index.js @@ -26,7 +26,6 @@ export { default as EqualizerController } from './equalizerController.js'; export { default as InputController } from './inputController.js'; export { default as LockController } from './lockController.js'; export { default as ModeController } from './modeController.js'; -export { default as NetworkingAccessController } from './networkingAccessController.js'; export { default as PercentageController } from './percentageController.js'; export { default as PlaybackController } from './playbackController.js'; export { default as PowerController } from './powerController.js'; diff --git a/lambda/alexa/smarthome/handlers/networkingAccessController.js b/lambda/alexa/smarthome/handlers/networkingAccessController.js deleted file mode 100644 index ff386897..00000000 --- a/lambda/alexa/smarthome/handlers/networkingAccessController.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (c) 2010-2024 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 - */ - -import { Interface, Property } from '../constants.js'; -import AlexaHandler from './handler.js'; - -/** - * Defines Alexa.Networking.AccessController interface handler class - * https://developer.amazon.com/docs/networking/alexa-networking-accesscontroller.html#directives - * @extends AlexaHandler - */ -export default class NetworkingAccessController extends AlexaHandler { - /** - * Defines set network access directive - * @type {String} - */ - static SET_NETWORK_ACCESS = 'SetNetworkAccess'; - - /** - * Defines handler namespace - * @return {String} - */ - static get namespace() { - return Interface.ALEXA_NETWORKING_ACCESS_CONTROLLER; - } - - /** - * Defines handler supported directives - * @return {Object} - */ - static get directives() { - return { - [NetworkingAccessController.SET_NETWORK_ACCESS]: this.setNetworkAccess - }; - } - - /** - * Sets network access - * @param {Object} directive - * @param {Object} openhab - * @return {Promise} - */ - static async setNetworkAccess(directive, openhab) { - const property = directive.endpoint.getCapabilityProperty({ - interface: directive.namespace, - property: Property.NETWORK_ACCESS - }); - const command = property.getCommand(directive.payload.networkAccess); - - await openhab.sendCommand(property.item.name, command); - - return directive.response(); - } -} diff --git a/lambda/alexa/smarthome/metadata.js b/lambda/alexa/smarthome/metadata.js index 33d191ef..a7ff8fe0 100644 --- a/lambda/alexa/smarthome/metadata.js +++ b/lambda/alexa/smarthome/metadata.js @@ -150,8 +150,7 @@ export default class AlexaMetadata { * @return {Object} */ static parseCapability(value) { - const match = value.match(this.#CAPABILITY_PATTERN); - return match?.groups; + return value.match(this.#CAPABILITY_PATTERN)?.groups; } /** @@ -160,7 +159,6 @@ export default class AlexaMetadata { * @return {Object} */ static parseGroupEndpoint(value) { - const match = value.match(this.#GROUP_ENDPOINT_PATTERN); - return match?.groups; + return value.match(this.#GROUP_ENDPOINT_PATTERN)?.groups; } } diff --git a/lambda/alexa/smarthome/properties/connectedDevice.js b/lambda/alexa/smarthome/properties/connectedDevice.js deleted file mode 100644 index b1ff8ed2..00000000 --- a/lambda/alexa/smarthome/properties/connectedDevice.js +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Copyright (c) 2010-2024 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 - */ - -import { isMACAddress } from '#root/utils.js'; -import { ItemType } from '#openhab/constants.js'; -import { Capability, Parameter, ParameterType } from '../constants.js'; -import AlexaDevice from '../device/index.js'; -import AlexaProperty from './property.js'; - -/** - * Defines connected device property class - * @extends AlexaProperty - */ -export default class ConnectedDevice extends AlexaProperty { - /** - * Returns supported item types - * @return {Array} - */ - get supportedItemTypes() { - return [ItemType.GROUP]; - } - - /** - * Returns supported parameters and their type - * @return {Object} - */ - get supportedParameters() { - return { - [Parameter.CONNECTED_TO]: ParameterType.STRING, - [Parameter.DEVICE_NAME]: ParameterType.STRING, - [Parameter.HOSTNAME]: ParameterType.STRING, - [Parameter.MAC_ADDRESS]: ParameterType.STRING - }; - } - - /** - * Returns if is reportable - * @return {Boolean} - */ - get isReportable() { - return false; - } - - /** - * Returns if is valid - * @return {Boolean} - */ - get isValid() { - return this.connectedTo && this.deviceName && this.hostname && isMACAddress(this.macAddress); - } - - /** - * Returns connected to based on parameter - * @return {String} - */ - get connectedTo() { - return this.parameters[Parameter.CONNECTED_TO]; - } - - /** - * Returns device name based on parameter - * @return {String} - */ - get deviceName() { - return this.parameters[Parameter.DEVICE_NAME]; - } - - /** - * Returns hostname based on parameter - * @return {String} - */ - get hostname() { - return this.parameters[Parameter.HOSTNAME] || 'N/A'; - } - - /** - * Returns mac address system based on parameter - * @return {String} - */ - get macAddress() { - return this.parameters[Parameter.MAC_ADDRESS]; - } - - /** - * Updates parameters - * @param {Object} item - * @param {Object} metadata - * @param {Object} settings - * @param {Array} groups - */ - updateParameters(item, metadata, settings, groups) { - const parameters = this.parameters; - // Update parameters from parent method - super.updateParameters(item, metadata, settings); - - // Determine router group based on group device type with home network controller capability - const router = groups - .filter((group) => item.groupNames.includes(group.name) && group.metadata?.alexa) - .find(({ metadata }) => { - const { groupCapabilities } = AlexaDevice.getDeviceType(metadata.alexa.value) || {}; - return groupCapabilities?.some(({ name }) => name === Capability.NETWORKING_HOME_NETWORK_CONTROLLER); - }); - // Set connected to parameter using router group name if found - parameters[Parameter.CONNECTED_TO] = router?.name; - // Set device name parameter using metadata config name parameter, otherwise item label - parameters[Parameter.DEVICE_NAME] = metadata.config.name || item.label; - } -} diff --git a/lambda/alexa/smarthome/properties/index.js b/lambda/alexa/smarthome/properties/index.js index 1e11cbfb..ea0ede8e 100644 --- a/lambda/alexa/smarthome/properties/index.js +++ b/lambda/alexa/smarthome/properties/index.js @@ -24,7 +24,6 @@ export { default as Channel } from './channel.js'; export { default as ChannelStep } from './channelStep.js'; export { default as Color } from './color.js'; export { default as ColorTemperature } from './colorTemperature.js'; -export { default as ConnectedDevice } from './connectedDevice.js'; export { default as Connectivity } from './connectivity.js'; export { default as DecoupleState } from './decoupleState.js'; export { default as DetectionState } from './detectionState.js'; @@ -37,7 +36,6 @@ export { default as LowerSetpoint } from './lowerSetpoint.js'; export { default as Mode } from './mode.js'; export { default as MuteState } from './muteState.js'; export { default as MuteStep } from './muteStep.js'; -export { default as NetworkAccess } from './networkAccess.js'; export { default as Percentage } from './percentage.js'; export { default as Playback } from './playback.js'; export { default as PlaybackAction } from './playbackAction.js'; diff --git a/lambda/alexa/smarthome/properties/networkAccess.js b/lambda/alexa/smarthome/properties/networkAccess.js deleted file mode 100644 index 8e5b0d23..00000000 --- a/lambda/alexa/smarthome/properties/networkAccess.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2010-2024 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 - */ - -import BinaryState from './binaryState.js'; - -/** - * Defines network access property class - * @extends BinaryState - */ -export default class NetworkAccess extends BinaryState { - /** - * Defines allowed state - * @type {String} - */ - static ALLOWED = 'ALLOWED'; - - /** - * Defines blocked state - * @type {String} - */ - static BLOCKED = 'BLOCKED'; - - /** - * Returns supported values - * https://developer.amazon.com/docs/networking/alexa-networking-accesscontroller.html#properties - * @return {Array} - */ - get supportedValues() { - return [NetworkAccess.ALLOWED, NetworkAccess.BLOCKED]; - } - - /** - * Returns if supports commands - * @return {Boolean} - */ - get supportsCommands() { - return true; - } -} diff --git a/lambda/alexa/smarthome/properties/property.js b/lambda/alexa/smarthome/properties/property.js index d776168c..fb3b2fd4 100644 --- a/lambda/alexa/smarthome/properties/property.js +++ b/lambda/alexa/smarthome/properties/property.js @@ -318,10 +318,9 @@ export default class AlexaProperty { * @param {Object} item * @param {Object} metadata * @param {Object} settings - * @param {Array} groups * @return {Object} */ - static create({ name, component, tag, parameters, item, metadata, settings, groups }) { + static create({ name, component, tag, parameters, item, metadata, settings }) { const property = new this(name, component, tag, parameters, item); // Return if property has not required component or supported item type @@ -331,7 +330,7 @@ export default class AlexaProperty { // Update property parameters based on metadata if provided, otherwise normalize existing parameters if (metadata) { - property.updateParameters(item, metadata, settings, groups); + property.updateParameters(item, metadata, settings); } else { property.normalizeParameters(); } diff --git a/lambda/test/alexa/cases/discovery/computer.test.js b/lambda/test/alexa/cases/discovery/computer.test.js index aad16c15..146918d8 100644 --- a/lambda/test/alexa/cases/discovery/computer.test.js +++ b/lambda/test/alexa/cases/discovery/computer.test.js @@ -14,120 +14,22 @@ export default { description: 'computer', items: [ - { - type: 'Group', - name: 'gComputer1', - label: 'Computer', - groupNames: ['gRouter1'], - metadata: { - alexa: { - value: 'Computer', - config: { - hostname: 'workstation', - macAddress: '00:21:86:B5:6E:10' - } - } - } - }, - { - type: 'Group', - name: 'gRouter1', - label: 'Router', - metadata: { - alexa: { - value: 'Router' - } - } - }, { type: 'Switch', - name: 'networkAccess1', - groupNames: ['gComputer1'], - metadata: { - alexa: { - value: 'NetworkAccess' - } - } - }, - { - type: 'Switch', - name: 'power', - groupNames: ['gComputer1'], - metadata: { - alexa: { - value: 'PowerState' - } - } - }, - { - type: 'Group', - name: 'gComputer99', - label: 'Invalid Computer', - groupNames: ['gRouter99'], - metadata: { - alexa: { - value: 'Computer', - config: { - hostname: 'workstation', - macAddress: '00:21:86:B5:6E:10' - } - } - } - }, - { - type: 'Group', - name: 'gRouter99', - label: 'Invalid Router', - metadata: { - alexa: { - value: 'Invalid' - } - } - }, - { - type: 'Switch', - name: 'networkAccess99', - groupNames: ['gComputer99'], + name: 'computer', + label: 'Computer', metadata: { alexa: { - value: 'NetworkAccess' + value: 'Computer' } } } ], expected: { - gComputer1: { - capabilities: [ - 'Alexa.Networking.ConnectedDevice', - 'Alexa.Networking.AccessController.networkAccess', - 'Alexa.PowerController.powerState', - 'Alexa.EndpointHealth.connectivity', - 'Alexa' - ], + computer: { + capabilities: ['Alexa.PowerController.powerState', 'Alexa.EndpointHealth.connectivity', 'Alexa'], displayCategories: ['COMPUTER'], - friendlyName: 'Computer', - configuration: { - 'Alexa.Networking.ConnectedDevice': { - staticDeviceInformation: { - deviceName: 'Computer', - hostname: 'workstation', - macAddress: '00:21:86:B5:6E:10' - } - }, - 'Alexa.Networking.AccessController': { - supportsScheduling: false - } - }, - relationships: { - isConnectedBy: { - endpointId: 'gRouter1' - } - } - }, - gRouter1: { - capabilities: ['Alexa.Networking.HomeNetworkController', 'Alexa'], - displayCategories: ['ROUTER'], - friendlyName: 'Router' + friendlyName: 'Computer' } } }; diff --git a/lambda/test/alexa/cases/discovery/router.test.js b/lambda/test/alexa/cases/discovery/router.test.js index 3c3014fc..2f2c6567 100644 --- a/lambda/test/alexa/cases/discovery/router.test.js +++ b/lambda/test/alexa/cases/discovery/router.test.js @@ -42,7 +42,6 @@ export default { expected: { gWirelessRouter: { capabilities: [ - 'Alexa.Networking.HomeNetworkController', 'Alexa.ToggleController:guestNetwork.toggleState', 'Alexa.PlaybackController', 'Alexa.EndpointHealth.connectivity', diff --git a/lambda/test/alexa/cases/index.js b/lambda/test/alexa/cases/index.js index 104f36f4..21c83523 100644 --- a/lambda/test/alexa/cases/index.js +++ b/lambda/test/alexa/cases/index.js @@ -77,7 +77,6 @@ import equalizerControllerTest from './equalizerController.test.js'; import inputControllerTest from './inputController.test.js'; import lockControllerTest from './lockController.test.js'; import modeControllerTest from './modeController.test.js'; -import networkingAccessControllerTest from './networkingAccessController.test.js'; import percentageControllerTest from './percentageController.test.js'; import playbackControllerTest from './playbackController.test.js'; import powerControllerTest from './powerController.test.js'; @@ -160,7 +159,6 @@ export default { InputController: [inputControllerTest], LockController: [lockControllerTest], ModeController: [modeControllerTest], - NetworkingAccessController: [networkingAccessControllerTest], PercentageController: [percentageControllerTest], PlaybackController: [playbackControllerTest], PowerController: [powerControllerTest], diff --git a/lambda/test/alexa/cases/networkingAccessController.test.js b/lambda/test/alexa/cases/networkingAccessController.test.js deleted file mode 100644 index 6f4996bc..00000000 --- a/lambda/test/alexa/cases/networkingAccessController.test.js +++ /dev/null @@ -1,193 +0,0 @@ -/** - * Copyright (c) 2010-2024 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 - */ - -export default [ - { - description: 'set network access', - directive: { - header: { - namespace: 'Alexa.Networking.AccessController', - name: 'SetNetworkAccess' - }, - endpoint: { - endpointId: 'gComputer', - cookie: { - capabilities: [ - { - name: 'NetworkingConnectedDevice', - property: 'connectedDevice', - parameters: { - connectedTo: 'gRouter', - deviceName: 'Computer', - macAddress: '00:21:86:B5:6E:10' - }, - item: { name: 'gComputer', type: 'Group' } - }, - { - name: 'NetworkingAccessController', - property: 'networkAccess', - parameters: {}, - item: { name: 'networkAccess', type: 'Switch' } - } - ] - } - }, - payload: { - networkAccess: 'BLOCKED' - } - }, - items: [{ name: 'networkAccess', state: 'OFF', type: 'Switch' }], - expected: { - alexa: { - context: { - properties: [ - { - namespace: 'Alexa.Networking.AccessController', - name: 'networkAccess', - value: 'BLOCKED' - } - ] - }, - event: { - header: { - namespace: 'Alexa', - name: 'Response' - } - } - }, - openhab: { - commands: [{ name: 'networkAccess', value: 'OFF' }] - } - } - }, - { - description: 'set network access allowed inverted', - directive: { - header: { - namespace: 'Alexa.Networking.AccessController', - name: 'SetNetworkAccess' - }, - endpoint: { - endpointId: 'gComputer', - cookie: { - capabilities: [ - { - name: 'NetworkingConnectedDevice', - property: 'connectedDevice', - parameters: { - connectedTo: 'gRouter', - deviceName: 'Computer', - macAddress: '00:21:86:B5:6E:10' - }, - item: { name: 'gComputer', type: 'Group' } - }, - { - name: 'NetworkingAccessController', - property: 'networkAccess', - parameters: { - inverted: true - }, - item: { name: 'networkAccess', type: 'Switch' } - } - ] - } - }, - payload: { - networkAccess: 'ALLOWED' - } - }, - items: [{ name: 'networkAccess', state: 'OFF', type: 'Switch' }], - expected: { - alexa: { - context: { - properties: [ - { - namespace: 'Alexa.Networking.AccessController', - name: 'networkAccess', - value: 'ALLOWED' - } - ] - }, - event: { - header: { - namespace: 'Alexa', - name: 'Response' - } - } - }, - openhab: { - commands: [{ name: 'networkAccess', value: 'OFF' }] - } - } - }, - { - description: 'set network access blocked inverted', - directive: { - header: { - namespace: 'Alexa.Networking.AccessController', - name: 'SetNetworkAccess' - }, - endpoint: { - endpointId: 'gComputer', - cookie: { - capabilities: [ - { - name: 'NetworkingConnectedDevice', - property: 'connectedDevice', - parameters: { - connectedTo: 'gRouter', - deviceName: 'Computer', - macAddress: '00:21:86:B5:6E:10' - }, - item: { name: 'gComputer', type: 'Group' } - }, - { - name: 'NetworkingAccessController', - property: 'networkAccess', - parameters: { - inverted: true - }, - item: { name: 'networkAccess', type: 'Switch' } - } - ] - } - }, - payload: { - networkAccess: 'BLOCKED' - } - }, - items: [{ name: 'networkAccess', state: 'ON', type: 'Switch' }], - expected: { - alexa: { - context: { - properties: [ - { - namespace: 'Alexa.Networking.AccessController', - name: 'networkAccess', - value: 'BLOCKED' - } - ] - }, - event: { - header: { - namespace: 'Alexa', - name: 'Response' - } - } - }, - openhab: { - commands: [{ name: 'networkAccess', value: 'ON' }] - } - } - } -]; diff --git a/lambda/test/utils.test.js b/lambda/test/utils.test.js index c1baa7e0..4be13dda 100644 --- a/lambda/test/utils.test.js +++ b/lambda/test/utils.test.js @@ -12,15 +12,7 @@ */ import { expect } from 'chai'; -import { - clamp, - compressJSON, - decompressJSON, - decamelize, - isMACAddress, - parseUrl, - stripPunctuation -} from '#root/utils.js'; +import { clamp, compressJSON, decompressJSON, decamelize, parseUrl, stripPunctuation } from '#root/utils.js'; describe('Utilities Tests', () => { describe('clamp', () => { @@ -61,20 +53,6 @@ describe('Utilities Tests', () => { }); }); - describe('is mac address', () => { - it('eui-48 format with colon separator', () => { - expect(isMACAddress('00:21:86:B5:6E:10')).to.be.true; - }); - - it('eui-64 format with dash separator', () => { - expect(isMACAddress('00-21-86-FF-FE-B5-6E-10')).to.be.true; - }); - - it('invalid format', () => { - expect(isMACAddress('invalid')).to.be.false; - }); - }); - describe('parse url', () => { it('url only', () => { expect(parseUrl('https://foo/bar')) diff --git a/lambda/utils.js b/lambda/utils.js index 2d86f8dd..9b04405c 100644 --- a/lambda/utils.js +++ b/lambda/utils.js @@ -59,15 +59,6 @@ export const decamelize = (string, separator = '_') => { .toLowerCase(); }; -/** - * Returns if given string is a mac address - * @param {String} string - * @return {Boolean} - */ -export const isMACAddress = (string) => { - return /^([0-9a-fA-F]{2}(-|:)){7}[0-9a-fA-F]{2}$|^([0-9a-fA-F]{2}(-|:)){5}[0-9a-fA-F]{2}$/.test(string); -}; - /** * Returns parsed url object * @param {String} url