From c2d67f19a686b141672d619be62e3f53890f1328 Mon Sep 17 00:00:00 2001 From: Tsvi Mostovicz Date: Wed, 17 Apr 2019 22:52:05 +0000 Subject: [PATCH] Simplify the change for a default value Based on @balloob comment. Simplifying the code --- homeassistant/components/input_datetime/__init__.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/input_datetime/__init__.py b/homeassistant/components/input_datetime/__init__.py index af0a28aa34a..3b904ac6375 100644 --- a/homeassistant/components/input_datetime/__init__.py +++ b/homeassistant/components/input_datetime/__init__.py @@ -122,17 +122,14 @@ class InputDatetime(RestoreEntity): if old_state is not None: restore_val = old_state.state + if not restore_val: + restore_val = DEFAULT_VALUE + if not self.has_date: - if not restore_val: - restore_val = DEFAULT_VALUE.split()[1] self._current_datetime = dt_util.parse_time(restore_val) elif not self.has_time: - if not restore_val: - restore_val = DEFAULT_VALUE.split()[0] self._current_datetime = dt_util.parse_date(restore_val) else: - if not restore_val: - restore_val = DEFAULT_VALUE self._current_datetime = dt_util.parse_datetime(restore_val) @property