Skip to content

Commit 27391bc

Browse files
committed
Change time
1 parent 55b8327 commit 27391bc

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

tedge_modbus/reader/mapper.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@ class MappedMessage:
2020

2121
data: str = ""
2222
topic: str = ""
23-
time: str = datetime.now(timezone.utc).isoformat()
2423

2524
def serialize(self):
2625
"""Serialize message adding time if not present"""
2726
if "/cmd/" in self.topic:
2827
return self.data
2928
out = json.loads(self.data)
3029
if "time" not in out:
31-
out["time"] = self.time
30+
out["time"] = datetime.now(timezone.utc).isoformat()
3231
return json.dumps(out)
3332

3433
def extend_data(self, other_message):
@@ -52,7 +51,7 @@ def merge(d1: dict, d2: dict) -> dict:
5251
merged = merge(d1, d2)
5352

5453
if "time" not in merged:
55-
merged["time"] = self.time
54+
merged["time"] = datetime.now(timezone.utc).isoformat()
5655

5756
# Convert the merged dictionary back to a JSON string and update self.data
5857
self.data = json.dumps(merged)

0 commit comments

Comments
 (0)