From 7a8f6500e2e76e87f61ee46647a0d3c70004c34b Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 9 Feb 2015 19:12:12 -0800 Subject: [PATCH] Fix a bug in recorder. Fixes #33 --- homeassistant/components/recorder.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/recorder.py b/homeassistant/components/recorder.py index 488dfe9272f..e31f933e421 100644 --- a/homeassistant/components/recorder.py +++ b/homeassistant/components/recorder.py @@ -82,7 +82,7 @@ def run_information(point_in_time=None): covers point_in_time. """ _verify_instance() - if point_in_time is None: + if point_in_time is None or point_in_time > _INSTANCE.recording_start: return RecorderRun() run = _INSTANCE.query( @@ -105,13 +105,17 @@ def setup(hass, config): class RecorderRun(object): """ Represents a recorder run. """ def __init__(self, row=None): + self.end = None + if row is None: self.start = _INSTANCE.recording_start - self.end = None self.closed_incorrect = False else: self.start = datetime.fromtimestamp(row[1]) - self.end = datetime.fromtimestamp(row[2]) + + if row[2] is not None: + self.end = datetime.fromtimestamp(row[2]) + self.closed_incorrect = bool(row[3]) def entity_ids(self, point_in_time=None):