mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 21:25:13 +02:00
Set default value for input_datetime
If no initial value is set and no value is available to be restored, set the default value as specified in the docs to 1970-01-01 00:00.
This commit is contained in:
@@ -120,12 +120,14 @@ class InputDatetime(RestoreEntity):
|
||||
if old_state is not None:
|
||||
restore_val = old_state.state
|
||||
|
||||
if restore_val is not None:
|
||||
if not self.has_date:
|
||||
restore_val = restore_val if not None else '00:00:00'
|
||||
self._current_datetime = dt_util.parse_time(restore_val)
|
||||
elif not self.has_time:
|
||||
restore_val = restore_val if not None else '1970-01-01'
|
||||
self._current_datetime = dt_util.parse_date(restore_val)
|
||||
else:
|
||||
restore_val = restore_val if not None else '1970-01-01 00:00:00'
|
||||
self._current_datetime = dt_util.parse_datetime(restore_val)
|
||||
|
||||
@property
|
||||
|
Reference in New Issue
Block a user