|
@@ -757,11 +757,9 @@ class deviceStatus(TemplateView):
|
|
|
|
|
|
# 获取请求参数
|
|
# 获取请求参数
|
|
uid = request_dict.get('uid') # 客户端传入的唯一设备标识
|
|
uid = request_dict.get('uid') # 客户端传入的唯一设备标识
|
|
- object_classes = request_dict.get('object_classes', [])
|
|
|
|
- cause_type = request_dict.get('cause_type', 'PHYSICAL_INTERACTION')
|
|
|
|
skill_name = request_dict.get('skill_name', 'Anlapus') # 默认技能名称
|
|
skill_name = request_dict.get('skill_name', 'Anlapus') # 默认技能名称
|
|
|
|
|
|
- logger.info(f'uid: {uid}, object_classes: {object_classes}')
|
|
|
|
|
|
+ logger.info(f'uid: {uid}')
|
|
|
|
|
|
if not uid:
|
|
if not uid:
|
|
return JsonResponse({'code': 111, 'msg': '缺少必要参数: uid'})
|
|
return JsonResponse({'code': 111, 'msg': '缺少必要参数: uid'})
|
|
@@ -774,7 +772,6 @@ class deviceStatus(TemplateView):
|
|
return JsonResponse({'code': 404, 'msg': '设备未注册'})
|
|
return JsonResponse({'code': 404, 'msg': '设备未注册'})
|
|
|
|
|
|
user_id = device.user_id
|
|
user_id = device.user_id
|
|
- endpoint_id = device.uid # 使用设备UID作为endpoint_id
|
|
|
|
|
|
|
|
# 2. 通过用户ID获取Alexa授权信息
|
|
# 2. 通过用户ID获取Alexa授权信息
|
|
alexa_auth = AlexaAuthModel.objects.filter(
|
|
alexa_auth = AlexaAuthModel.objects.filter(
|
|
@@ -809,15 +806,15 @@ class deviceStatus(TemplateView):
|
|
time_of_sample = time_of_sample.split('.')[0] + 'Z'
|
|
time_of_sample = time_of_sample.split('.')[0] + 'Z'
|
|
|
|
|
|
# 5. 构造ChangeReport事件
|
|
# 5. 构造ChangeReport事件
|
|
- properties = []
|
|
|
|
- if object_classes:
|
|
|
|
- properties.append({
|
|
|
|
- "namespace": "Alexa.SmartVision.ObjectDetectionSensor",
|
|
|
|
- "name": "objectDetectionClasses",
|
|
|
|
- "value": object_classes,
|
|
|
|
- "timeOfSample": time_of_sample,
|
|
|
|
- "uncertaintyInMilliseconds": 0
|
|
|
|
- })
|
|
|
|
|
|
+ properties = [{
|
|
|
|
+ "namespace": "Alexa.SmartVision.ObjectDetectionSensor",
|
|
|
|
+ "name": "objectDetectionClasses",
|
|
|
|
+ "value": [{
|
|
|
|
+ "imageNetClass": "person"
|
|
|
|
+ }],
|
|
|
|
+ "timeOfSample": time_of_sample,
|
|
|
|
+ "uncertaintyInMilliseconds": 0
|
|
|
|
+ }]
|
|
|
|
|
|
payload = {
|
|
payload = {
|
|
"event": {
|
|
"event": {
|
|
@@ -832,12 +829,12 @@ class deviceStatus(TemplateView):
|
|
"type": "BearerToken",
|
|
"type": "BearerToken",
|
|
"token": current_access_token
|
|
"token": current_access_token
|
|
},
|
|
},
|
|
- "endpointId": endpoint_id
|
|
|
|
|
|
+ "endpointId": uid
|
|
},
|
|
},
|
|
"payload": {
|
|
"payload": {
|
|
"change": {
|
|
"change": {
|
|
"cause": {
|
|
"cause": {
|
|
- "type": cause_type
|
|
|
|
|
|
+ "type": "PHYSICAL_INTERACTION"
|
|
},
|
|
},
|
|
"properties": properties
|
|
"properties": properties
|
|
}
|
|
}
|