Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
ems_collector
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ZZH
ems_collector
Commits
330c0b35
Commit
330c0b35
authored
Jun 23, 2026
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix time 2026-6-23 23:09
parent
0a02612d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
fwd_water_meter.py
src/ems_water_grp/fwd_water_meter.py
+10
-2
No files found.
src/ems_water_grp/fwd_water_meter.py
View file @
330c0b35
...
@@ -9,6 +9,8 @@ DATE:2026/6/23 16:09
...
@@ -9,6 +9,8 @@ DATE:2026/6/23 16:09
import
asyncio
import
asyncio
import
json
import
json
import
signal
import
signal
import
pendulum
from
utils.time_format
import
CST
,
YMD_Hms
from
gmqtt
import
Client
as
MQTTClient
from
gmqtt
import
Client
as
MQTTClient
from
apscheduler.schedulers.asyncio
import
AsyncIOScheduler
from
apscheduler.schedulers.asyncio
import
AsyncIOScheduler
from
apscheduler.triggers.cron
import
CronTrigger
from
apscheduler.triggers.cron
import
CronTrigger
...
@@ -132,10 +134,16 @@ class FwdWaterMeterSrv:
...
@@ -132,10 +134,16 @@ class FwdWaterMeterSrv:
except
(
ValueError
,
TypeError
):
except
(
ValueError
,
TypeError
):
val
=
item
.
get
(
"value"
)
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
,
payload
=
{
"cid"
:
cid
,
"mid"
:
sid
,
"nm"
:
sid
,
"data_topic"
:
"water_sw"
,
"data_topic"
:
"water_sw"
,
"images"
:
[{
"t"
:
item
.
get
(
"time"
,
""
),
"images"
:
[{
"t"
:
t
,
"tags"
:
{
"meter_value"
:
val
}}]}
"tags"
:
{
"meter_value"
:
val
}}]}
# 动态生成 Topic 并推送
# 动态生成 Topic 并推送
topic
=
f
"{self.topic_prefix}/{sid}"
topic
=
f
"{self.topic_prefix}/{sid}"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment