Utility_meter cyles

I’m currently attempting a couple of different methods (including logging values to influxDB and graphing in there) but so far the most correct method seem to be to use the utility meter, with the quarter-hourly cycle.
As input I use the tarif 1 and tarif 2 consumption sensors coming from the DSMR integration.
My next steps will be to get the monthly max peak and all the peak from the last year/12 months, but with the new statistics charts that shouldn’t be too hard (that info is also kept indefinitely as opposed to the state changes)

EDIT: This is my graph from yesterday:
The yellow bars are values coming from the DSMR integration, every 1 second, grouped per 15minutes by the apex-charts card. The blue one is the tarif1 utility meter, the red one is the tarif2 utility meter (red one has no values just yet, only activated this morning)

As you can see, grouping and taking the average from the actual Power values from DSMR seems to align pretty much with the utility meter integration. I’m going to keep both of them active for a while and compare results in the coming days. if the result stay the same I’ll be removing the direct DSMR graphs and changing the interval back to 30seconds (default), the 1 second interval causes a lot of data to come into home assistant which really isn’t needed.

You might get slightly different results in HA versus Mijn Fluvius, because DSMR is not sending data in a time-synced fashion.

What I am doing, is sum both tarifs in NodeRed using an inject node, which is cron under the hood.


Function node:

const globalHomeAssistant = global.get('homeassistant');
var output;
var afname_1 = parseFloat(globalHomeAssistant.homeAssistant.states["sensor.energy_consumption_tarif_1"].state);
var afname_2 = parseFloat(globalHomeAssistant.homeAssistant.states["sensor.energy_consumption_tarif_2"].state);


output = (+afname_1) + (+afname_2);
output = output.toFixed(3);
return [{payload: output}];

Capacity tarif is only applicable to downstream energy.

I actually don’t really care about 100% accurate results, just a rough estimate is good enough for me.
The main reason I don’t need 100% accurate results is that my meter actually does not send any data to Fluvius, so I don’t get any info from MijnFluvius at all :wink:

Newsflash.

New HA 2021.9 Utility Meter will support cron-based resets. So you can easily let UM reset every 15min of the hour, multiply by 4 et voila.

As mentioned above the utility meter with quarter-hourly cycle is the correct option to measure the correct “kwartierpiek” or “capaciteitstarief”…
Don’t forget to multiply this by 4 to get the correct value which is needed.

I’m struggling to get these values for a month/year… I want the values with the MAX value of the current and past months. Anyone found a solution for that yet? I cannot find something useful in HA. min/max sensor doesn’t help…

I have a bar graph that shows this for the last 24h with max values. (and can see that 2.08 is the highest value last 24h.)
2021-09-22 13_16_43-Window

I use this utility_meter sensor

quarter_hourly_grid_consumption:
  source: sensor.grid_consumption_kwh
  cycle: quarter-hourly

Then I use this input_numbers to store the maximum peak and the monthly maximum peaks

  max_peak_2:
    name: Maximum piek 2
    min: 0.1
    max: 12.0
    step: 0.001
    mode: box
    unit_of_measurement: "kWh"
  
  january_peak_2:
    name: Piek januari 2
    min: 2.5
    max: 12.0
    step: 0.001
    mode: box
    unit_of_measurement: "kWh"
  
  february_peak_2:
    name: Piek februari 2
    min: 2.5
    max: 12.0
    step: 0.001
    mode: box
    unit_of_measurement: "kWh"
  
  march_peak_2:
    name: Piek maart 2
    min: 2.5
    max: 12.0
    step: 0.001
    mode: box
    unit_of_measurement: "kWh"

  april_peak_2:
    name: Piek april 2
    min: 2.5
    max: 12.0
    step: 0.001
    mode: box
    unit_of_measurement: "kWh"

  may_peak_2:
    name: Piek mei 2
    min: 2.5
    max: 12.0
    step: 0.001
    mode: box
    unit_of_measurement: "kWh"

  june_peak_2:
    name: Piek juni 2
    min: 2.5
    max: 12.0
    step: 0.001
    mode: box
    unit_of_measurement: "kWh"

  july_peak_2:
    name: Piek juli 2
    min: 2.5
    max: 12.0
    step: 0.001
    mode: box
    unit_of_measurement: "kWh"

  august_peak_2:
    name: Piek augustus 2
    min: 2.5
    max: 12.0
    step: 0.001
    mode: box
    unit_of_measurement: "kWh"

  september_peak_2:
    name: Piek september 2
    min: 2.5
    max: 12.0
    step: 0.001
    mode: box
    unit_of_measurement: "kWh"

  october_peak_2:
    name: Piek oktober 2
    min: 2.5
    max: 12.0
    step: 0.001
    mode: box
    unit_of_measurement: "kWh"

  november_peak_2:
    name: Piek november 2
    min: 2.5
    max: 12.0
    step: 0.001
    mode: box
    unit_of_measurement: "kWh"

  december_peak_2:
    name: Piek december 2
    min: 2.5
    max: 12.0
    step: 0.001
    mode: box
    unit_of_measurement: "kWh"

