diff --git a/plugins/alexa/.vscode/settings.json b/plugins/alexa/.vscode/settings.json index 77ccdbd6d..964a62559 100644 --- a/plugins/alexa/.vscode/settings.json +++ b/plugins/alexa/.vscode/settings.json @@ -1,4 +1,4 @@ { - "scrypted.debugHost": "127.0.0.1", + "scrypted.debugHost": "scrypted-server", } \ No newline at end of file diff --git a/plugins/alexa/CHANGELOG.md b/plugins/alexa/CHANGELOG.md index 20a0ce5d8..ba4142c81 100644 --- a/plugins/alexa/CHANGELOG.md +++ b/plugins/alexa/CHANGELOG.md @@ -1,6 +1,11 @@
Changelog +### 0.3.6 + +alexa: maybe fix alexa when no detection types are available + + ### 0.3.4 Alexa: add option to not auto enable devices (#1615) diff --git a/plugins/alexa/package-lock.json b/plugins/alexa/package-lock.json index 8cb4738f6..54f594a0b 100644 --- a/plugins/alexa/package-lock.json +++ b/plugins/alexa/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/alexa", - "version": "0.3.6", + "version": "0.3.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@scrypted/alexa", - "version": "0.3.6", + "version": "0.3.7", "dependencies": { "axios": "^1.3.4", "uuid": "^9.0.0" @@ -15,7 +15,7 @@ "@scrypted/common": "../../common", "@scrypted/sdk": "../../sdk", "@types/debug": "^4.1.12", - "@types/node": "^18.4.2" + "@types/node": "^22.13.11" } }, "../../common": { @@ -36,7 +36,7 @@ }, "../../sdk": { "name": "@scrypted/sdk", - "version": "0.3.113", + "version": "0.5.10", "dev": true, "license": "ISC", "dependencies": { @@ -103,10 +103,14 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.14.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.2.tgz", - "integrity": "sha512-1uEQxww3DaghA0RxqHx0O0ppVlo43pJhepY51OxuQIKHpjbnYLA7vcdwioNPzIqmC2u3I/dmylcqjlh0e7AyUA==", - "dev": true + "version": "22.13.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.11.tgz", + "integrity": "sha512-iEUCUJoU0i3VnrCmgoWCXttklWcvoCIx4jzcP22fioIVSdTmjgoEvmAO/QPw6TcS9k5FrNgn4w7q5lGOd1CT5g==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.20.0" + } }, "node_modules/asynckit": { "version": "0.4.0", @@ -198,6 +202,13 @@ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, + "node_modules/undici-types": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", + "dev": true, + "license": "MIT" + }, "node_modules/uuid": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", diff --git a/plugins/alexa/package.json b/plugins/alexa/package.json index 45f301d34..2e705ad3f 100644 --- a/plugins/alexa/package.json +++ b/plugins/alexa/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/alexa", - "version": "0.3.6", + "version": "0.3.7", "scripts": { "scrypted-setup-project": "scrypted-setup-project", "prescrypted-setup-project": "scrypted-package-json", @@ -42,6 +42,6 @@ "@scrypted/common": "../../common", "@scrypted/sdk": "../../sdk", "@types/debug": "^4.1.12", - "@types/node": "^18.4.2" + "@types/node": "^22.13.11" } } diff --git a/plugins/alexa/src/main.ts b/plugins/alexa/src/main.ts index 6cb2dbf7e..50a713949 100644 --- a/plugins/alexa/src/main.ts +++ b/plugins/alexa/src/main.ts @@ -660,17 +660,26 @@ class AlexaPlugin extends ScryptedDeviceBase implements HttpRequestHandler, Mixi const deviceHandler = alexaDeviceHandlers.get(mapName); - if (deviceHandler) { + const getDevice = () => { const device = systemManager.getDeviceById(directive.endpoint.endpointId); - if (!device) { - response.send(deviceErrorResponse("NO_SUCH_ENDPOINT", "The device doesn't exist in Scrypted", directive)); + if (!device || !device.mixins.includes(this.id)) { + response.send(deviceErrorResponse("NO_SUCH_ENDPOINT", "The device doesn't exist in Scrypted or was removed from the Alexa Plugin", directive)); + this.deleteEndpoints(directive.endpoint.endpointId).catch(() => { }); return; } + return device; + } + if (deviceHandler) { + const device = getDevice(); + if (!device) + return; await deviceHandler.apply(this, [request, response, directive, device]); return; } else { this.console.error(`no handler for: ${mapName}`); + if (!getDevice()) + return; } // it is better to send a non-specific response than an error, as the API might get rate throttled diff --git a/plugins/alexa/src/types/index.ts b/plugins/alexa/src/types/index.ts index e59804454..8ad2886d4 100644 --- a/plugins/alexa/src/types/index.ts +++ b/plugins/alexa/src/types/index.ts @@ -8,7 +8,7 @@ export interface SupportedType { setState?(device: ScryptedDevice, payload: any): Promise>; } -export const supportedTypes = new Map(); +export const supportedTypes = new Map(); import '../handlers'; import './camera';