|
@@ -358,15 +358,37 @@ class SmartSceneView(View):
|
|
|
return response.json(444, {'error param': 'subDeviceId'})
|
|
|
try:
|
|
|
click_scene_qs = SmartScene.objects.filter(user_id=user_id, sub_device_id=sub_device_id,
|
|
|
- conditions__contains='2161')
|
|
|
+ conditions__contains='2161').values('id', 'scene_name',
|
|
|
+ 'is_enable')
|
|
|
double_click_scene_qs = SmartScene.objects.filter(user_id=user_id, sub_device_id=sub_device_id,
|
|
|
- conditions__contains='2162')
|
|
|
- double_click_scene_qs = SmartScene.objects.filter(user_id=user_id, sub_device_id=sub_device_id,
|
|
|
- conditions__contains='2162')
|
|
|
- if not click_scene_qs.exists():
|
|
|
- return response.json(173)
|
|
|
- smart_scene_qs = click_scene_qs.values('id', 'scene_name', 'is_enable')
|
|
|
- return response.json(0, list(smart_scene_qs))
|
|
|
+ conditions__contains='2162').values('id', 'scene_name',
|
|
|
+ 'is_enable')
|
|
|
+ press_scene_qs = SmartScene.objects.filter(user_id=user_id, sub_device_id=sub_device_id,
|
|
|
+ conditions__contains='2163').values('id', 'scene_name',
|
|
|
+ 'is_enable')
|
|
|
+ scene_list = []
|
|
|
+ if click_scene_qs.exists():
|
|
|
+ scene_list.append({
|
|
|
+ 'scene_type': 1,
|
|
|
+ 'id': click_scene_qs[0]['id'],
|
|
|
+ 'scene_name': click_scene_qs[0]['scene_name'],
|
|
|
+ 'is_enable': click_scene_qs[0]['is_enable']
|
|
|
+ })
|
|
|
+ if double_click_scene_qs.exists():
|
|
|
+ scene_list.append({
|
|
|
+ 'scene_type': 2,
|
|
|
+ 'id': double_click_scene_qs[0]['id'],
|
|
|
+ 'scene_name': double_click_scene_qs[0]['scene_name'],
|
|
|
+ 'is_enable': double_click_scene_qs[0]['is_enable']
|
|
|
+ })
|
|
|
+ if press_scene_qs.exists():
|
|
|
+ scene_list.append({
|
|
|
+ 'scene_type': 3,
|
|
|
+ 'id': press_scene_qs[0]['id'],
|
|
|
+ 'scene_name': press_scene_qs[0]['scene_name'],
|
|
|
+ 'is_enable': press_scene_qs[0]['is_enable']
|
|
|
+ })
|
|
|
+ return response.json(0, scene_list)
|
|
|
except Exception as e:
|
|
|
return response.json(500, repr(e))
|
|
|
|
|
@@ -440,6 +462,7 @@ class SmartSceneView(View):
|
|
|
"""
|
|
|
编辑智能场景
|
|
|
@param request_dict: 请求参数
|
|
|
+ @param user_id: 用户id
|
|
|
@request_dict smartSceneId: 智能场景id
|
|
|
@param response: 响应对象
|
|
|
@return: response
|