Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import requests
import yaml

THIS_VERSION = "v7.15.11"
THIS_VERSION = "v7.15.12"
TIME_FORMAT = "%Y-%m-%dT%H:%M:%S%z"
TIME_FORMAT_SECONDS = "%Y-%m-%dT%H:%M:%S.%f%z"
TIME_FORMAT_OCTOPUS = "%Y-%m-%d %H:%M:%S%z"
Expand Down Expand Up @@ -9962,15 +9962,15 @@ def fetch_octopus_rates(self, entity_id, adjust_key=None):
else:
current_rate_id = entity_id

data_import = self.get_state(entity_id=current_rate_id, attribute="rates")
data_import = (
self.get_state(entity_id=current_rate_id, attribute="rates")
or self.get_state(entity_id=current_rate_id, attribute="all_rates")
or self.get_state(entity_id=current_rate_id, attribute="raw_today")
)
if data_import:
data_all += data_import
else:
data_import = self.get_state(entity_id=current_rate_id, attribute="all_rates")
if data_import:
data_all += data_import
else:
self.log("WARN: No Octopus data in sensor {} attribute 'all_rates'".format(current_rate_id))
self.log("WARN: No Octopus data in sensor {} attribute 'all_rates' / 'rates' / 'raw_today'".format(current_rate_id))

# Next rates
if "_current_rate" in entity_id:
Expand All @@ -9997,6 +9997,8 @@ def fetch_octopus_rates(self, entity_id, adjust_key=None):
from_key = "start"
to_key = "end"
scale = 100.0
if rate_key not in data_all[0]:
rate_key = "value"
rate_data = self.minute_data(
data_all, self.forecast_days + 1, self.midnight_utc, rate_key, from_key, backwards=False, to_key=to_key, adjust_key=adjust_key, scale=scale
)
Expand Down