diff --git a/_docs/entities/electricity.md b/_docs/entities/electricity.md index 6d9d4417..08f6f84f 100644 --- a/_docs/entities/electricity.md +++ b/_docs/entities/electricity.md @@ -135,6 +135,10 @@ Each rate item has the following attributes This is `on` when you're within your tariff's off peak period, and `off` at all other times. This is [disabled by default](../faq.md#there-are-entities-that-are-disabled-why-are-they-disabled-and-how-do-i-enable-them). This will only be work if you're on a tariff with an off peak period. +!!! warning + + For intelligent tariffs, this sensor will only turn on during the standard off peak period. If you are wanting to know when extended off peak rates are available, you'll want to use the [is dispatching](./intelligent.md#is-dispatching) sensor. + ## Smart Meter Entities If your account information doesn't determine you have a smart meter, then you will have the following entities in a disabled state. If you enable these entities, they might not work correctly in this scenario. diff --git a/_docs/entities/intelligent.md b/_docs/entities/intelligent.md index 32a07703..c0d3767c 100644 --- a/_docs/entities/intelligent.md +++ b/_docs/entities/intelligent.md @@ -10,15 +10,21 @@ If you are on the [intelligent tariff](https://octopus.energy/smart/intelligent- `binary_sensor.octopus_energy_{{ACCOUNT_ID}}_intelligent_dispatching` -This sensor is used to determine if you're currently in a planned dispatch period (i.e. "smart-charge" determined by Octopus Energy) or are within the off peak period. +This sensor is used to determine if you're currently in a planned dispatch period (i.e. "smart-charge" determined by Octopus Energy) or are within the standard off peak period. + +!!! warning + + If you are using this to drive other automations for cheap rates (e.g. to fill batteries), you should perform additional checks to make sure your vehicle is actually charging. If it isn't, this sensor could be incorrectly on if during a dispatch outside of the standard off peak period and you will therefore not receive the off peak rate. + + If you are wanting to know when you are within a guaranteed off peak period, you should use the [off peak](./electricity.md#off-peak) sensor. !!! info - `planned_dispatches` is not supported for the following intelligent providers + This sensor is only partially supported for the following intelligent providers * OHME - `planned_dispatches` will therefore always return an empty collection and this entity will only turn on when within of the standard off peak period. + If you are supplied by one of the above providers, `planned_dispatches` will always return an empty collection and this entity will only turn on when within the standard off peak period. | Attribute | Type | Description | |-----------|------|-------------| diff --git a/custom_components/octopus_energy/utils/__init__.py b/custom_components/octopus_energy/utils/__init__.py index ca60fd1e..fed44909 100644 --- a/custom_components/octopus_energy/utils/__init__.py +++ b/custom_components/octopus_energy/utils/__init__.py @@ -84,7 +84,10 @@ def is_off_peak(current: datetime, rates): rate_information = get_current_rate_information(rates, current) - return off_peak_value is not None and rate_information is not None and value_inc_vat_to_pounds(off_peak_value) == rate_information["current_rate"]["value_inc_vat"] + return (off_peak_value is not None and + rate_information is not None and + rate_information["current_rate"]["is_intelligent_adjusted"] == False and + value_inc_vat_to_pounds(off_peak_value) == rate_information["current_rate"]["value_inc_vat"]) def private_rates_to_public_rates(rates: list): if rates is None: diff --git a/tests/unit/utils/test_is_off_peak.py b/tests/unit/utils/test_is_off_peak.py index b39ab66f..e3bffc00 100644 --- a/tests/unit/utils/test_is_off_peak.py +++ b/tests/unit/utils/test_is_off_peak.py @@ -38,4 +38,18 @@ async def test_when_off_peak_available_and_current_off_peak_then_true_returned() rate_data = create_rate_data(period_from, period_to, [10, 10, 30, 30]) # Act - assert is_off_peak(current, rate_data) == True \ No newline at end of file + assert is_off_peak(current, rate_data) == True + +@pytest.mark.asyncio +async def test_when_off_peak_available_and_current_off_peak_and_intelligent_adjusted_then_false_returned(): + # Arrange + period_from = datetime.strptime("2022-02-01T00:00:00Z", "%Y-%m-%dT%H:%M:%S%z") + period_to = datetime.strptime("2022-02-01T02:00:00Z", "%Y-%m-%dT%H:%M:%S%z") + current = datetime.strptime("2022-02-01T00:00:01Z", "%Y-%m-%dT%H:%M:%S%z") + + rate_data = create_rate_data(period_from, period_to, [10, 10, 30, 30]) + for rate in rate_data: + rate["is_intelligent_adjusted"] = True + + # Act + assert is_off_peak(current, rate_data) == False \ No newline at end of file