Skip to content

Commit

Permalink
Add parameter to define attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFes committed Jul 3, 2023
1 parent 707714b commit 5b7e326
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Other optional fields are listed below:
### Source sensor settings
|name|type|default|example|description|
|---|---|---|---|---|
|`attr`|string|`raw_today`|`price_data`|The attribute which has the datetimes and prices used by the macro, defaults to `raw_today`|
|`time_key`|string|`"start"`|`"datetime"`|The key used in the attributes of your integration for the start times of the hours|
|`value_key`|string|`"value"`|`"price"`|The key used in the attributes of your integration for the price values|

Expand Down
4 changes: 2 additions & 2 deletions cheapest_energy_hours.jinja
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{%- macro cheapest_energy_hours(sensor, hours, start, end, time_key, value_key, include_today, include_tomorrow, lowest, mode, look_ahead, time_format, no_weight_points, weight) -%}
{%- macro cheapest_energy_hours(sensor, hours, start, end, attr, time_key, value_key, include_today, include_tomorrow, lowest, mode, look_ahead, time_format, no_weight_points, weight) -%}
{# Get data out of the selected entity #}
{%- set today = state_attr(sensor, 'raw_today') -%}
{%- set today = state_attr(sensor, attr | default('raw_today')) -%}
{%- set tomorrow = state_attr(sensor, 'raw_tomorrow') -%}
{%- set m = mode | default('start') -%}
{%- set wp = no_weight_points | default(1) | int(1) -%}
Expand Down

0 comments on commit 5b7e326

Please sign in to comment.