For anyone coming here in 2024 and getting confused because all entity_id
s are NULL, the database structure is different now and entity IDs are stored elsewhere. This thread has the details:
In my case, I’m using a standard SQLite backend and I have a “sensor.hot_tub_solar_mat_temp” sensor pulling values from a counterfeit DS18B20 that occasionally returns 0C i.e. 32F.
This query finds all rows with state equal to 32F that I want to delete.
SELECT *
FROM
states
WHERE
metadata_id = (
SELECT
metadata_id
FROM
states_meta
WHERE
entity_id = 'sensor.hot_tub_solar_mat_temp'
)
AND
states.state==32
Replace SELECT *
with DELETE
to purge them.