Skip to content

Commit dcb1a64

Browse files
author
committed
Deployed 7c01073 with MkDocs version: 1.6.1
1 parent c658165 commit dcb1a64

File tree

4 files changed

+35
-20
lines changed

4 files changed

+35
-20
lines changed

blueprints/target_timeframes_octopus_energy_carbon_intensity.yaml

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ blueprint:
1414
- sensor
1515
integration: target_timeframes
1616
multiple: false
17-
octopus_energy_previous_day_rates:
18-
name: Previous day rates
19-
description: The previous day rates event sensor supplied by Octopus Energy. More information can be found at https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/entities/electricity/#previous-day-rates.
20-
selector:
21-
entity:
22-
filter:
23-
- domain:
24-
- event
25-
integration: octopus_energy
26-
multiple: false
2717
octopus_energy_current_day_rates:
2818
name: Current day rates
2919
description: The current day rates event sensor supplied by Octopus Energy. More information can be found at https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/entities/electricity/#current-day-rates.
@@ -61,6 +51,13 @@ blueprint:
6151
selector:
6252
number:
6353
mode: box
54+
octopus_energy_weighting:
55+
name: Octopus Energy rate weighting
56+
description: The weighting to apply to the Octopus Energy rates when calculating the final value for the period.
57+
default: 0.7
58+
selector:
59+
number:
60+
mode: box
6461
carbon_intensity_current_day_rates:
6562
name: Current day rates
6663
description: The current day rates event sensor supplied by Carbon Intensity. More information can be found at https://bottlecapdave.github.io/HomeAssistant-CarbonIntensity/entities/#current-day-rates.
@@ -81,20 +78,26 @@ blueprint:
8178
- event
8279
integration: carbon_intensity
8380
multiple: false
81+
carbon_intensity_weighting:
82+
name: Carbon Intensity forecast weighting
83+
description: The weighting to apply to the Carbon Intensity forecast when calculating the final value for the period.
84+
default: 0.3
85+
selector:
86+
number:
87+
mode: box
8488
variables:
8589
target_timeframe_data_source_sensor: !input target_timeframe_data_source_sensor
86-
octopus_energy_previous_day_rates: !input octopus_energy_previous_day_rates
8790
octopus_energy_current_day_rates: !input octopus_energy_current_day_rates
8891
octopus_energy_next_day_rates: !input octopus_energy_next_day_rates
8992
octopus_energy_free_electricity: !input octopus_energy_free_electricity
9093
octopus_energy_free_electricity_weighting: !input octopus_energy_free_electricity_weighting
9194
carbon_intensity_current_day_rates: !input carbon_intensity_current_day_rates
9295
carbon_intensity_next_day_rates: !input carbon_intensity_next_day_rates
96+
octopus_energy_weighting: !input octopus_energy_weighting
97+
carbon_intensity_weighting: !input carbon_intensity_weighting
9398
mode: queued
9499
max: 4
95100
triggers:
96-
- platform: state
97-
entity_id: !input octopus_energy_previous_day_rates
98101
- platform: state
99102
entity_id: !input octopus_energy_current_day_rates
100103
- platform: state
@@ -110,9 +113,6 @@ action:
110113
- action: target_timeframes.update_target_timeframe_data_source
111114
data: >
112115
{%- set all_oe_rates = [] -%}
113-
{%- if state_attr(octopus_energy_previous_day_rates, 'rates') != None -%}
114-
{%- set all_oe_rates = all_oe_rates + state_attr(octopus_energy_previous_day_rates, 'rates') -%}
115-
{%- endif -%}
116116
{%- if state_attr(octopus_energy_current_day_rates, 'rates') != None -%}
117117
{%- set all_oe_rates = all_oe_rates + state_attr(octopus_energy_current_day_rates, 'rates') -%}
118118
{%- endif -%}
@@ -132,12 +132,19 @@ action:
132132
{%- set all_ci_rates = all_ci_rates + state_attr(carbon_intensity_next_day_rates, 'rates') -%}
133133
{%- endif -%}
134134
135+
{%- set min_rate = all_oe_rates | map(attribute='value_inc_vat') | min -%}
136+
{%- set max_rate = all_oe_rates | map(attribute='value_inc_vat') | max -%}
137+
{%- set min_carbon = all_ci_rates | map(attribute='intensity_forecast') | min -%}
138+
{%- set max_carbon = all_ci_rates | map(attribute='intensity_forecast') | max -%}
139+
{%- set rate_diff = max_rate - min_rate if max_rate - min_rate != 0 else 1 %}
140+
{%- set carbon_diff = max_carbon - min_carbon if max_carbon - min_carbon != 0 else 1 %}
141+
135142
{%- set data = namespace(new_rates=[]) -%}
136143
{%- for rate in all_oe_rates -%}
137144
{%- set start = rate["start"] | as_timestamp | timestamp_utc -%}
138145
{%- set end = rate["end"] | as_timestamp | timestamp_utc -%}
139-
{%- set value = rate["value_inc_vat"] | float -%}
140-
146+
{%- set value = (((rate["value_inc_vat"] | float - min_rate) / rate_diff) * octopus_energy_weighting) -%}
147+
141148
{%- set free_namespace = namespace(is_free=False) -%}
142149
{%- for free_session in free_electricity_rates -%}
143150
{%- set free_start = free_session["start"] | as_timestamp | timestamp_utc -%}
@@ -158,7 +165,7 @@ action:
158165
159166
{%- set metadata = { "rate": rate["value_inc_vat"], "is_capped": rate["is_capped"] } -%}
160167
{%- if carbon_intensity_namespace.rate -%}
161-
{%- set value = value * (carbon_intensity_namespace.rate["intensity_forecast"] | float) -%}
168+
{%- set value = value + (((carbon_intensity_namespace.rate["intensity_forecast"] | float - min_carbon) / carbon_diff) * carbon_intensity_weighting) -%}
162169
{%- set metadata = dict(metadata.items(), carbon_intensity=carbon_intensity_namespace.rate["intensity_forecast"] | float) -%}
163170
{%- endif -%}
164171

