Found a relatively simple way to do this:
- Install SQLite Web add-on (GitHub - hassio-addons/addon-sqlite-web: SQLite Web - Home Assistant Community Add-ons) and open Web UI
- Select “states” table
- Select “Query” tab.
- Enter SQL query and click execute: it will report the first 1000 rows if successful
SELECT * FROM states WHERE entity_id = "sensor.your_sensor_id"
- Click on “Export CSV”: it will have all rows
