Jelajahi Sumber

修改添加智能场景接口当conditions参数type类型为1时相应处理

peng 3 tahun lalu
induk
melakukan
1d7395c779
1 mengubah file dengan 9 tambahan dan 8 penghapusan
  1. 9 8
      Controller/SensorGateway/SmartSceneController.py

+ 9 - 8
Controller/SensorGateway/SmartSceneController.py

@@ -250,14 +250,15 @@ class SmartSceneView(View):
                 else:
                     return response.json(444, {'error param': 'invalid isAllDay'})
 
-                sub_device_id = conditions_dict['sensor']['subDeviceId']
-                sub_device_qs = GatewaySubDevice.objects.filter(id=sub_device_id).values('src_addr').first()
-                msg = {
-                    'smart_scene_id': smart_scene_qs.id,
-                    'sensor_type': conditions_dict['sensor']['device_type'],
-                    'sensor_src': int(sub_device_qs['src_addr'], 16),
-                    'sensor_status': conditions_dict['sensor']['eventValues'][0]['value'],
-                }
+                msg = {}
+                if conditions_dict['type'] == '2':
+                    sub_device_id = conditions_dict['sensor']['subDeviceId']
+                    sub_device_qs = GatewaySubDevice.objects.filter(id=sub_device_id).values('src_addr').first()
+                    msg['smart_scene_id'] = smart_scene_qs.id
+                    msg['sensor_type'] = conditions_dict['sensor']['device_type']
+                    msg['sensor_src'] = int(sub_device_qs['src_addr'], 16)
+                    msg['sensor_status'] = conditions_dict['sensor']['eventValues'][0]['value']
+
                 task_list = []
                 for task in tasks_list:
                     task_temp = {