search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

services/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,10 @@ <h2 id="target-timeframes">Target Timeframes<a class="headerlink" href="#target-
933933
<p>The following services are available if you have set up at least one <a href="../setup/target_timeframe/">target timeframe</a>.</p>
934934
<h3 id="target_timeframesupdate_target_timeframe_config">target_timeframes.update_target_timeframe_config<a class="headerlink" href="#target_timeframesupdate_target_timeframe_config" title="Permanent link">#</a></h3>
935935
<p>For updating a given <a href="../setup/target_timeframe/">target timeframe's</a> config. This allows you to change target timeframes sensors dynamically based on other outside criteria (e.g. you need to adjust the target hours to top up home batteries).</p>
936+
<div class="admonition warning">
937+
<p class="admonition-title">Warning</p>
938+
<p>This will cause the sensor to re-evaluate the target times, which may result in different times being picked.</p>
939+
</div>
936940
<table>
937941
<thead>
938942
<tr>
@@ -1038,6 +1042,10 @@ <h2 id="rolling-target-timeframes">Rolling Target Timeframes<a class="headerlink
10381042
<p>The following services are available if you have set up at least one <a href="../setup/rolling_target_timeframe/">rolling target timeframe</a>.</p>
10391043
<h3 id="target_timeframesupdate_rolling_target_timeframe_config">target_timeframes.update_rolling_target_timeframe_config<a class="headerlink" href="#target_timeframesupdate_rolling_target_timeframe_config" title="Permanent link">#</a></h3>
10401044
<p>For updating a given <a href="../setup/rolling_target_timeframe/">rolling target timeframe's</a> config. This allows you to change rolling target timeframes sensors dynamically based on other outside criteria (e.g. you need to adjust the target hours to top up home batteries).</p>
1045+
<div class="admonition warning">
1046+
<p class="admonition-title">Warning</p>
1047+
<p>This will cause the sensor to re-evaluate the target times, which may result in different times being picked.</p>
1048+
</div>
10411049
<table>
10421050
<thead>
10431051
<tr>

sitemap.xml.gz

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)