@@ -170,7 +170,7 @@ def main():
170
170
time_of_sample = get_utc_timestamp ()
171
171
172
172
# ensure that this change or state report is appropriate for your user and skill
173
- alexa_params = {
173
+ alexa_psu = {
174
174
"context" : {
175
175
"properties" : [{
176
176
"namespace" : "Alexa.EndpointHealth" ,
@@ -218,10 +218,132 @@ def main():
218
218
}
219
219
}
220
220
}
221
+
222
+ # Proactive Discovery Additions or Updates
223
+ # https://developer.amazon.com/docs/smarthome/how-to-proactively-manage-endpoints.html
224
+ alexa_pdu = {
225
+ "event" : {
226
+ "header" : {
227
+ "namespace" : "Alexa.Discovery" ,
228
+ "name" : "AddOrUpdateReport" ,
229
+ "payloadVersion" : "3" ,
230
+ "messageId" : message_id
231
+ },
232
+ "payload" : {
233
+ "endpoints" : [{
234
+ "endpointId" : "appliance-001" ,
235
+ "friendlyName" : "Living Room Light" ,
236
+ "description" : "Smart Light by Sample Manufacturer" ,
237
+ "manufacturerName" : "Sample Manufacturer" ,
238
+ "displayCategories" : [
239
+ "LIGHT"
240
+ ],
241
+ "cookie" : {
242
+ "extraDetail1" : "optionalDetailForSkillToReferenceThisDevice" ,
243
+ "extraDetail2" : "There can be multiple entries" ,
244
+ "extraDetail3" : "use for reference purposes" ,
245
+ "extraDetail4" : "Do not use to maintain device state"
246
+ },
247
+ "capabilities" : [{
248
+ "type" : "AlexaInterface" ,
249
+ "interface" : "Alexa.ColorTemperatureController" ,
250
+ "version" : "3" ,
251
+ "properties" : {
252
+ "supported" : [{
253
+ "name" : "colorTemperatureInKelvin"
254
+ }],
255
+ "proactivelyReported" : "true" ,
256
+ "retrievable" : "true"
257
+ }
258
+ },
259
+ {
260
+ "type" : "AlexaInterface" ,
261
+ "interface" : "Alexa.EndpointHealth" ,
262
+ "version" : "3" ,
263
+ "properties" : {
264
+ "supported" : [{
265
+ "name" : "connectivity"
266
+ }],
267
+ "proactivelyReported" : "true" ,
268
+ "retrievable" : "true"
269
+ }
270
+ },
271
+ {
272
+ "type" : "AlexaInterface" ,
273
+ "interface" : "Alexa" ,
274
+ "version" : "3"
275
+ },
276
+ {
277
+ "type" : "AlexaInterface" ,
278
+ "interface" : "Alexa.ColorController" ,
279
+ "version" : "3" ,
280
+ "properties" : {
281
+ "supported" : [{
282
+ "name" : "color"
283
+ }],
284
+ "proactivelyReported" : "true" ,
285
+ "retrievable" : "true"
286
+ }
287
+ },
288
+ {
289
+ "type" : "AlexaInterface" ,
290
+ "interface" : "Alexa.PowerController" ,
291
+ "version" : "3" ,
292
+ "properties" : {
293
+ "supported" : [{
294
+ "name" : "powerState"
295
+ }],
296
+ "proactivelyReported" : "true" ,
297
+ "retrievable" : "true"
298
+ }
299
+ },
300
+ {
301
+ "type" : "AlexaInterface" ,
302
+ "interface" : "Alexa.BrightnessController" ,
303
+ "version" : "3" ,
304
+ "properties" : {
305
+ "supported" : [{
306
+ "name" : "brightness"
307
+ }],
308
+ "proactivelyReported" : "true" ,
309
+ "retrievable" : "true"
310
+ }
311
+ }
312
+ ]
313
+ }],
314
+ "scope" : {
315
+ "type" : "BearerToken" ,
316
+ "token" : token
317
+ }
318
+ }
319
+ }
320
+ }
321
+
322
+ # Proactive Discovery Deletions
323
+ alexa_pdu_delete = {
324
+ "event" : {
325
+ "header" : {
326
+ "messageId" : message_id ,
327
+ "name" : "DeleteReport" ,
328
+ "namespace" : "Alexa.Discovery" ,
329
+ "payloadVersion" : "3"
330
+ },
331
+ "payload" : {
332
+ "endpoints" : [{
333
+ "endpointId" : "appliance-001"
334
+ }
335
+ ],
336
+ "scope" : {
337
+ "type" : "BearerToken" ,
338
+ "token" : token
339
+ }
340
+ }
341
+ }
342
+ }
221
343
222
- response = requests .post (ALEXA_URI , headers = alexa_headers , data = json .dumps (alexa_params ), allow_redirects = True )
344
+ response = requests .post (ALEXA_URI , headers = alexa_headers , data = json .dumps (alexa_psu ), allow_redirects = True )
223
345
LOGGER .debug ("Request data: " + json .dumps (alexa_headers ))
224
- LOGGER .debug ("Request data: " + json .dumps (alexa_params ))
346
+ LOGGER .debug ("Request data: " + json .dumps (alexa_psu ))
225
347
LOGGER .debug ("Alexa response header: " + format (response .headers ))
226
348
LOGGER .debug ("Alexa response status: " + format (response .status_code ))
227
349
LOGGER .debug ("Alexa response body : " + format (response .text ))
0 commit comments