update
This commit is contained in:
parent
fa44f490e2
commit
6f62fbca0d
32
config.py
32
config.py
|
@ -83,6 +83,38 @@ def rfid_deviceId(rfid, deviceId):
|
|||
]
|
||||
|
||||
|
||||
def is_warning(deviceId, v, t):
|
||||
match t:
|
||||
case 0:
|
||||
temperature = v[1]
|
||||
if 41.0 <= temperature or temperature <= 37.0:
|
||||
return True
|
||||
case 1:
|
||||
air_temperature = v[1]
|
||||
air_humidity = v[2]
|
||||
if 40.0 <= air_temperature or air_temperature <= 0:
|
||||
return True
|
||||
if 80.0 <= air_humidity or air_humidity <= 30.0:
|
||||
return True
|
||||
case 2:
|
||||
danqi = v[1]
|
||||
if danqi >= 1.24:
|
||||
return True
|
||||
case 3:
|
||||
jiawan = v[1]
|
||||
if jiawan > 1000:
|
||||
return True
|
||||
case 4:
|
||||
zaoyin = v[1]
|
||||
if zaoyin >= 55:
|
||||
return True
|
||||
case 5:
|
||||
yanwu = v[1]
|
||||
if yanwu >= 200:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def insert_to_warning_sql(deviceId, v, t):
|
||||
return {
|
||||
"devices": ["root.warning." + deviceId],
|
||||
|
|
12
xumu.py
12
xumu.py
|
@ -254,12 +254,12 @@ async def message_publish(data):
|
|||
r = requests.post(baseHost + insertUri, headers=headers, json=send_json)
|
||||
r = r.json()
|
||||
res.append(r)
|
||||
# TODO 如果是报警数据,则发送到报警数据表
|
||||
send_json = insert_to_warning_sql(deviceId, v, t)
|
||||
print(send_json)
|
||||
r = requests.post(baseHost + insertUri, headers=headers, json=send_json)
|
||||
r = r.json()
|
||||
res.append(r)
|
||||
if is_warning(deviceId, v, t):
|
||||
# 如果是报警数据,则发送到报警数据表
|
||||
send_json = insert_to_warning_sql(deviceId, v, t)
|
||||
r = requests.post(baseHost + insertUri, headers=headers, json=send_json)
|
||||
r = r.json()
|
||||
res.append(r)
|
||||
return BaseResponse(data=res)
|
||||
except Exception as e:
|
||||
return BaseResponse(code=500, msg=str(e))
|
||||
|
|
Loading…
Reference in New Issue