@@ -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