This template_sensors for the maximum peak and the year peak

    max_peak_2:
      friendly_name: Maximum piek 2 
      unit_of_measurement: "kWh"
      device_class: energy
      value_template: >
        {% set peak = ((states.sensor.quarter_hourly_grid_consumption.state | float(default=0)) * 4) %}
        {% set max_peak = (states.input_number.max_peak_2.state | float(default=0)) %}
        {% macro max(X, Y) -%} {{X|float if X|float > Y|float else Y|float }} {%- endmacro %}
        {{ max(max_peak, peak) }}

    year_peak:
      friendly_name: Gemiddelde jaarpiek
      unit_of_measurement: "W"
      device_class: power
      value_template: >
        {{ (( states('input_number.january_peak') | float(default=0) +
              states('input_number.february_peak') | float(default=0) +
              states('input_number.march_peak') | float(default=0) +
              states('input_number.april_peak') | float(default=0) +
              states('input_number.may_peak') | float(default=0) +
              states('input_number.june_peak') | float(default=0) +
              states('input_number.july_peak') | float(default=0) +
              states('input_number.august_peak') | float(default=0) +
              states('input_number.september_peak') | float(default=0) +
              states('input_number.october_peak') | float(default=0) +
              states('input_number.november_peak') | float(default=0) +
              states('input_number.december_peak') | float(default=0) ) / 12) | round(2)
        }}

And finale I have 2 automations

alias: Maximum piek 2
id: 546462125er
description: ''
mode: parallel
trigger:
  - platform: state
    entity_id: sensor.max_peak_2
condition:
  - condition: template
    value_template: >
      {{  states("sensor.max_peak_2") | float(default=0)> states("input_number.max_peak_2") | float(default=0)}}
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.max_peak_2
    data:
        value: >
          {{ states("sensor.max_peak_2") | float(default=0)}}
alias: Maximum maandpiek
id: fevefvdvfzsvf
description: ''
mode: single
trigger:
  - platform: template
    value_template: '{{ (as_timestamp(now()))|timestamp_custom(''%d'', true) | int == 1 }}'
