Modbus daily usage for offline inverter

Hi!

I’m using modbus and reads data from Sofar solar inverter. working great, but one thing I would like improved.

The sensor in ESPHome:

  - id: sofar_load_consumption_today
    platform: modbus_controller
    modbus_controller_id: sofarsolar
    name: ${sofar_name} - Load consumption today
    register_type: holding
    #skip_updates: 12
    address: 0x0688
    register_count: 2
    unit_of_measurement: "kWh"
    icon: "mdi:solar-power"
    value_type: S_DWORD
    device_class: energy
    state_class: total_increasing
    accuracy_decimals: 2
    filters:
      - multiply: 0.01

But as soon as the inverter goes offline then the daily sensor will go to zero. I would like to have it show last value until midnight so I can see the value before going to bed.

Seems PNG uploads are broken, so I can’t show you the graph. But I hope you get the point.

Any suggestions how to fix so it resets at midnight and not when inverter goes offline?