Browse Source

添加子设备是判断只能添加一个智能按钮

peng 2 years ago
parent
commit
4f615011d9
1 changed files with 4 additions and 0 deletions
  1. 4 0
      Controller/SensorGateway/SubDeviceController.py

+ 4 - 0
Controller/SensorGateway/SubDeviceController.py

@@ -106,6 +106,10 @@ class GatewaySubDeviceView(View):
             if sub_device_qs.exists():
                 sub_device_qs.update(src_addr=src_addr)  # 更新短地址
                 return response.json(174)
+            if device_type == SENSOR_TYPE['smart_button']:
+                sub_device_qs = GatewaySubDevice.objects.filter(device_id=device_id, device_type=device_type)
+                if sub_device_qs.exists():
+                    return response.json(174)
 
             with transaction.atomic():
                 sub_device = GatewaySubDevice.objects.create(device_id=device_id, device_type=device_type,