Crall

Untitled

Oct 20th, 2025
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.01 KB | Source Code | 0 0
  1. ******* Nordpool templare för HA price timline card: https://github.com/Neisi/ha-price-timeline-card *********
  2.  
  3.  
  4.  
  5.  - trigger:
  6.       - platform: time_pattern
  7.         minutes: "/10"
  8.       - platform: homeassistant
  9.         event: start
  10.  
  11.     action:
  12.       - action: nordpool.get_prices_for_date
  13.         data:
  14.           config_entry: 01K6BFF0TVKT3M3RDYTQWVM38D #BYT TILL DIN EGEN NORDPOOLS ID
  15.           date: "{{ now().date() }}"
  16.           areas: SE3
  17.           currency: SEK
  18.         response_variable: today_price
  19.  
  20.       - action: nordpool.get_prices_for_date
  21.         data:
  22.           config_entry: 01K6BFF0TVKT3M3RDYTQWVM38D #BYT TILL DIN EGEN NORDPOOLS ID
  23.           date: "{{ now().date() + timedelta(days=1) }}"
  24.           areas: SE3
  25.           currency: SEK
  26.         response_variable: tomorrow_price
  27.  
  28.     sensor:
  29.       - name: Combined Nordpool Prices
  30.         unique_id: combined_nordpool_prices
  31.         state: "{{ now().isoformat() }}"
  32.         attributes:
  33.           data: >
  34.            {% set all = namespace(prices=[]) %}
  35.  
  36.             {% if today_price and today_price['SE3'] is defined %}
  37.               {% for item in today_price['SE3'] %}
  38.                 {% set all.prices = all.prices + [{
  39.                   'start_time': (item.start | as_datetime | as_local).isoformat(),
  40.                   'end_time': (item.end | as_datetime | as_local).isoformat(),
  41.                   'price_per_kwh': item.price / 1000
  42.                 }] %}
  43.               {% endfor %}
  44.             {% endif %}
  45.  
  46.             {% if tomorrow_price and tomorrow_price['SE3'] is defined %}
  47.               {% for item in tomorrow_price['SE3'] %}
  48.                 {% set all.prices = all.prices + [{
  49.                   'start_time': (item.start | as_datetime | as_local).isoformat(),
  50.                   'end_time': (item.end | as_datetime | as_local).isoformat(),
  51.                   'price_per_kwh': item.price / 1000
  52.                 }] %}
  53.               {% endfor %}
  54.             {% endif %}
  55.  
  56.             {{ all.prices | sort(attribute='start_time') }}
Advertisement
Add Comment
Please, Sign In to add comment