Can I access historical entity data from a custom card?

Hi, I am currently trying to make a custom card using lit-element as well as chart.js to provide visualizations. I know that Home Assistant stores historical data from the entities, as this is shown in the default entities card, but I am wondering if there is any way to access this historical data from the js for the custom card. Currently, I am using hass.states to get the current state, but is there a similar way to access historical data points? Thanks for your help.

Personally I would not know, but there is an example card that is able to display long term statistics. From that you should be able to see how it was done:

I didn’t realize someone picked it up after the original dev dropped the project, good to know! I’ll have to finally remove the old one from HACS and install the new one.

Yes if you’re writing JS you can get all the recorder history, same as the default frontend.

If you have the hass object, you can call websocket API methods to get entity history. See frontend/src/data/history.ts at ec9a95dde0c13625d9b85ef8630948385cc09691 · home-assistant/frontend · GitHub, particularly subscribeHistory I think may be how the frontend ususally does history graphing.