|
@@ -37,8 +37,6 @@ class SmartSceneView(View):
|
|
|
return self.condition_devices(request_dict, response)
|
|
|
if operation == 'task-devices': # 添加任务-查询设备
|
|
|
return self.task_devices(request_dict, user_id, response)
|
|
|
- elif operation == 'get-device-information':
|
|
|
- return self.get_device_information(request_dict, response)
|
|
|
elif operation == 'create': # 创建智能场景
|
|
|
return self.create_smart_scene(request_dict, user_id, response)
|
|
|
|
|
@@ -82,7 +80,7 @@ class SmartSceneView(View):
|
|
|
return response.json(500, repr(e))
|
|
|
|
|
|
@staticmethod
|
|
|
- def task_devices(request_dict, user_id, response):
|
|
|
+ def task_devices(request_dict, response):
|
|
|
"""
|
|
|
添加任务-查询设备
|
|
|
@param request_dict: 请求参数
|
|
@@ -95,9 +93,34 @@ class SmartSceneView(View):
|
|
|
|
|
|
if not all([device_id]):
|
|
|
return response.json(444)
|
|
|
+
|
|
|
+ device_qs = FamilyRoomDevice.objects.filter(device_id=device_id,sub_device=0)
|
|
|
+ if not device_qs.exists():
|
|
|
+ return response.json(173)
|
|
|
+ gate_way = GatewaySubDevice.objects.filter(device_id=device_id)
|
|
|
+ if not gate_way.exists():
|
|
|
+ return response.json(173)
|
|
|
try:
|
|
|
- device_info_qs = GatewaySubDevice.objects.filter(device__userID_id=user_id)
|
|
|
- return response.json(0)
|
|
|
+ gate_way = gate_way.values('id', 'device_type', 'nickname', 'status')
|
|
|
+ gate_way_list = []
|
|
|
+ for gate_int in gate_way:
|
|
|
+ gate_way.exists()
|
|
|
+ gate_way_list.append(gate_int)
|
|
|
+ device_qs = device_qs.values('family_id', 'device_id', 'room_id', 'device__Type', 'device__NickName',
|
|
|
+ 'device__UID')
|
|
|
+ device_qs_list = []
|
|
|
+ for device_int in device_qs:
|
|
|
+ device_qs.exists()
|
|
|
+ device_qs_list.append(device_int)
|
|
|
+ device_qs = device_qs.first()
|
|
|
+ room_id = device_qs['room_id']
|
|
|
+ room_qs = FamilyRoom.objects.filter(id=room_id).values('name')
|
|
|
+ room_qs_list = []
|
|
|
+ for room_int in room_qs:
|
|
|
+ room_qs.exists()
|
|
|
+ room_qs_list.append(room_int)
|
|
|
+ repe = {'device_qs_list': device_qs_list, 'gate_way_list': gate_way_list, 'room_qs_list': room_qs_list}
|
|
|
+ return response.json(0, repe)
|
|
|
except Exception as e:
|
|
|
return response.json(500, repr(e))
|
|
|
|
|
@@ -170,44 +193,3 @@ class SmartSceneView(View):
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
|
return response.json(500, repr(e))
|
|
|
-
|
|
|
- @staticmethod
|
|
|
- def get_device_information(request_dict, response):
|
|
|
-
|
|
|
- device_id = request_dict.get('deviceId', None)
|
|
|
- if not device_id:
|
|
|
- return response.json(444)
|
|
|
- device_qs = FamilyRoomDevice.objects.filter(device_id=device_id, sub_device=0)
|
|
|
- if not device_qs.exists():
|
|
|
- return response.json(173)
|
|
|
- gate_way = GatewaySubDevice.objects.filter(device_id=device_id)
|
|
|
- if not gate_way.exists():
|
|
|
- return response.json(173)
|
|
|
- try:
|
|
|
- gate_way = gate_way.values('id', 'device_type', 'nickname', 'status')
|
|
|
- gate_way_list = []
|
|
|
- for gate_int in gate_way:
|
|
|
- gate_way.exists()
|
|
|
- gate_way_list.append(gate_int)
|
|
|
- device_qs = device_qs.values('family_id', 'device_id', 'room_id', 'device__Type', 'device__NickName',
|
|
|
- 'device__UID')
|
|
|
- device_qs_list = []
|
|
|
- for device_int in device_qs:
|
|
|
- device_qs.exists()
|
|
|
- device_qs_list.append(device_int)
|
|
|
- device_qs = device_qs.first()
|
|
|
- family_id = device_qs['family_id']
|
|
|
- room_id = device_qs['room_id']
|
|
|
- room_qs = FamilyRoom.objects.filter(id=room_id).values('name')
|
|
|
- room_qs_list = []
|
|
|
- for room_int in room_qs:
|
|
|
- room_qs.exists()
|
|
|
- room_qs_list.append(room_int)
|
|
|
-
|
|
|
- repe = {'device_qs_list': device_qs_list, 'gate_way_list': gate_way_list, 'room_qs_list': room_qs_list}
|
|
|
-
|
|
|
- return response.json(0, repe)
|
|
|
-
|
|
|
- except Exception as e:
|
|
|
- print(e.args)
|
|
|
- return response.json(500)
|