浏览代码

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

peng 2 年之前
父节点
当前提交
4f615011d9
共有 1 个文件被更改,包括 4 次插入0 次删除
  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():
             if sub_device_qs.exists():
                 sub_device_qs.update(src_addr=src_addr)  # 更新短地址
                 sub_device_qs.update(src_addr=src_addr)  # 更新短地址
                 return response.json(174)
                 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():
             with transaction.atomic():
                 sub_device = GatewaySubDevice.objects.create(device_id=device_id, device_type=device_type,
                 sub_device = GatewaySubDevice.objects.create(device_id=device_id, device_type=device_type,