Aggregate energy consumption based on sensor states

I use a shelly em to monitor the power consumption of a heatpump sensor.shellyem_pdc_channel_1_energy.

During the day the heatpump uses this energy to provide different services (only on service at a time) which I know thanks to another sensor that reads the status sensor.pdc_status

Would it be possible to create one or more sensors that count the energy used for every service
example:

During the day the shelly em measures 5 kWh
From 0 to 10 am > sensor.pdc_status
10 am to 12 > sensor.pdc_status (water) - add 1 kwh
12 to 24 > sensor.pdc_status (floor heating ) - add 4 kwh

At the end of the day the counter would look lik
sensor.energy_floor_heating = 4kwh
sensor. Water = 1 kwh

Daily counters can be used, but I don’t know how to generate the sensors that split energy usage in the first place.

Thanks!

Is the question unclear?

I tried to read your question, but it isn’t clear to me what you want. Can you maybe elaborate a bit more on the heatpump you are using and what services it offers?

What information do you receive (and how) that differentiates the water and floor heating?