Fix plant error when adding new value (#25302)
* Only add value if int or floar * Simplify check * Simplify check
This commit is contained in:
parent
49e2583b08
commit
fc384ca6d5
1 changed files with 3 additions and 1 deletions
|
@ -363,7 +363,7 @@ class DailyHistory:
|
|||
def add_measurement(self, value, timestamp=None):
|
||||
"""Add a new measurement for a certain day."""
|
||||
day = (timestamp or datetime.now()).date()
|
||||
if value is None:
|
||||
if not isinstance(value, (int, float)):
|
||||
return
|
||||
if self._days is None:
|
||||
self._days = deque()
|
||||
|
@ -388,4 +388,6 @@ class DailyHistory:
|
|||
oldest = self._days.popleft()
|
||||
del self._max_dict[oldest]
|
||||
self._days.append(day)
|
||||
if not isinstance(value, (int, float)):
|
||||
return
|
||||
self._max_dict[day] = value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue