|
@@ -39,6 +39,8 @@ class SmartSceneView(View):
|
|
|
return self.create_smart_scene(request_dict, user_id, response)
|
|
|
elif operation == 'scene-list': # 查询智能场景列表
|
|
|
return self.scene_list(request_dict, user_id, response)
|
|
|
+ elif operation == 'smart-button-scene-list': # 查询智能按钮场景列表
|
|
|
+ return self.smart_button_scene_list(request_dict, user_id, response)
|
|
|
elif operation == 'update-status': # 更新智能场景状态
|
|
|
return self.update_status(request_dict, response)
|
|
|
elif operation == 'detail': # 查询智能场景详情
|
|
@@ -241,11 +243,9 @@ class SmartSceneView(View):
|
|
|
with transaction.atomic():
|
|
|
if is_all_day is None: # 不设置时间
|
|
|
smart_scene_qs = SmartScene.objects.create(**smart_scene_dict)
|
|
|
- # 设备的time数据
|
|
|
- hour, minute = conditions_dict['time']['minutes'] / 60, conditions_dict['time']['minutes'] % 60
|
|
|
- start_time = int(hour * 3600 + minute * 60)
|
|
|
+ # 设备的time数据,分钟转为秒
|
|
|
time_dict = {
|
|
|
- 'start_time': start_time,
|
|
|
+ 'start_time': conditions_dict['time']['minutes'] * 60,
|
|
|
'repeat': conditions_dict['time']['repeat']
|
|
|
}
|
|
|
elif is_all_day == 1: # 全天
|
|
@@ -268,16 +268,11 @@ class SmartSceneView(View):
|
|
|
smart_scene_dict['effective_time_id'] = effective_time_id
|
|
|
smart_scene_qs = SmartScene.objects.create(**smart_scene_dict)
|
|
|
|
|
|
- # 设备的time数据
|
|
|
- start_hour, start_minute, end_hour, end_minute = \
|
|
|
- start_time / 60, start_time % 60, end_time / 60, end_time % 60
|
|
|
- start_time, end_time = \
|
|
|
- int(start_hour * 3600 + start_minute * 60), \
|
|
|
- int(end_hour * 3600 + end_minute * 60)
|
|
|
+ # 设备的time数据,分钟转为秒
|
|
|
time_dict = {
|
|
|
'is_all_day': is_all_day,
|
|
|
- 'start_time': start_time,
|
|
|
- 'end_time': end_time,
|
|
|
+ 'start_time': start_time * 60,
|
|
|
+ 'end_time': end_time * 60,
|
|
|
'repeat': repeat
|
|
|
}
|
|
|
else:
|
|
@@ -344,6 +339,34 @@ class SmartSceneView(View):
|
|
|
except Exception as e:
|
|
|
return response.json(500, repr(e))
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def smart_button_scene_list(request_dict, user_id, response):
|
|
|
+ """
|
|
|
+ 查询智能按钮场景列表
|
|
|
+ @param request_dict: 请求参数
|
|
|
+ @param user_id: 用户id
|
|
|
+ @request_dict subDeviceId: 子设备id
|
|
|
+ @param response: 响应对象
|
|
|
+ @return: response
|
|
|
+ """
|
|
|
+ sub_device_id = request_dict.get('subDeviceId', None)
|
|
|
+
|
|
|
+ if not sub_device_id:
|
|
|
+ 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')
|
|
|
+ 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))
|
|
|
+ except Exception as e:
|
|
|
+ return response.json(500, repr(e))
|
|
|
+
|
|
|
@staticmethod
|
|
|
def update_status(request_dict, response):
|
|
|
"""
|