Skip to content

Zonneplan

Jonas Karlsson edited this page Jul 4, 2024 · 2 revisions

To use the Zonneplan integration, the following template sensor can be used to create the price input.

template:
  - sensor:
      - name: "Zonneplan template price sensor"
        unique_id: zonneplan_template_price_sensor
        unit_of_measurement: "€/kWh"
        availability: "{{ 'sensor.zonneplan_current_electricity_tariff' | has_value }}"
        state: "{{ states('sensor.zonneplan_current_electricity_tariff') }}"
        attributes:
          prices_today: >
            {%- set forecast = state_attr('sensor.zonneplan_current_electricity_tariff', 'forecast') %}
            {%- set time_key = 'datetime' %}
            {%- set price_key = 'electricity_price' %}
            {%- set ns = namespace(data=[]) %}
            {%- for i in forecast | default([], true) if as_local(as_datetime(i[time_key])).date() == now().date() %}
              {%- set ns.data = ns.data + [dict(time= as_local(as_datetime(i[time_key])).isoformat(), price = i[price_key] / 10000000 )] %}
            {%- endfor %}
            {{ ns.data }}
          prices_tomorrow: >
            {%- set forecast = state_attr('sensor.zonneplan_current_electricity_tariff', 'forecast') %}
            {%- set time_key = 'datetime' %}
            {%- set price_key = 'electricity_price' %}
            {%- set ns = namespace(data=[]) %}
            {%- for i in forecast | default([], true) if as_local(as_datetime(i[time_key])).date() == (now()+timedelta(days=1)).date() %}
              {%- set ns.data = ns.data + [dict(time= as_local(as_datetime(i[time_key])).isoformat(), price = i[price_key] / 10000000 )] %}
            {%- endfor %}
            {{ ns.data }}