Problem with file size sensor

Does anyone else have a problem with their file size sensor working for a while and then just not updating anymore? Mine works for a day or two, and then just stops updating the file size. It looks like it should be working, according to the “last updated”, and there are no errors in the log. But the file size currently is 147328.0 kb.

hadb

If I delete the database and restart HA, it starts working again, and then the same thing happens. This has been happening for several versions of HA - I’m currently on hass.io 0.70.1, but it was happening on the 0.69 versions as well, and possibly before.

my config has

  - platform: filesize
    file_paths:
      - /config/home-assistant_v2.db

with

homeassistant:
    whitelist_external_dirs:
      - '/config/'

Any information or help gratefully received.

Mine looks the same, but I think what is happening is that the history db reaches the purge interval and the file size no longer increases. The size is correct.

3 Likes

Thanks so much for your reply. I was looking at this

HAdbsize

and not thinking about the difference between file size conversions in decimal vs. binary. Looking at this

and realizing that the conversions are done as binary I can see that the file size is correct in all cases.

It makes sense about the purge interval. Thanks so much for helping me out! :slight_smile:

Hi, there is no way to view the actual and real size of the DB file?

My actual DB size is 267.004kb, but the sensor show 273.041 (size before purge?)

Thanks

The file sensor is showing the size in KB (Kilobytes). The other way you are measuring its “actual size” is in KiB (Kibibytes).

Both are correct. Just different units.

KB = 1,000 bits
KiB = 1024 bits.

267.004 * 1.024 = 274.41 (I assume you made a typo here, by putting 274.041)

ok, but the size of my db hasn’t changed for 10 days

Do you still have history data available (graphs and such)?

yes, but the file update time changes, the size never changes.
This is my config:


recorder:
  commit_interval: 300
  auto_purge: true
  purge_keep_days: 5

image

What are you using to view that?

File Editor in iOS HomeAssistant app

I don’t understand this. My database file does the same…grows and then hits some level and stops growing. But isn’t there constantly new entries put into the database, and then its purged of old data every once in a while. So shouldn’t we see constant growth and then every once in a while spike down in size?

That’s a two year old post. And wrong. I no longer use the default SQLite database or a pi.

You should see changes:

Yeah, I couldn’t find any other posts that describe this behavior. I’ve been recently exploring why my DB is so enormous and am doing a deep dive. I haven’t gotten around to switching to a different DB type although I’ve heard that is a good idea.

Its just odd that sometimes it plateaus for a while, it does seem to line up with the actual file size when I look at it in a file explorer. But I suppose it could be the file size sensor but I kind of doubt it.