Commit 330c0b35 authored by ZZH's avatar ZZH

fix time 2026-6-23 23:09

parent 0a02612d
......@@ -9,6 +9,8 @@ DATE:2026/6/23 16:09
import asyncio
import json
import signal
import pendulum
from utils.time_format import CST, YMD_Hms
from gmqtt import Client as MQTTClient
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from apscheduler.triggers.cron import CronTrigger
......@@ -132,10 +134,16 @@ class FwdWaterMeterSrv:
except (ValueError, TypeError):
val = item.get("value")
# 标准化时间格式(2026-06-23 16: 00 -> 2026-06-23 16:00:00)
raw_time = item.get("time")
try:
t = pendulum.parse(raw_time, tz=CST).format(YMD_Hms)
except Exception:
t = raw_time
payload = {"cid": cid, "mid": sid, "nm": sid,
"data_topic": "water_sw",
"images": [{"t": item.get("time", ""),
"tags": {"meter_value": val}}]}
"images": [{"t": t, "tags": {"meter_value": val}}]}
# 动态生成 Topic 并推送
topic = f"{self.topic_prefix}/{sid}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment