From 5552a5be708ba61f74ee56ceaca414dbbeb6aa41 Mon Sep 17 00:00:00 2001 From: cgtobi Date: Fri, 19 Jul 2019 16:09:29 +0200 Subject: [PATCH] Fix plant error when adding new value (#25302) * Only add value if int or floar * Simplify check * Simplify check --- homeassistant/components/plant/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/plant/__init__.py b/homeassistant/components/plant/__init__.py index c4abc916c3f..0b2ffe6d8cb 100644 --- a/homeassistant/components/plant/__init__.py +++ b/homeassistant/components/plant/__init__.py @@ -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