Skip to content

Commit 2ceb2cd

Browse files
committed
alexa: maybe fix alexa when no detection types are available
1 parent a5fd1c0 commit 2ceb2cd

File tree

5 files changed

+103
-84
lines changed

5 files changed

+103
-84
lines changed

plugins/alexa/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
<details>
22
<summary>Changelog</summary>
33

4+
### 0.3.4
5+
6+
Alexa: add option to not auto enable devices (#1615)
7+
8+
9+
### 0.3.3
10+
11+
google-home/alexa: republish with new sdk for media converter
12+
13+
414
### 0.3.2
515

616
alexa: fix syncedDevices being undefined

plugins/alexa/package-lock.json

Lines changed: 27 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/alexa/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@scrypted/alexa",
3-
"version": "0.3.4",
3+
"version": "0.3.6",
44
"scripts": {
55
"scrypted-setup-project": "scrypted-setup-project",
66
"prescrypted-setup-project": "scrypted-package-json",

plugins/alexa/src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,9 @@ class HttpResponseLoggingImpl implements AlexaHttpResponse {
718718
sendSocket(socket: any, options: HttpResponseOptions): void {
719719
this.response.sendSocket(socket, options);
720720
}
721+
sendStream(stream: AsyncGenerator<Buffer, void>, options?: HttpResponseOptions): void {
722+
this.response.sendStream(stream, options);
723+
}
721724
}
722725

723726
export default AlexaPlugin;

plugins/alexa/src/types/camera/capabilities.ts

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -126,68 +126,69 @@ export async function getCameraCapabilities(device: ScryptedDevice): Promise<Dis
126126
];
127127

128128
if (device.interfaces.includes(ScryptedInterface.ObjectDetector)) {
129-
const detectionTypes = await (device as any as ObjectDetector).getObjectTypes();
130-
const classNames = detectionTypes.classes.filter(t => t !== 'ring' && t !== 'motion').map(type => type.toLowerCase());
131-
132-
capabilities.push(
133-
{
134-
"type": "AlexaInterface",
135-
"interface": "Alexa.SmartVision.ObjectDetectionSensor",
136-
"version": "1.0",
137-
"properties": {
138-
"supported": [{
139-
"name": "objectDetectionClasses"
140-
}],
141-
"proactivelyReported": true,
142-
"retrievable": true
143-
},
144-
"configuration": {
145-
"objectDetectionConfiguration": classNames.map(type => ({
146-
"imageNetClass": type
147-
}))
148-
}
149-
} as DiscoveryCapability
150-
);
151-
152-
capabilities.push(
153-
{
154-
"type": "AlexaInterface",
155-
"interface": "Alexa.DataController",
156-
"instance": "Camera.SmartVisionData",
157-
"version": "1.0",
158-
"properties": undefined,
159-
"configuration": {
160-
"targetCapability": {
161-
"name": "Alexa.SmartVision.ObjectDetectionSensor",
162-
"version": "1.0"
163-
},
164-
"dataRetrievalSchema": {
165-
"type": "JSON",
166-
"schema": "SmartVisionData"
129+
const detectionTypes = await (device as any as ObjectDetector).getObjectTypes().catch(() => {}) || undefined;
130+
const classNames = detectionTypes?.classes?.filter(t => t !== 'ring' && t !== 'motion').map(type => type.toLowerCase()).filter(c => !!c);
131+
if (classNames?.length) {
132+
capabilities.push(
133+
{
134+
"type": "AlexaInterface",
135+
"interface": "Alexa.SmartVision.ObjectDetectionSensor",
136+
"version": "1.0",
137+
"properties": {
138+
"supported": [{
139+
"name": "objectDetectionClasses"
140+
}],
141+
"proactivelyReported": true,
142+
"retrievable": true
167143
},
168-
"supportedAccess": ["BY_IDENTIFIER", "BY_TIMESTAMP_RANGE"]
169-
}
170-
} as DiscoveryCapability
171-
);
172-
}
173-
174-
if (device.interfaces.includes(ScryptedInterface.MotionSensor)) {
175-
capabilities.push(
176-
{
177-
"type": "AlexaInterface",
178-
"interface": "Alexa.MotionSensor",
179-
"version": "3",
180-
"properties": {
181-
"supported": [
182-
{
183-
"name": "detectionState"
184-
}
185-
],
186-
"proactivelyReported": true,
187-
"retrievable": true
188-
}
189-
} as DiscoveryCapability
190-
);
144+
"configuration": {
145+
"objectDetectionConfiguration": classNames.map(type => ({
146+
"imageNetClass": type
147+
}))
148+
}
149+
} as DiscoveryCapability
150+
);
151+
152+
capabilities.push(
153+
{
154+
"type": "AlexaInterface",
155+
"interface": "Alexa.DataController",
156+
"instance": "Camera.SmartVisionData",
157+
"version": "1.0",
158+
"properties": undefined,
159+
"configuration": {
160+
"targetCapability": {
161+
"name": "Alexa.SmartVision.ObjectDetectionSensor",
162+
"version": "1.0"
163+
},
164+
"dataRetrievalSchema": {
165+
"type": "JSON",
166+
"schema": "SmartVisionData"
167+
},
168+
"supportedAccess": ["BY_IDENTIFIER", "BY_TIMESTAMP_RANGE"]
169+
}
170+
} as DiscoveryCapability
171+
);
172+
}
173+
174+
if (device.interfaces.includes(ScryptedInterface.MotionSensor)) {
175+
capabilities.push(
176+
{
177+
"type": "AlexaInterface",
178+
"interface": "Alexa.MotionSensor",
179+
"version": "3",
180+
"properties": {
181+
"supported": [
182+
{
183+
"name": "detectionState"
184+
}
185+
],
186+
"proactivelyReported": true,
187+
"retrievable": true
188+
}
189+
} as DiscoveryCapability
190+
);
191+
}
191192
}
192193

193194
return capabilities;

0 commit comments

Comments
 (0)