Browse Source

修复智能按钮编辑相同场景不能重复问题

peng 3 years ago
parent
commit
28c9f75bcb
1 changed files with 3 additions and 3 deletions
  1. 3 3
      Controller/SensorGateway/SmartSceneController.py

+ 3 - 3
Controller/SensorGateway/SmartSceneController.py

@@ -263,7 +263,6 @@ class SmartSceneView(View):
                     value = event_values['value'].replace(replace_str, '')
                     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',
                                                                                          'src_addr')
@@ -567,8 +566,9 @@ class SmartSceneView(View):
                 # 智能按钮不能创建触发条件相同的场景
                 if device_type == '216':
                     event_type = conditions_dict['sensor']['eventValues'][0]['event_type']
-                    smart_scene_temp_qs = smart_scene_qs.filter(sub_device_id=sub_device_id,
-                                                                conditions__contains=event_type)
+                    smart_scene_temp_qs = SmartScene.objects.filter(Q(sub_device_id=sub_device_id),
+                                                                    ~Q(id=smart_scene_id),
+                                                                    conditions__contains=event_type)
                     if smart_scene_temp_qs.exists():
                         return response.json(180)