Fix plant error when adding new value (#25302)
* Only add value if int or floar * Simplify check * Simplify checkpull/25313/head
parent
49e2583b08
commit
fc384ca6d5
|
@ -363,7 +363,7 @@ class DailyHistory:
|
||||||
def add_measurement(self, value, timestamp=None):
|
def add_measurement(self, value, timestamp=None):
|
||||||
"""Add a new measurement for a certain day."""
|
"""Add a new measurement for a certain day."""
|
||||||
day = (timestamp or datetime.now()).date()
|
day = (timestamp or datetime.now()).date()
|
||||||
if value is None:
|
if not isinstance(value, (int, float)):
|
||||||
return
|
return
|
||||||
if self._days is None:
|
if self._days is None:
|
||||||
self._days = deque()
|
self._days = deque()
|
||||||
|
@ -388,4 +388,6 @@ class DailyHistory:
|
||||||
oldest = self._days.popleft()
|
oldest = self._days.popleft()
|
||||||
del self._max_dict[oldest]
|
del self._max_dict[oldest]
|
||||||
self._days.append(day)
|
self._days.append(day)
|
||||||
|
if not isinstance(value, (int, float)):
|
||||||
|
return
|
||||||
self._max_dict[day] = value
|
self._max_dict[day] = value
|
||||||
|
|
Loading…
Reference in New Issue