lang преди 4 години
родител
ревизия
794122e407
променени са 1 файла, в които са добавени 126 реда и са изтрити 54 реда
  1. 126 54
      controller/index.py

+ 126 - 54
controller/index.py

@@ -399,60 +399,132 @@ class oa2DiscoveryDevice(TemplateView):
         region = request_dict.get("region", 'cn')
         logger = logging.getLogger('django')
 
-        api_uri = 'http://api.amazonalexa.com/v3/events'
-        requests_data = {
-            "event": {
-                "header": {
-                    "namespace": "Alexa.Discovery",
-                    "name": "AddOrUpdateReport",
-                    "payloadVersion": "3",
-                    "messageId": str(uuid.uuid4()),
-                },
-                "payload": {
-                    "endpoints": {
-                        "endpointId": 'HVTLKFJM6KDTAF9J111A',
-                        "manufacturerName": 'Zosi smart',
-                        "modelName": 'P1425-LE',
-                        "friendlyName": 'Camera one',
-                        "description": 'Camera one',
-                        "displayCategories": ['CAMERA'],
-                        "cookie": {},
-                        "capabilities": [
-                            {
-                                "type": 'AlexaInterface',
-                                "interface": 'Alexa.CameraStreamController',
-                                "version": '3',
-                                "cameraStreamConfigurations": [
-                                    {
-                                        "protocols": ['RTSP'],
-                                        "resolutions": [{'width': 1280, 'height': 720}],
-                                        "authorizationTypes": ['NONE'],
-                                        "videoCodecs":  ['H264'],
-                                        "audioCodecs": ['ACC']
-                                    }]
-                            },
-                            {
-                                "type": 'AlexaInterface',
-                                "interface": 'Alexa.MediaMetadata',
-                                "version": '3',
-                                "proactivelyReported": True,
-                                # "retrievable": True
-
-                            }
-                        ]
-                    },
-                    "scope": {
-                        "type": "BearerToken",
-                        "token": access_token
-                    }
-
-                }
-            }
-        }
-        request_res = requests.post(url=api_uri, data=requests_data)
-        request_json = request_res.json()
-        logger.info('1111-----request_json--------------------')
-        logger.info(request_json)
+        # api_uri = 'http://api.amazonalexa.com/v3/events'
+        # requests_data = {
+        #     "event": {
+        #         "header": {
+        #             "namespace": "Alexa.Discovery",
+        #             "name": "AddOrUpdateReport",
+        #             "payloadVersion": "3",
+        #             "messageId": str(uuid.uuid4())
+        #         },
+        #         "payload": {
+        #             "endpoints": [
+        #                 {
+        #                     "endpointId": "LKFJM6KDTAF9",
+        #                     "manufacturerName": "Zosi smart",
+        #                     "description": "Smart Light by Sample Manufacturer",
+        #                     "friendlyName": "Camera one",
+        #                     "displayCategories": [
+        #                         "CAMERA"
+        #                     ],
+        #                     "capabilities": [
+        #                         {
+        #                             "type": "AlexaInterface",
+        #                             "interface": "Alexa.CameraStreamController",
+        #                             "version": "3",
+        #                             "cameraStreamConfigurations": [
+        #                                 {
+        #                                     "protocols": ['RTSP'],
+        #                                     "resolutions": [{"width": 1280, "height": 720}],
+        #                                     "authorizationTypes": ["NONE"],
+        #                                     "videoCodecs":  ["H264"],
+        #                                     "audioCodecs": ["ACC"]
+        #                                 }]
+        #                         },
+        #                         {
+        #                             "type": "AlexaInterface",
+        #                             "interface": "Alexa.MediaMetadata",
+        #                             "version": "3",
+        #                         }
+        #                     ],
+        #                     "connections": [
+        #                     ],
+        #                     "cookie": {
+        #                     }
+        #                 }
+        #             ],
+        #             "scope": {
+        #                 "type": "BearerToken",
+        #                 "token": access_token
+        #             }
+        #         }
+        #     }
+        # }
+        # new_data = {
+        #     "event": {
+        #         "header": {
+        #             "namespace": "Alexa.Discovery",
+        #             "name": "AddOrUpdateReport",
+        #             "payloadVersion": "3",
+        #             "messageId": str(uuid.uuid4())
+        #         },
+        #         "payload": {
+        #             "endpoints": [
+        #                 {
+        #                     "endpointId": "HVTLKFJM6KDTAF9J111A",
+        #                     "manufacturerName": "Sample Manufacturer",
+        #                     "description": "Smart Light by Sample Manufacturer",
+        #                     "friendlyName": "Kitchen Light",
+        #                     "additionalAttributes":  {
+        #                         "manufacturer" : "Sample Manufacturer",
+        #                         "model" : "Sample Model",
+        #                         "serialNumber": "<the serial number of the device>",
+        #                         "firmwareVersion" : "<the firmware version of the device>",
+        #                         "softwareVersion": "<the software version of the device>",
+        #                         "customIdentifier": "<your custom identifier for the device>"
+        #                     },
+        #                     "displayCategories": [
+        #                         "LIGHT"
+        #                     ],
+        #                     "capabilities": [
+        #                         {
+        #                             "type": "AlexaInterface",
+        #                             "interface": "Alexa.PowerController",
+        #                             "version": "3",
+        #                             "properties": {
+        #                                 "supported": [
+        #                                     {
+        #                                         "name": "powerState"
+        #                                     }
+        #                                 ],
+        #                                 # "proactivelyReported": true,
+        #                                 # "retrievable": true
+        #                             }
+        #                         },
+        #                         {
+        #                             "type": "AlexaInterface",
+        #                             "interface": "Alexa.BrightnessController",
+        #                             "version": "3",
+        #                             "properties": {
+        #                                 "supported": [
+        #                                     {
+        #                                         "name": "brightness"
+        #                                     }
+        #                                 ],
+        #                                 # "proactivelyReported": True,
+        #                                 # "retrievable": True
+        #                             }
+        #                         }
+        #                     ],
+        #                     "connections": [
+        #                     ],
+        #                     "cookie": {
+        #                     }
+        #                 }
+        #             ],
+        #             "scope": {
+        #                 "type": "BearerToken",
+        #                 "token": access_token
+        #             }
+        #         }
+        #     }
+        # }
+        # request_res = requests.post(url=api_uri, data=new_data)
+        # request_json = request_res.json()
+        # return JsonResponse({'res': request_json})
+        # logger.info('1111-----request_json--------------------')
+        # logger.info(request_json)
 
 
         try: