Skip to content

Commit

Permalink
fix: Updated how we determine if we're on an expired fixed tariff
Browse files Browse the repository at this point in the history
  • Loading branch information
BottlecapDave committed Oct 23, 2021
1 parent 37ee143 commit 075766f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion custom_components/octopus_energy/utils.py
Expand Up @@ -30,6 +30,7 @@ async def async_get_active_tariff_code(agreements, client):

latest_agreement = None
latest_valid_from = None
fixed_indicators = ["12M", "24M"]

# Find our latest agreement
for agreement in agreements:
Expand All @@ -53,7 +54,7 @@ async def async_get_active_tariff_code(agreements, client):

# If our latest agreement was a fixed rate and is in the past, then we must have moved into a variable rate
# (according to Octopus support), therefore we need to find the latest variable rate that
if latest_valid_to < now and "FIX" in tariff_parts["product_code"]:
if latest_valid_to < now and any(x in tariff_parts["product_code"] for x in fixed_indicators):
products = await client.async_get_products(True)

variable_product = None
Expand Down

0 comments on commit 075766f

Please sign in to comment.