Hello there,
I’m using a temp/humidity sensor in Bluetooth.
Sometimes, the value is not realistic, like yesterday, my office went from 21.2°C to 1568.7°C and back to 21.0°C.
It is easy to detect with an automation that the difference between last value and current value is weird with a template for exemple.
But then, I’d like to remove that non-sense value from the states table in a way.
Is it possible?
Because if I dont, my graph look like this
which is not really nice …
EDIT: I assume I can use an sql command, but as it is my first time, I’d like some help.
How I find the culprit:
SELECT *
FROM states
WHERE entity_id = 'sensor.xiaomi_temperature'
AND state > 50
And then, I delete it base on state_id
, which I could do in one SQL statement but “better be safe than sorry”.
EDIT 2
Then, I sometime do an update of the state_id which have the deleted one as old_state_id as the deleted one with the old_state_id of the deleted one (does it make sense?) even if it doesn’t seem to be a problem not to do it.