From a39bee335007cdd66565f2355d77ddd2261491ab Mon Sep 17 00:00:00 2001 From: xyj <1090822794@qq.com> Date: Thu, 22 Feb 2024 16:49:38 +0800 Subject: [PATCH] fixed --- xumu.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/xumu.py b/xumu.py index a8aa38e..75166f6 100644 --- a/xumu.py +++ b/xumu.py @@ -339,7 +339,18 @@ async def past_seven_days(deviceId): current_date = datetime.now().date() tomorrow = current_date + timedelta(days=1) 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 = { "sql": sql }