How to calculate daily power consumption from DSMR sensors?

I think you can do it by creating 3 automations + input_numbers that get the value of your real sensor at a specific time:

  1. to get the value at the beginning of the day (get the value of sensor when time is 00:00:01)
  2. to get the value at the end of the day (get the value of the sensor when time is 23:59:59)
  3. to calculate the value for a day (2-1)

If someone has other way or idea, please share it.

For example, this is how i get the correct date when my MiRobot starts cleaning:

  - alias: MiRobot last runtime
    hide_entity: True
    trigger:
      platform: template
      value_template: "{{ (states.vacuum.mirobot.attributes.status) == 'Cleaning' }}"
    action:
      - service: input_datetime.set_datetime
        data_template:
          entity_id: input_datetime.mirobot_last_runtime
          time: '{{ (as_timestamp(now()) | timestamp_custom("%H:%M:%S", true)) }}'
          date: '{{ (as_timestamp(now()) | timestamp_custom("%Y-%m-%d", true)) }}' 

I think you can use something similar, but using input_number instead of datetime.

something like this (didn’t test it):

input_number:
  consumption_morning:
    name: Consumption morning
    min: 9
    max: 999999999
	
  consumption_evening:
    name: Consumption evening
    min: 9
    max: 999999999

  daily_consumption:
    name: Consumption evening
    min: 9
    max: 999999999	

	
automation:
  - alias: Start of the day value
    trigger:
      platform: time
      at: '00:00:01'
    action:
      service: input_number.set_value
      data_template:
        entity_id: input_number.consumption_morning
        value: "{{ states.sensor.your_sensor_name.state }}"
		
  - alias: End of the day value
    trigger:
      platform: time
      at: '23:59:58'
    action:
      service: input_number.set_value
      data_template:
        entity_id: input_number.consumption_evening
        value: "{{ states.sensor.your_sensor_name.state }}"
		
  - alias: Calculate daily consumption
    trigger:
      platform: time
      at: '23:59:59'
    action:
      service: input_number.set_value
      data_template:
        entity_id: input_number.daily_consumption
        value: "{{ (states.input_number.consumption_evening.state) - (states.input_number.consumption_morning.state) }}"