:art: Update ignore

huangqimin001 3 lat temu
rodzic
commit
2936369608
1 zmienionych plików z 13 dodań i 7 usunięć
  1. 13 7
      api/eqpt_views.py

+ 13 - 7
api/eqpt_views.py

@@ -291,19 +291,14 @@ def mqtt_upload_temperature(payload):
291 291
     except Exception:
292 292
         return
293 293
 
294
+    # 充电状态,true 充电,false 未充电
294 295
     chg_sta = payload.get('chg_sta', False)
295
-
296
+    # 充电状态,温度忽略
296 297
     if chg_sta:
297 298
         return
298 299
 
299
-    macid = payload.get('mac', '')
300
-    macid = f'{macid[:2]}:{macid[2:4]}:{macid[4:6]}:{macid[6:8]}:{macid[8:10]}:{macid[10:12]}'
301
-    current_time = payload.get('current_time', '')
302
-    start_stamp = end_stamp = tc.string_to_timestamp(current_time)
303
-    # raw_temp = payload.get('raw_temp', '')
304 300
     alg_temp = payload.get('alg_temp', '')
305 301
 
306
-    # temp = raw_temp.split(',') + alg_temp.split(',')
307 302
     temp = alg_temp.split(',')
308 303
     temp = [int(t) for t in temp if t]
309 304
 
@@ -312,6 +307,17 @@ def mqtt_upload_temperature(payload):
312 307
 
313 308
     temperature = max(temp) / 100
314 309
 
310
+    # 电量剩余 65%,有效电量范围[0, 100]
311
+    bat = payload.get('bat', 0)
312
+    # 电量剩余 100% + 温度超过 37 度,温度忽略
313
+    if bat == 100 and temperature > 37:
314
+        return
315
+
316
+    macid = payload.get('mac', '')
317
+    macid = f'{macid[:2]}:{macid[2:4]}:{macid[4:6]}:{macid[6:8]}:{macid[8:10]}:{macid[10:12]}'
318
+    current_time = payload.get('current_time', '')
319
+    start_stamp = end_stamp = tc.string_to_timestamp(current_time)
320
+
315 321
     try:
316 322
         eqpt = ThermometerEquipmentInfo.objects.get(macid=macid, status=True)
317 323
     except ThermometerEquipmentInfo.DoesNotExist: