Sfoglia il codice sorgente

修复杀虫灯控制返回值

yf_yzl 2 anni fa
parent
commit
1d4a4e9fa6
1 ha cambiato i file con 13 aggiunte e 0 eliminazioni
  1. 13 0
      smartfarming/api/views/forecast/send_control.py

+ 13 - 0
smartfarming/api/views/forecast/send_control.py

@@ -164,6 +164,19 @@ def device_control(request):
     response_code = response.status_code
     logger.warning(f"控制响应码:{response_code}")
     if response_code == 200:
+        ext = payload.get("ext", {})
+        if ext:
+            dattim = ext.get("dattim", "")
+            clt = ext.get("clt", "")
+        if int(device_type_id) == 2:
+            ext = payload.get("ext")
+            if dattim:
+                ext.pop("dattim")
+                ext["dat_f"] = dattim
+            if clt:
+                ext.pop("clt")
+                ext["clt_t"] = clt 
+            payload["ext"] = ext
         device_config = MongoDeviceConfig.objects.get(d_id=d_id)
         device_config.device_config = str(payload)
         device_config.save()