Skip to content

Commit cb19320

Browse files
Potential fix for history crash (#2817)
1 parent 9c0b649 commit cb19320

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎apps/predbat/ha.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,10 @@ def get_history(self, sensor, now, days=30, from_time=None, force_db=False):
653653
start = now - timedelta(days=days)
654654
end = now
655655
res = self.api_call("/api/history/period/{}".format(start.strftime(TIME_FORMAT_HA)), {"filter_entity_id": sensor, "end_time": end.strftime(TIME_FORMAT_HA)})
656-
return res
656+
if isinstance(res, list) and len(res) > 0:
657+
return res
658+
else:
659+
return None
657660

658661
async def set_state_external(self, entity_id, state, attributes={}):
659662
"""

0 commit comments

Comments
 (0)