Эх сурвалжийг харах

修复编辑智能场景存在问题

locky 3 жил өмнө
parent
commit
6df440e9e8

+ 5 - 3
Controller/SensorGateway/SmartSceneController.py

@@ -557,7 +557,11 @@ class SmartSceneView(View):
             if not smart_scene_qs.exists():
                 return response.json(173)
 
-            msg = {}
+            scene_status = 1 if smart_scene_qs[0].is_enable else 0
+            msg = {
+                'smart_scene_id': smart_scene_id,
+                'scene_status': scene_status
+            }
             if conditions_dict['type'] == 2:  # 条件为选择子设备
                 if not sub_device_id:
                     return response.json(444, {'error param': 'subDeviceId'})
@@ -590,8 +594,6 @@ class SmartSceneView(View):
                 if not sub_device_qs.exists():
                     return response.json(173)
                 serial_number = sub_device_qs[0]['device__serial_number']
-                msg['smart_scene_id'] = smart_scene_id
-                msg['scene_status'] = 1 if smart_scene_qs[0].is_enable else 0
                 msg['sensor_type'] = int(conditions_dict['sensor']['device_type'])
                 msg['sensor_src'] = int(sub_device_qs[0]['src_addr'], 16)
                 msg['sensor_status'] = int(conditions_dict['sensor']['eventValues'][0]['event_type'])