Open CaptainXRay opened 1 year ago
Hi, I started looking into it and found a post about calculating average value of a forecast (https://community.home-assistant.io/t/calculating-average-from-a-forecast/518023) and started playing with it.
This calculates the average of the actual attributes, now its just to write each data to a template and then maybe add things like the deviation from the minimum etc
`{% set ns = namespace(sum = 0, count = 0) %}
{% for item in state_attr('sensor.awattar_at_price', 'data') -%} {% if as_datetime(item.start_time).date() == now().date() %} {% set ns.sum = ns.sum + item.price_ct_per_kwh %} {% set ns.count = ns.count + 1 %} {% endif %} {%- endfor %}
{{ ns.count }} {{ ns.sum }} {{ ns.sum/ns.count }}`
thats the template for the average cost, highest and lowest price
name: Energiepreis_Durchschnitt state: >- {% set ns = namespace(sum = 0, count = 0) %} {% for item in state_attr('sensor.awattar_at_price', 'data') -%} {% if as_datetime(item.start_time).date() == now().date() %} {% set ns.sum = ns.sum + item.price_ct_per_kwh %} {% set ns.count = ns.count + 1 %} {% endif %} {%- endfor %} {{ ns.sum/ns.count }}
name: Energiepreis_niedrig state: >- {% set ns = namespace(lowest = 999999, time = "") %} {% for item in state_attr('sensor.awattar_at_price', 'data') -%} {% if as_datetime(item.start_time).date() == now().date() %} {% if item.price_ct_per_kwh < ns.lowest %} {% set ns.lowest = item.price_ct_per_kwh %} {% set ns.time = item.start_time %} {% endif %} {% endif %} {%- endfor %} {{ ns.lowest}}
name: Energiepreis_hoch state: >- {% set ns = namespace(highest = 0, time = "") %} {% for item in state_attr('sensor.awattar_at_price', 'data') -%} {% if as_datetime(item.start_time).date() == now().date() %} {% if item.price_ct_per_kwh > ns.highest %} {% set ns.highest = item.price_ct_per_kwh %} {% set ns.time = item.start_time %} {% endif %} {% endif %} {%- endfor %} {{ ns.highest}}
Found a post on home assistant community: https://community.home-assistant.io/t/epex-spot-and-awattar-electricity-prices/519151/4
That Apex card can do it all
Hey, Thanks for the easy to use integration!
Is it somehow possible to use the daily provided forecast dataset, that is given in the state attrebute 'data' and feed it in InfluxDb or show it in Grafana?
Second question: aWATTar also has a monthley changing price for their "sunny" tariff. is it possible to get the data from the api too?
regards Norbert