Sikkert ikke det du er ute etter men jeg bruker denne koden i HA. (koden er kopiert fra noen andre her inne)
template:
- binary_sensor:
- name: Lav Spotpris
state: |
{% set today_price = state_attr('sensor.nordpool_kwh_krsand_nok_3_10_025','today') %}
{% set current = state_attr('sensor.nordpool_kwh_krsand_nok_3_10_025', 'current_price') %}
{% set number_of_hours = states('input_number.number_of_hours') | int %}
{% set max_price = states('input_number.max_price') | float %}
{% if number_of_hours == 0 %}
{% set price_limit = 0 %}
{% else %}
{% set price_limit = (today_price | sort)[number_of_hours-1] %}
{% endif %}
{% set limit = ([ price_limit, max_price ]) | min %}
{{current <= limit}}
input_number:
max_price:
name: Maks Pris
min: 0
max: 10
step: 0.1
icon: mdi:cash-lock
unit_of_measurement: kr/kWt
number_of_hours:
name: Antall Timer
min: 0
max: 24
step: 1
icon: mdi:clock