Skip to content

Commit 9463b7a

Browse files
authored
Merge pull request #106 from aanil/master
Futureproof sensorpush script
2 parents 43baa3e + 083e4f7 commit 9463b7a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sensorpush_to_statusdb.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ def process_data(sensors_json, samples_dict, start_time, nr_samples_requested):
378378

379379
# The dropna is needed since sometimes we get sparse samples
380380
# and might have hours without samples.
381-
hourly_mean = sensor_samples.resample("1H").mean().dropna()
382-
for hour, mean_val in hourly_mean.iteritems():
381+
hourly_mean = sensor_samples.resample("1h").mean().dropna()
382+
for hour, mean_val in hourly_mean.items():
383383
# Don't add any hourly mean values where we've saved more detailed info
384384
if not sd.time_in_any_extended_interval(hour):
385385
sd.saved_samples[hour.strftime("%Y-%m-%dT%H:%M:%S")] = round(
@@ -402,7 +402,7 @@ def main(
402402
try:
403403
if arg_start_date is None:
404404
# Start time is the start of the previous hour
405-
start_date_datetime = datetime.datetime.utcnow() - datetime.timedelta(
405+
start_date_datetime = datetime.datetime.now(datetime.UTC) - datetime.timedelta(
406406
hours=1
407407
)
408408
start_date_datetime = start_date_datetime.replace(

0 commit comments

Comments
 (0)