Skip to content

Commit

Permalink
Catch json decode error, allow decimal places in solcast update hours (
Browse files Browse the repository at this point in the history
…#1383)

* Catch json decode error, allow decimal places in solcast update hours

* [pre-commit.ci lite] apply automatic fixes

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
  • Loading branch information
springfall2008 and pre-commit-ci-lite[bot] authored Aug 21, 2024
1 parent 4742fbb commit 2bee727
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import asyncio
import json

THIS_VERSION = "v8.3.5"
THIS_VERSION = "v8.3.6"
PREDBAT_FILES = ["predbat.py", "config.py", "prediction.py", "utils.py", "inverter.py", "ha.py", "download.py", "unit_test.py"]
from download import predbat_update_move, predbat_update_download, check_install

Expand Down Expand Up @@ -805,7 +805,7 @@ def download_solcast_data(self):
api_keys = [api_keys]

period_data = {}
max_age = self.get_arg("solcast_poll_hours", 8) * 60
max_age = self.get_arg("solcast_poll_hours", 8.0) * 60

for api_key in api_keys:
params = {"format": "json", "api_key": api_key.strip()}
Expand Down Expand Up @@ -10366,7 +10366,12 @@ def load_current_config(self):
filepath = self.config_root + "/predbat_config.json"
if os.path.exists(filepath):
with open(filepath, "r") as file:
settings = json.load(file)
try:
settings = json.load(file)
except json.JSONDecodeError:
self.log("Warn: Failed to load Predbat settings from {}".format(filepath))
return

for name in settings:
current = self.config_index.get(name, None)
if current:
Expand Down

0 comments on commit 2bee727

Please sign in to comment.