|
@@ -256,6 +256,12 @@ class SmartSceneView(View):
|
|
|
if not sub_device_id:
|
|
|
return response.json(444, {'error param': 'subDeviceId'})
|
|
|
|
|
|
+ # 查询数据
|
|
|
+ sub_device_qs = GatewaySubDevice.objects.filter(id=sub_device_id).\
|
|
|
+ values('device__serial_number', 'ieee_addr', 'is_tampered')
|
|
|
+ if not sub_device_qs.exists():
|
|
|
+ return response.json(173)
|
|
|
+
|
|
|
if cls.time_conflict(sub_device_id, conditions, is_all_day, request_dict):
|
|
|
return response.json(182)
|
|
|
|
|
@@ -268,6 +274,10 @@ class SmartSceneView(View):
|
|
|
if smart_scene_qs.exists():
|
|
|
return response.json(180)
|
|
|
|
|
|
+ # 紧急按钮打开时,创建的场景状态默认为关闭
|
|
|
+ if sub_device_qs[0]['is_tampered'] == 1:
|
|
|
+ smart_scene_dict['is_enable'] = False
|
|
|
+
|
|
|
# 温湿度传感器返回温湿度
|
|
|
elif device_type == SENSOR_TYPE['tem_hum_sensor']:
|
|
|
event_values = conditions_dict['sensor']['eventValues'][0]
|
|
@@ -281,10 +291,6 @@ class SmartSceneView(View):
|
|
|
msg['sensor_data'] = float(value)
|
|
|
|
|
|
smart_scene_dict['sub_device_id'] = sub_device_id
|
|
|
- sub_device_qs = GatewaySubDevice.objects.filter(id=sub_device_id).values('device__serial_number',
|
|
|
- 'ieee_addr')
|
|
|
- if not sub_device_qs.exists():
|
|
|
- return response.json(173)
|
|
|
serial_number = sub_device_qs[0]['device__serial_number']
|
|
|
|
|
|
msg['sensor_type'] = int(conditions_dict['sensor']['device_type'])
|