condition: []
action:
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ (as_timestamp(now()))|timestamp_custom(''%m'', true)|int == 2 }}'
        sequence:
          - condition: template
            value_template: >
              {{  states("sensor.max_peak_2") | float(default=0)> states("input_number.january_peak_2") | float(default=0)}}
          - service: input_number.set_value
            target:
              entity_id: input_number.january_peak_2
            data:
              value: >
                {{ states("sensor.max_peak_2") }}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.february_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: '{{ (as_timestamp(now()))|timestamp_custom(''%m'', true)|int == 3 }}'
        sequence:
          - condition: template
            value_template: >
              {{  states("sensor.max_peak_2") | float(default=0)> states("input_number.february_peak_2") | float(default=0)}}
          - service: input_number.set_value
            target:
              entity_id: input_number.february_peak_2
            data:
              value: >
                {{ states("sensor.max_peak_2") }}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.march_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: '{{ (as_timestamp(now()))|timestamp_custom(''%m'', true)|int == 4 }}'
        sequence:
          - condition: template
            value_template: >
              {{  states("sensor.max_peak_2") | float(default=0)> states("input_number.march_peak_2") | float(default=0)}}
          - service: input_number.set_value
            target:
              entity_id: input_number.march_peak_2
            data:
              value: >
                {{ states("sensor.max_peak_2") }}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.april_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: '{{ (as_timestamp(now()))|timestamp_custom(''%m'', true)|int == 5 }}'
        sequence:
          - condition: template
            value_template: >
              {{  states("sensor.max_peak_2") | float(default=0)> states("input_number.april_peak_2") | float(default=0)}}
          - service: input_number.set_value
            target:
              entity_id: input_number.april_peak_2
            data:
              value: >
                {{ states("sensor.max_peak_2") }}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.may_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: '{{ (as_timestamp(now()))|timestamp_custom(''%m'', true)|int == 6 }}'
        sequence:
          - condition: template
            value_template: >
              {{  states("sensor.max_peak_2") | float(default=0)> states("input_number.may_peak_2") | float(default=0)}}
          - service: input_number.set_value
            target:
              entity_id: input_number.may_peak_2
            data:
              value: >
                {{ states("sensor.max_peak_2") }}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.june_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: '{{ (as_timestamp(now()))|timestamp_custom(''%m'', true)|int == 7 }}'
        sequence:
          - condition: template
            value_template: >
              {{  states("sensor.max_peak_2") | float(default=0)> states("input_number.june_peak_2") | float(default=0)}}
          - service: input_number.set_value
            target:
              entity_id: input_number.june_peak_2
            data:
              value: >
                {{ states("sensor.max_peak_2") }}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.july_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: '{{ (as_timestamp(now()))|timestamp_custom(''%m'', true)|int == 8 }}'
        sequence:
          - condition: template
            value_template: >
              {{  states("sensor.max_peak_2") | float(default=0)> states("input_number.july_peak_2") | float(default=0)}}
          - service: input_number.set_value
            target:
              entity_id: input_number.july_peak_2
            data:
              value: >
                {{ states("sensor.max_peak_2") }}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.august_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: '{{ (as_timestamp(now()))|timestamp_custom(''%m'', true)|int == 9 }}'
        sequence:
          - condition: template
            value_template: >
              {{  states("sensor.max_peak_2") | float(default=0)> states("input_number.august_peak_2") | float(default=0)}}
          - service: input_number.set_value
            target:
              entity_id: input_number.august_peak_2
            data:
              value: >
                {{ states("sensor.max_peak_2") }}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.september_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: '{{ (as_timestamp(now()))|timestamp_custom(''%m'', true)|int == 10 }}'
        sequence:
          - condition: template
            value_template: >
              {{  states("sensor.max_peak_2") | float(default=0)> states("input_number.september_peak_2") | float(default=0)}}
          - service: input_number.set_value
            target:
              entity_id: input_number.september_peak_2
            data:
              value: >
                {{ states("sensor.max_peak_2") }}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.october_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: '{{ (as_timestamp(now()))|timestamp_custom(''%m'', true)|int == 11 }}'
        sequence:
          - condition: template
            value_template: >
              {{  states("sensor.max_peak_2") | float(default=0)> states("input_number.october_peak_2") | float(default=0)}}
          - service: input_number.set_value
            target:
              entity_id: input_number.october_peak_2
            data:
              value: >
                {{ states("sensor.max_peak_2") }}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.november_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: '{{ (as_timestamp(now()))|timestamp_custom(''%m'', true)|int == 12 }}'
        sequence:
          - condition: template
            value_template: >
              {{  states("sensor.max_peak_2") | float(default=0)> states("input_number.november_peak_2") | float(default=0)}}
          - service: input_number.set_value
            target:
              entity_id: input_number.november_peak_2
            data:
              value: >
                {{ states("sensor.max_peak_2") }}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.december_peak_2
            data:
              value: 2.5
    default:
      - condition: template
        value_template: >
          {{  states("sensor.max_peak_2") | float(default=0)> states("input_number.december_peak_2") | float(default=0)}}
      - service: input_number.set_value
        target:
          entity_id: input_number.december_peak_2
        data:
          value: >
            {{ states("sensor.max_peak_2") }}
      - delay:
          seconds: 5
      - service: input_number.set_value
        target:
          entity_id: input_number.max_peak_2
        data:
          value: 0.1
      - delay:
          minutes: 1
      - service: input_number.set_value
        target:
          entity_id: input_number.january_peak_2
        data:
          value: 2.5
4 Likes

Hi Giel,

Thank you for sharing your code!
This is a very useful implementation to have this information available in Home Assistant.

I just would like to remark 2 things to be aware of:

The input_numbers and template_sensors technically should be of the device_class “power”, not “energy” and their values are in “kW”, not “kWh”.

You can find more information in this video of VREG (Dutch): Capaciteitstarief: van kwartiervermogen tot gemiddelde maandpiek - YouTube

If there is a monthpeak of less than 2.5kW, then indeed 2.5kW will be used to calculate the average monthpeak.
However, if the year is incomplete (not all monthpeaks known) and therefore there are missing values for calculating the “average monthpeak”, the average is calculated with the known values only.
The missing values are simply omitted and you should not use a default minimum monthpeak of 2.5kW in that case.
So the first year of introducing the capacity tarif, your calculation will be off somewhat.

