mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 12:15:08 +02:00
Simplify the change for a default value
Based on @balloob comment. Simplifying the code
This commit is contained in:
@@ -122,17 +122,14 @@ class InputDatetime(RestoreEntity):
|
|||||||
if old_state is not None:
|
if old_state is not None:
|
||||||
restore_val = old_state.state
|
restore_val = old_state.state
|
||||||
|
|
||||||
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:
|
if not restore_val:
|
||||||
restore_val = DEFAULT_VALUE
|
restore_val = DEFAULT_VALUE
|
||||||
|
|
||||||
|
if not self.has_date:
|
||||||
|
self._current_datetime = dt_util.parse_time(restore_val)
|
||||||
|
elif not self.has_time:
|
||||||
|
self._current_datetime = dt_util.parse_date(restore_val)
|
||||||
|
else:
|
||||||
self._current_datetime = dt_util.parse_datetime(restore_val)
|
self._current_datetime = dt_util.parse_datetime(restore_val)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Reference in New Issue
Block a user