How to remove entities and their statistics

Hi, I have following custom integrations in configuration.yaml:

  - platform: integration
    source: sensor.heater_current_usage_central_heating
    method: left
    name: Gas consumption CH
    round: 3

  - platform: integration
    source: sensor.heater_current_usage_domestic_hot_water
    method: left
    name: Gas consumption DHW
    round: 3

  - platform: integration
    source: sensor.heater_current_usage
    method: left
    name: Gas consumption DHW+CH
    round: 3

Their current states are messed up, and I want to either reset them to 0 to start over, or remove them completely from HA along with their long term statistics, and then add them back. None of the methods I’ve found seem to be working. What I’ve tried so far:

  1. Developer tools → States and set state to 0. After a while all values are going back to previous values.
  2. Developer tools → Statistics and correct the values for each of them - that’s not an option since there are quite a lot of incorrect values and it’s impossible to correct them individually
  3. Remove entities from configuration.yaml, restart HA, remove entities along with the statistics from Settings → Entities and Developer tools → States and Statistics, then adding them back in configuration.yaml and restart HA - magically all states are restored…
  4. I even tried to manually delete the data from SQLite database for these entities - altough long term statistics are indeed removed, the last remembered value is restored from somewhere else and it’s impossible to set it to 0

The “source” entities all have state = 0. The problem is only with the above.

These entities are immortal. Is there any other way to remove them completely or reset their values to 0?

Really nobody knows the answer?

what i’ve done in the past is to delete them using the api

command is

curl -X DELETE -H “Authorization: Bearer ” https:///api/states/

example:

curl -X DELETE -H “Authorization: Bearer eyJhbGciOiJlhdCI6MTY4MDc3NDc5MywiZXhwIjoxOTk2MTM0NzkzfQ.jAyXGwjKKezveeJRLqpLtBfRIOTfZ_eu_QvmVpRyjE0” http://192.168.1.100/api/states/binary_sensor.presence_sensor_fp2_00bc_presence_living

1 Like