2 Likes
  1. I’m going to change that.
  2. I think you can use a default value

All the specifics can be found in the technical regulations which you can find at https://www.vreg.be/sites/default/files/document/trde_2021.pdf

48°/1 Gemiddelde maandpiek afname: het rollend gemiddelde van de 12 laatste maandpieken
afname met inachtneming van de minimumwaarde van de maandpiek, zoals gedefinieerd in de
tariefmethodologie, vastgelegd door de VREG. Indien de maandpiek nog niet voor 12 maanden
beschikbaar is, is de gemiddelde maandpiek het gemiddelde sinds de eerste relevante maandpiek

48°/1 Gemiddelde maandpiek afname: het rollend gemiddelde van de 12 laatste maandpieken
afname met inachtneming van de minimumwaarde van de maandpiek, zoals gedefinieerd in de
tariefmethodologie, vastgelegd door de VREG. Indien de maandpiek nog niet voor 12 maanden
beschikbaar is, is de gemiddelde maandpiek het gemiddelde sinds de eerste relevante maandpiek

To avoid misunderstandings, let me summarise:
When you start taking measurements, for the first month the monthly peak and the average monthly peak are identical.

1st monthly peak: a kW ==> average monthly peak: a kW
2nd monthly peak: b kW ==> average monthly peak: (a+b)/2 kW
3rd monthly peak: c kW ==> average monthly peak: (a+b+c)/3 kW

12th monthly peak: l kW ==> average monthly peak: (a+b+c+d+e+f+g+h+i+j+k+l)/12 kW

13th monthly peak: m kW ==> average monthly peak: (b+c+d+e+f+g+h+i+j+k+l+m)/12 kW
14th monthly peak: n kW ==> average monthly peak: (c+d+e+f+g+h+i+j+k+l+m+n)/12 kW

==> “het rollend gemiddelde van de 12 laatste maanden” or “the rolling average of the last 12 months”

Correct?

Yes, your summary is correct. (Only the case <2.5kW is missing.)

More formaly: (With the correct terminology.)
The average monthpeak is the rolling average of the available monthpeaks, with a window size of 12. This window size is reduced to the amount of available monthpeaks if there are less than 12 monthpeaks available.

Pay attention to:
If an available monthpeak is less than 2.5kW, you must use a value of 2.5kW to represent that monthpeak in the calculations of the average monthpeak.
(Technically the monthpeak itself remains on its original value of less than 2.5kW.This might become relevant if the minimum value of 2.5kW in use today is changed (lowered) in the future. Today’s value was actualy determined by other net usage information and it can be reviewed and changed in the future if required.)

Also:
It doesn’t matter when “you” start taking measurements, but when the network operator starts. :slight_smile:

Today, monthpeaks are only relevant for consumption, not injection. However, if deemed necessary, this could change in the future so injection might then also be subject to a similar calculation (which might employ different numerical values).

It is unclear (not defined) what happens when you move to a different location within the geographical area where this capacitytarif is applicable, or when the legal owner of the electricitycontract is changed without moving. (Will the previous monthpeaks of the legal contractowner be used? Will the previous monthpeaks of the meter be used? Will you start again with no available monthpeaks?)

2 Likes

Hi @gieljnssns,

I’m trying to understand following in the automation ‘Maximum maandpiek’

If the first condition fails and failing means that the monthly peak is < 2.5 kW (2.5 kW is the minimum value of the input_number january in this example)

          - condition: template
            value_template: >
              {{  states("sensor.max_peak_2") | float(default=0)> states("input_number.january_peak_2") | float(default=0)}}

all the next steps are not done?
If so, the input_number.max_peak_2 is never reset and remains with his value.
February will then start with the value of the previous month in input_number.max_peak_2??

Am I missing some point?

Yes, you are right. :face_with_hand_over_mouth::face_with_hand_over_mouth:
I have to rethink this part…

I did some changes

        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.january_peak_2
            data:
              value: >
                {% if states("sensor.max_peak_2") | float(default=0)> states("input_number.january_peak_2") | float(default=0) %}
                  {{ states("sensor.max_peak_2") }}
                {% else %}
                  2.5
                {% endif %}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.february_peak_2
            data:
              value: 2.5
1 Like

