Measuring the Time Between History Graph Plotted points (High/Low)

So I have a robot vacuum that has a battery sensor.

The data I want to know is, on average, how long does it take for the battery to go from a depleted state to a fully charged state, and how long does it take for the fully charged battery to be depleted.

Then, those values to be graphed as their own sensor…

The resulting data would be “The average battery discharge time is X.” Based on this measure, I might be able to predict when the battery will no longer be able to charge fully…

Have a look at this. It might be able to provide what you’re looking for.

Another, maybe naive, approach would be to create some automations to handle the time between the charges.

For example:

# automation 1 #
When battery <5% and vacuum charging  
  1. set input_number.vacuum_charging to 0
  2. enable automation 2

# automation 2 #
When enabled, run every minute and increment the input_number.vacuum_charging by 1

# automation 3 #
When battery reaches 100% --> disable automation 2

This will give you a final input_number.vacuum_charging with the minutes it took for the battery to charge.