Fix a bug in recorder. Fixes #33

This commit is contained in:
Paulus Schoutsen 2015-02-09 19:12:12 -08:00
parent 50bb4daeaa
commit 7a8f6500e2

View File

@ -82,7 +82,7 @@ def run_information(point_in_time=None):
covers point_in_time. """ covers point_in_time. """
_verify_instance() _verify_instance()
if point_in_time is None: if point_in_time is None or point_in_time > _INSTANCE.recording_start:
return RecorderRun() return RecorderRun()
run = _INSTANCE.query( run = _INSTANCE.query(
@ -105,13 +105,17 @@ def setup(hass, config):
class RecorderRun(object): class RecorderRun(object):
""" Represents a recorder run. """ """ Represents a recorder run. """
def __init__(self, row=None): def __init__(self, row=None):
self.end = None
if row is None: if row is None:
self.start = _INSTANCE.recording_start self.start = _INSTANCE.recording_start
self.end = None
self.closed_incorrect = False self.closed_incorrect = False
else: else:
self.start = datetime.fromtimestamp(row[1]) self.start = datetime.fromtimestamp(row[1])
if row[2] is not None:
self.end = datetime.fromtimestamp(row[2]) self.end = datetime.fromtimestamp(row[2])
self.closed_incorrect = bool(row[3]) self.closed_incorrect = bool(row[3])
def entity_ids(self, point_in_time=None): def entity_ids(self, point_in_time=None):