I implemented your solution in HA next to mine (see above Utility_meter cyles - #12 by evb).
So I can compare the results :slight_smile:

The next step will be the implementation of the rolling average month peak “gemiddelde maandpiek afname” (Utility_meter cyles - #29 by JohanBraeken) :thinking:

I’m trying to set up something similar. The difference for me is that my monthly rate is calculated from the 5 highest hourly energy use figures each month. Any good ideas how I might achieve that? I’ve successfully set up @gieljnssns’s configuration so far, yet that obviously onnly gets me the single highest figure for the month.

What for hardware to measure do you have?

Could somebody help me in the right direction? I’m trying to use the utility_meter with cycle string: quarter-hourly but I’m not getting the right result. I’m fairly new at this so cut me some slack :wink:

cycle string (Optional)
How often to reset the counter. Valid values are quarter-hourly, hourly, daily, weekly, monthly, bimonthly, quarterly and yearly. Cycle value bimonthly will reset the counter once in two months.

This is my yaml-code

recorder:
sensor:
  - platform: statistics
    entity_id: sensor.energy

utility_meter:
  energy:
    source: sensor.p1_meter_active_power
    cycle: quarter-hourly
  daily_energy_offpeak:
    source: sensor.p1_meter_total_power_import_t2
    name: Daily Energy (Offpeak)
    cycle: daily
  daily_energy_peak:
    source: sensor.p1_meter_total_power_import_t1
    name: Daily Energy (Peak)
    cycle: daily
  monthly_energy_offpeak:
    source: sensor.p1_meter_total_power_import_t2
    name: Monthly Energy (Offpeak)
    cycle: monthly
  monthly_energy_peak:
    source: sensor.p1_meter_total_power_import_t1
    name: Monthly Energy (Peak)
    cycle: monthly

I’ve added the following to allow me to be able to measure the “kwartuurpiek”.

However, the sensor seems to add up consumed power instead of just measuring. Thereafter I changed the kind of measurement in ‘entity customization’ into ‘measurement’ instead of ‘total increasing’ because the entity doesn’t have a unique ID (because it was added in YAML.). But this doesn’t change its behaviour.

This entity (‘sensor.energy’) does not have a unique ID, therefore its settings cannot be managed from the UI. See the documentation for more detail.
You can overwrite some attributes in the [entity customisations] section.

Because I needed the ‘mean’ value I added statistics sensor. Normally this should already give the mean value

The statistics sensor platform consumes the state from other sensors. It exports the mean value as state and the following values as attributes: count, mean, median, quantiles, standard_deviation, variance, total, min_value, max_value, min_age, max_age, change, average_change and change_rate. If the source is a binary sensor then only state changes are counted.

Am I approaching this all wrong? What do I need to change in order for this to work? Also am I missing something? Do I need to multiply the value?

In Grafana it looks just fine, but I’m not able to pinpoint the issue occurring on the sensor from the utility meter :frowning:

This is a screenshot from the utility meter. The values seem to just always rise. I can’t seem to figure this one out on my own.

@Giovanni85, I’m trying to understand your post, but have difficulty to follow you.

I imagine that this sensor, in his raw value, is giving you the actual power consumption (W or kW) of your installation? This value is the real-time power consumption from the grid, correct?
Be careful if you have solar panels! You must only have the grid consumption!

This value must be converted to kWh (kilo-watt-hour), the number of kW per hour.
For this you can use the Riemann sum integration from HA.

- platform: integration
  source: sensor.p1_meter_active_power
  name: smappeemqtt_grid_afname_kwh
  unit_prefix: k
  round: 3

Now you can use the utility_meter integration

### creat quarterhour utility_meter from the riemann sum sensor.smappeemqtt_grid_afname_kwh
smappeemqtt_quarterhour_gridenergy:
  source: sensor.smappeemqtt_grid_afname_kwh
  cycle: quarter-hourly

Now you can follow 2 ways for the calculation of the average peak power per quarter.

  1. via a template sensor
- platform: template
  sensors:
    ### create from the utility_meter sensor the average peakpower per quarterhour  ###
    smappeemqtt_quarterhour_grid_averagepeakpower:
      value_template: "{{ states('sensor.smappeemqtt_quarterhour_gridenergy')|float * 4 }}"
      unit_of_measurement: "kW"
      icon_template: mdi:calculator
      friendly_name: "Gemiddeld piekvermogen per kwartier"

or

  1. Utility_meter cyles - #26 by gieljnssns : see above
    You take the sensor smappeemqtt_quarterhour_gridenergy as starting point to implement the Helpers and input_numbers.
    Be sure to implement the correction applied by @gieljnssns : Utility_meter cyles - #32 by evb

I’m using these 2 implementations in parallel, to be able to verify the values…