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,13 +120,15 @@ 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 restore_val is not None:
|
if not self.has_date:
|
||||||
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)
|
self._current_datetime = dt_util.parse_time(restore_val)
|
||||||
elif not self.has_time:
|
elif not self.has_time:
|
||||||
self._current_datetime = dt_util.parse_date(restore_val)
|
restore_val = restore_val if not None else '1970-01-01'
|
||||||
else:
|
self._current_datetime = dt_util.parse_date(restore_val)
|
||||||
self._current_datetime = dt_util.parse_datetime(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
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
|
Reference in New Issue
Block a user