Skip to content

Commit 92324c2

Browse files
author
committed
Deployed f3f3e12 with MkDocs version: 1.6.1
1 parent 8bcf0c7 commit 92324c2

5 files changed

Lines changed: 136 additions & 3 deletions

File tree

blueprints/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,15 @@
606606
</span>
607607
</a>
608608

609+
</li>
610+
611+
<li class="md-nav__item">
612+
<a href="#weather" class="md-nav__link">
613+
<span class="md-ellipsis">
614+
Weather
615+
</span>
616+
</a>
617+
609618
</li>
610619

611620
</ul>
@@ -746,6 +755,15 @@
746755
</span>
747756
</a>
748757

758+
</li>
759+
760+
<li class="md-nav__item">
761+
<a href="#weather" class="md-nav__link">
762+
<span class="md-ellipsis">
763+
Weather
764+
</span>
765+
</a>
766+
749767
</li>
750768

751769
</ul>
@@ -804,6 +822,9 @@ <h3 id="octopus-energy-and-carbon-intensity">Octopus Energy and Carbon Intensity
804822
<p class="admonition-title">Warning</p>
805823
<p>This automation will run when any of the underlying entities update. This make take a while initially. If you want the data available immediately, then you'll need to run the automation manually.</p>
806824
</div>
825+
<h3 id="weather">Weather<a class="headerlink" href="#weather" title="Permanent link">#</a></h3>
826+
<p><a href="https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fbottlecapdave.github.io%2FHomeAssistant-TargetTimeframes%2Fblueprints%2Ftarget_timeframes_weather.yaml">Install blueprint</a> | <a href="target_timeframes_weather.yaml">Source</a></p>
827+
<p>This blueprint will provide the data source based on the forecast of the provide weather sensor and will use the specified <code>Forecast attribute</code> as the value for the calculation of the target timeframes. The forecast will be refreshed every 30 minutes.</p>
807828

808829

809830

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
blueprint:
2+
name: Target Timeframes - Weather source
3+
description: Configures a target timeframe data source from Weather
4+
domain: automation
5+
author: BottlecapDave
6+
input:
7+
target_timeframe_data_source_sensor:
8+
name: Target timeframe data source sensor
9+
description: The data source sensor which represents the data source to update
10+
selector:
11+
entity:
12+
filter:
13+
- domain:
14+
- sensor
15+
integration: target_timeframes
16+
multiple: false
17+
weather_sensor:
18+
name: Weather sensor
19+
description: The weather sensor to get the forecast for.
20+
selector:
21+
entity:
22+
filter:
23+
- domain:
24+
- weather
25+
multiple: false
26+
forecast_attribute:
27+
name: Forecast attribute
28+
description: Type in the name of the desired forecast attribute to use as the value (e.g. "precipitation", "uv_index" or "temperature"). See the metadata of the result for possible options
29+
default: "condition"
30+
selector:
31+
text:
32+
variables:
33+
target_timeframe_data_source_sensor: !input target_timeframe_data_source_sensor
34+
weather_sensor: !input weather_sensor
35+
forecast_attribute: !input forecast_attribute
36+
millisecond_jitter: >
37+
{{ range(1, 1000) | random }}
38+
mode: queued
39+
max: 4
40+
triggers:
41+
- trigger: time_pattern
42+
minutes: '/30'
43+
condition: []
44+
action:
45+
# Add a bit of jitter so the API isn't hit at once
46+
- delay:
47+
milliseconds: >
48+
{{ millisecond_jitter }}
49+
- action: weather.get_forecasts
50+
target:
51+
entity_id: !input weather_sensor
52+
data:
53+
type: hourly
54+
response_variable: weather_forecast
55+
- variables:
56+
data_source_data: >
57+
{%- set forecast_items = weather_forecast[weather_sensor]["forecast"] -%}
58+
{%- set data = namespace(items=[]) -%}
59+
{%- for forecast in forecast_items -%}
60+
{%- set start = forecast["datetime"] | as_timestamp | timestamp_utc -%}
61+
{%- set end = ((start | as_datetime) + timedelta(minutes=30)) | as_timestamp | timestamp_utc -%}
62+
{%- set value = forecast[forecast_attribute] | float -%}
63+
{%- set new_item = [{ 'start': start , 'end': end, 'value': value, 'metadata': forecast }] -%}
64+
65+
{%- set data.items = data.items + new_item -%}
66+
67+
{%- set start = end -%}
68+
{%- set end = ((start | as_datetime) + timedelta(minutes=30)) | as_timestamp | timestamp_utc -%}
69+
{%- set new_item = [{ 'start': start , 'end': end, 'value': value, 'metadata': forecast }] -%}
70+
71+
{%- set data.items = data.items + new_item -%}
72+
{%- endfor -%}
73+
{{ data.items }}
74+
- action: target_timeframes.update_target_timeframe_data_source
75+
data: >
76+
{{ { 'data': data_source_data } }}
77+
target:
78+
entity_id: !input target_timeframe_data_source_sensor

search/search_index.json

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

setup/target_timeframe/index.html

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,15 @@
493493
</span>
494494
</a>
495495

