From a21673069baf6f767e2672bd8df7085d63fabc08 Mon Sep 17 00:00:00 2001
From: Paulus Schoutsen <paulus@paulusschoutsen.nl>
Date: Sun, 29 Mar 2015 09:42:24 -0700
Subject: [PATCH] Bugfix for states at point in time on new databases

---
 homeassistant/components/history.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/homeassistant/components/history.py b/homeassistant/components/history.py
index 10c4fdb41f6..c547190b91a 100644
--- a/homeassistant/components/history.py
+++ b/homeassistant/components/history.py
@@ -67,6 +67,10 @@ def get_states(point_in_time, entity_ids=None, run=None):
     if run is None:
         run = recorder.run_information(point_in_time)
 
+        # History did not run before point_in_time
+        if run is None:
+            return []
+
     where = run.where_after_start_run + "AND created < ? "
     where_data = [point_in_time]
 
-- 
GitLab