Skip to content

Commit

Permalink
Update Tibber template sensor because of change in 2024.11 (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFes authored Nov 7, 2024
1 parent f311849 commit 0b7b62b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions documentation/1-source_sensor.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,34 @@ template:
```
#### TIBBER
Home Assistant 2024.11.0 and above
```yaml
template:
- trigger:
- platform: time_pattern
hours: "/1"
- platform: homeassistant
event: start
action:
- service: tibber.get_prices
data:
start: "{{ (today_at() - timedelta(days=1)).strftime('%Y-%m-%d %H:%M:%S') }}"
end: "{{ (today_at() + timedelta(days=2)).strftime('%Y-%m-%d %H:%M:%S') }}"
response_variable: prices
sensor:
- name: tibber_forecast
state: "{{ prices.prices.values() | first | selectattr('start_time', '<=', utcnow().isoformat()) | map(attribute='price') | list | last }}"
attributes:
prices: >
{% set ns = namespace(prices=[]) %}
{% for i in prices.prices.values() | first %}
{% set n = dict(start_time = i.start_time, price = i.price) %}
{% set ns.prices = ns.prices + [n] %}
{% endfor %}
{{ ns.prices }}
```
Versions of Home Assitant before 2024.11.0 (2024.10 and lower)
```yaml
template:
- trigger:
Expand Down

0 comments on commit 0b7b62b

Please sign in to comment.