|
@@ -189,13 +189,12 @@ class SmartSceneView(View):
|
|
tasks = request_dict.get('tasks', None)
|
|
tasks = request_dict.get('tasks', None)
|
|
is_all_day = request_dict.get('isAllDay', None)
|
|
is_all_day = request_dict.get('isAllDay', None)
|
|
|
|
|
|
- if not any([device_id, sub_device_id, is_all_day]):
|
|
|
|
- return response.json(444, {'error param': 'deviceId or subDeviceId or isAllDay'})
|
|
|
|
|
|
+ if not any([device_id, sub_device_id]):
|
|
|
|
+ return response.json(444, {'error param': 'deviceId or subDeviceId'})
|
|
if not all([conditions, tasks]):
|
|
if not all([conditions, tasks]):
|
|
return response.json(444, {'error param': 'conditions and tasks'})
|
|
return response.json(444, {'error param': 'conditions and tasks'})
|
|
|
|
|
|
now_time = int(time.time())
|
|
now_time = int(time.time())
|
|
- is_all_day = int(is_all_day) # 1: 全天, 2: 非全天
|
|
|
|
conditions_dict = eval(conditions)
|
|
conditions_dict = eval(conditions)
|
|
tasks_list = eval(tasks)
|
|
tasks_list = eval(tasks)
|
|
try:
|
|
try:
|
|
@@ -209,11 +208,15 @@ class SmartSceneView(View):
|
|
'scene_name': scene_name,
|
|
'scene_name': scene_name,
|
|
'conditions': conditions,
|
|
'conditions': conditions,
|
|
'tasks': tasks,
|
|
'tasks': tasks,
|
|
- 'is_all_day': is_all_day,
|
|
|
|
'created_time': now_time,
|
|
'created_time': now_time,
|
|
'updated_time': now_time,
|
|
'updated_time': now_time,
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ # 处理设置时间
|
|
|
|
+ if is_all_day:
|
|
|
|
+ is_all_day = int(is_all_day)
|
|
|
|
+ smart_scene_dict['is_all_day'] = is_all_day
|
|
|
|
+
|
|
# 处理传网关设备id和子设备id的情况
|
|
# 处理传网关设备id和子设备id的情况
|
|
if device_id:
|
|
if device_id:
|
|
smart_scene_dict['device_id'] = device_id
|
|
smart_scene_dict['device_id'] = device_id
|
|
@@ -229,7 +232,7 @@ class SmartSceneView(View):
|
|
serial_number = sub_device_qs[0]['device__serial_number']
|
|
serial_number = sub_device_qs[0]['device__serial_number']
|
|
|
|
|
|
with transaction.atomic():
|
|
with transaction.atomic():
|
|
- if is_all_day == 1:
|
|
|
|
|
|
+ if not is_all_day or is_all_day == 1: # 不设置时间或全天
|
|
smart_scene_qs = SmartScene.objects.create(**smart_scene_dict)
|
|
smart_scene_qs = SmartScene.objects.create(**smart_scene_dict)
|
|
elif is_all_day == 2:
|
|
elif is_all_day == 2:
|
|
if is_all_day == '0':
|
|
if is_all_day == '0':
|