We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9513b48 commit d15d1f5Copy full SHA for d15d1f5
openwisp_monitoring/device/writer.py
@@ -1,6 +1,7 @@
1
import logging
2
from copy import deepcopy
3
from datetime import datetime, timedelta
4
+from django.utils import timezone
5
6
from django.contrib.contenttypes.models import ContentType
7
from django.core.exceptions import ObjectDoesNotExist
@@ -60,7 +61,10 @@ def _append_metric_data(
60
61
)
62
63
def write(self, data, time=None, current=False):
- time = datetime.strptime(time, "%d-%m-%Y_%H:%M:%S.%f").replace(tzinfo=UTC)
64
+ if time:
65
+ time = datetime.strptime(time, "%d-%m-%Y_%H:%M:%S.%f").replace(tzinfo=UTC)
66
+ else:
67
+ time = timezone.now()
68
self._init_previous_data()
69
self.device_data.data = data
70
# saves raw device data
0 commit comments