Refresh now() templates on second=0 (#42225)

This commit is contained in:
Anders Melchiorsen authored and GitHub committed 2020-10-23 00:11:02 +02:00
1 parent 4e917cf62c
commit cb0c937b3e
2 files changed
+15 -11

No files matched your search

+8 -6
View File
@@ -792,11 +792,13 @@ class _TrackTemplateResultInfo:
@callback
def _setup_time_listener(self, template: Template, has_time: bool) -> None:
if template in self._time_listeners:
self._time_listeners.pop(template)()
# now() or utcnow() has left the scope of the template
if not has_time:
if template in self._time_listeners:
# now() or utcnow() has left the scope of the template
self._time_listeners.pop(template)()
return
if template in self._time_listeners:
return
track_templates = [
@@ -809,8 +811,8 @@ class _TrackTemplateResultInfo:
def _refresh_from_time(now: datetime) -> None:
self._refresh(None, track_templates=track_templates)
self._time_listeners[template] = async_call_later(
self.hass, 60.45, _refresh_from_time
self._time_listeners[template] = async_track_utc_time_change(
self.hass, _refresh_from_time, second=0
)
@callback