Remove bad temperature data from database

You can shutdown Home Assistant and then use a tool like DB Browser to run a SQL DELETE command for all values greater than a given threshold (like 5000).

I described the steps involved to someone else with a similar need to purge records from the database. It’s also applicable for your requirements: