Can you Extract Data from the History Component

There was another thread about something like this and I think the guy ended up dropping it. History statistics component can get information, but i’m not sure it can be used the way you want to use it.

Maybe you could build an automation that stores the timestamp and state change in a mqtt topic. Each time you fire the automation grab the previous value and calculate?

Might be easier to just create a appdaemon app.

EDIT: HIstory statistics component: