This commit is contained in:
xyj 2024-02-22 16:49:38 +08:00
parent 49d1e50bc6
commit a39bee3350
1 changed files with 12 additions and 1 deletions

13
xumu.py
View File

@ -339,7 +339,18 @@ async def past_seven_days(deviceId):
current_date = datetime.now().date() current_date = datetime.now().date()
tomorrow = current_date + timedelta(days=1) tomorrow = current_date + timedelta(days=1)
past_6_days_date = current_date - timedelta(days=6) past_6_days_date = current_date - timedelta(days=6)
sql = f"select MAX_VALUE(value) from root.warning.{deviceId} group by ([{past_6_days_date}, {tomorrow}), 1d)" the_decvice = await get_device(None, deviceId)
device_type = None
if the_decvice.code == 200:
device_values = the_decvice.data["values"]
if len(device_values) != 0:
device_type = device_values[1][0]
# 如果是空气设备,则有两个值
if device_type == 1:
sql = f"select MAX_VALUE(air_temperature),MAX_VALUE(air_humidity) from root.warning.{deviceId} group by ([{past_6_days_date}, {tomorrow}), 1d)"
# 如果是其他设备则有一个值RFID不算
else:
sql = f"select MAX_VALUE(value) from root.warning.{deviceId} group by ([{past_6_days_date}, {tomorrow}), 1d)"
send_json = { send_json = {
"sql": sql "sql": sql
} }