i have a pv system and read out the values via modbus using homeassistant. This also includes the total yield of the solar energy. after a restart of the inverter, this value is set to 0 in the inverter, so that the value for the total yield is no longer correct. is there a way in home assistant to temporarily store the value for the total yield so that it is available again after a restart of the inverter and resetting the value in the inverter to 0?
I assume that ‘total yield’ is the total energy generated ever, since the device was first turned on.
Firstly I wonder why your inverter is not retaining the totals-figures itself over a restart. Non volatile memory should hold such values for the lifetime of the device. My Solis inverter certainly does.
Some models of inverter will include the facility to re-calibrate these long-term values. There may be a feature for writing back to a register the old value. The stored value may also be in a holding register which you can just overwrite yourself.
Utility meters in Home Assistant will have a state value based on the difference between the current subject entity value, and the internally-recorded last value at reset. The only value that is retained by Home Assistant is the value (reading) at last reset, and utility meters will clear down the retained value if the reading goes backwards, on the assumption that the utility meter has been replaced with a new one.
The only values that Home Assistant itself holds over a restart are input entities, hence the use of an input.number to store the current inverter total yield. It would, of course, be necessary to capture the current value regularly, unless the inverter goes back to 0, in which case you don’t want to capture the value, which is rather negating the point of the exercise.
I would assume that you have other values, including ‘total today’. A basic Home Assistant automation, triggered every day at 22:30 (after sunset but before midnight), could be used to simply add the day-production figure to the stored value in an input-number, by which you could sum the total produced yourself. The advantage of using an input-number here is that such entities can be easily modified, hence you could manually set the initial state value to the last known ‘total energy’ yourself.