496+
</li>
497+
498+
<li class="md-nav__item">
499+
<a href="#always" class="md-nav__link">
500+
<span class="md-ellipsis">
501+
Always
502+
</span>
503+
</a>
504+
496505
</li>
497506

498507
</ul>
@@ -965,6 +974,15 @@
965974
</span>
966975
</a>
967976

977+
</li>
978+
979+
<li class="md-nav__item">
980+
<a href="#always" class="md-nav__link">
981+
<span class="md-ellipsis">
982+
Always
983+
</span>
984+
</a>
985+
968986
</li>
969987

970988
</ul>
@@ -1169,10 +1187,26 @@ <h4 id="existing-target-values-havent-started-or-finished">Existing target value
11691187
<p>This will only evaluate target times if no target times have been calculated or all existing target times are either in the future or all existing target times are in the past. </p>
11701188
<p>For example, lets say we have a continuous target which looks between <code>00:00</code> and <code>08:00</code> has existing target times from <code>2023-01-02T01:00</code> to <code>2023-01-02T02:00</code>. </p>
11711189
<ul>
1172-
<li>If the current time is <code>2023-01-02T00:59</code>, then the target times will be re-evaluated and might change if the target period (i.e. <code>2023-01-02T00:30</code> to <code>2023-01-02T08:30</code>) has better values than the existing target times (e.g. the external weightings have changed).</li>
1190+
<li>If the current time is <code>2023-01-02T00:59</code>, then the target times will be re-evaluated and might change if the target period (i.e. <code>2023-01-02T00:30</code> to <code>2023-01-02T08:00</code>) has better values than the existing target times (e.g. the external weightings have changed).</li>
11731191
<li>If the current time is <code>2023-01-02T01:00</code>, the the target times will not be re-evaluated because we've entered our current target times, even if the evaluation period has cheaper times. </li>
1174-
<li>If the current time is <code>2023-01-02T02:01</code>, the the target times will be re-evaluated because our existing target times are in the past and will find the best times in the new rolling target period (i.e. <code>2023-01-02T02:00</code> to <code>2023-01-02T10:00</code>). </li>
1192+
<li>If the current time is <code>2023-01-02T02:01</code>, the the target times will be re-evaluated because our existing target times are in the past and will find the best times in the new target period (i.e. <code>2023-01-02T02:00</code> to <code>2023-01-02T08:00</code>). </li>
1193+
</ul>
1194+
<h4 id="always">Always<a class="headerlink" href="#always" title="Permanent link">#</a></h4>
1195+
<p>This will always evaluate the best target times for the target period, even if the sensor is in the middle of an existing target time period.</p>
1196+
<p>For example, lets say we have a continuous target which looks between <code>00:00</code> and <code>08:00</code> and has existing target times from <code>2023-01-02T01:00</code> to <code>2023-01-02T02:00</code>. </p>
1197+
<ul>
1198+
<li>If the current time is <code>2023-01-02T00:59</code>, then the target times will be re-evaluated and might change if the new target period (i.e. <code>2023-01-02T00:30</code> to <code>2023-01-02T08:30</code>) has better times than the existing target times.</li>
1199+
<li>If the current time is <code>2023-01-02T01:31</code>, then the target times will be re-evaluated and might change if the new target period (i.e. <code>2023-01-02T01:30</code> to <code>2023-01-02T08:30</code>) has better times than the existing target times.</li>
1200+
<li>If the current time is <code>2023-01-02T02:01</code>, the the target times will be re-evaluated because our existing target times are in the past and will find the best times in the new target period (i.e. <code>2023-01-02T02:00</code> to <code>2023-01-02T08:00</code>).</li>
11751201
</ul>
1202+
<div class="admonition note">
1203+
<p class="admonition-title">Note</p>
1204+
<p>This is only supported when <a href="#re-evaluate-within-time-frame">Re-evaluate within time frame</a> is enabled, otherwise it will behave the same as the other options.</p>
1205+
</div>
1206+
<div class="admonition warning">
1207+
<p class="admonition-title">Warning</p>
1208+
<p>This setting means that you could end up with the sensor not turning on for the fully requested hours as the target times might be moved ahead half way through the picked times. It also could mean that the sensor doesn't come on at all during the requested look ahead hours (e.g. 8) because the lowest period kept moving back. </p>
1209+
</div>
11761210
<h3 id="offset">Offset<a class="headerlink" href="#offset" title="Permanent link">#</a></h3>
11771211
<p>You may want your target value sensors to turn on a period of time before the optimum discovered period. For example, you may be turning on a robot vacuum cleaner for a 30 minute clean and want it to charge during the optimum period. For this, you'd use the <code>offset</code> field and set it to <code>-00:30:00</code>, which can be both positive and negative and go up to a maximum of 24 hours. This will shift when the sensor turns on relative to the optimum period. For example, if the optimum period is between <code>2023-01-18T10:00</code> and <code>2023-01-18T11:00</code> with an offset of <code>-00:30:00</code>, the sensor will turn on between <code>2023-01-18T09:30</code> and <code>2023-01-18T10:30</code>.</p>
11781212
<h3 id="re-evaluate-within-time-frame">Re-evaluate within time frame<a class="headerlink" href="#re-evaluate-within-time-frame" title="Permanent link">#</a></h3>

sitemap.xml.gz

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)