Skip to content

Commit

Permalink
Write reading timestamp as int
Browse files Browse the repository at this point in the history
  • Loading branch information
desouco committed Apr 17, 2024
1 parent 26e8982 commit eb26eb4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions moisture_sensor_data_mqtt/moisture_sensor_data_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def mqtt_reader(client, msg):
if driest is None or wettest is None:
return

ts_secs = gv.now
ts_secs = int(gv.now)
ts = datetime.datetime.fromtimestamp(ts_secs)
if interval is not None and sensor in last_reading:
if last_reading[sensor]["ts"] + datetime.timedelta(minutes=interval) > ts:
Expand Down Expand Up @@ -213,6 +213,7 @@ def truncate_data_files(neme, **kw):

for line in input:
fields = line.split(",")
# timestamp can be float or int
if int(float(fields[0])) + retention > now:
output.write(line)

Expand All @@ -235,7 +236,7 @@ def load_moisture_data_mqtt_settings():
# If file does not exist return default value
settings = {
"sensors": {},
"last_truncate": gv.now,
"last_truncate": int(gv.now),
}


Expand Down

0 comments on commit eb26eb4

Please sign in to comment.