State history graph flat-lining

Every day or 2, my home assistant loses the ability to display/store the state history of my devices.
It happens at a certain time and lasts around 12 hours before it comes back on and tracks as normal.
It effects all my devices histories (lights, sensors, etc), so doesn’t appear to be an issue with the individual sensor.

Whatever the state was in at the time it stops storing the info is what it shows in the history as a flat line, even though it continues to track the current state correctly.
i.e. see the picture below, actual temp is 30.6, but the graph shows it stuck at about 25.5 as that’s what it was at around 11pm when it stopped recording the history.

Any idea as to why that might be, and how I might go about fixing it?

I have the same issue, since sometime in January. It used to be sometimes, now always, anywhere between 2 and 8 hours of the most recent time is flat lined. Its not the sensors as it applies to two Aeon Multisensors and my Aeotec Home Power Monitor and also some status sensors.

The issue must be the database. Ideas?

Well, I’m glad I’m not the only one…
Yes, I assume it’s something about the database, but I’ve tried deleting the db and restarting and have still had the issue. I’ve seen other posts where the state history doesn’t load, but this appears different…

I actually had to do a fresh install of hass.io on a new sd card a few weeks ago after my previous install (that was also having this issue) stopped working altogether.
I thought maybe that had fixed the issue, but it just came back yesterday, and has done it twice so far…

I was thinking it was an SD card issue but you’ve tried that - interesting how it worked for a while then the problem reappeared. I’ve noticed that the problem seems to get worse over time. My flat line duration has got longer, up to about 18 hours max, but never has the whole graph gone flat. Hard or soft resets don’t change the flat line. Must be the database or accessing the database.

Although it does start to work, after the flat line, after a reset. But the original flat line remains.

Just came here to check or post the same thing.

I was on 0.7x before and it started happening.
I would regularly STOP hassio. Then delete the database file. (I though that it may be a size issue database reaches 1gig after about 3 days stock)

It would work for a bit.

I tried updating… that failed.
The sd card was dead.

With new sd card. I did a clean reinstall and fixed all my broken changes.

Instructed to purge the database every day in conf.yaml for a total of 1 days worth. (Something like that)
Also instructed to limit a lot of my heavily changing sensor data. (Light metering, temp, humidity)

Still now after 3 days or so it slowly starts to creep back and flatline.

I’m running on rpi3b with a pretty basic reinstall.
Looking forward to a solution. I’m hoping it’s not another burnt card.

happens to me as well, not running on an rpi but on a Synology NAS using docker, any solution thus far ?

I have the same issues after upgrading from 0.84 to 0.93.2.

Sensors work but history graphs become flat after some hours. I deleted my DB, but same result.

Any idea??

Thanks!!

I’ve read several different issues of this type and I had a similar problem. I believe sqlite may have issues keeping up with multiple inserts. I switched my db to PostgreSQL and my problems went away.

I tried to set logger level to DEBUG, but nothing. After few hours, history of sensors becomes flat, with no error. Simply it happens. It is frustrating :frowning:

Anyone figured it out ? it still happens… :frowning:

Sane to me. Runs fine for 7 or 8 hours. Then flat Line

Fixed it finally!

Just add

?charset=utf8

at the end of the mysql connection string. From what I observed when you have emojis in notifications it crashes for some reason. 3 days without a crash! (usually was 4-8 hours)

As I re stumbled on this page I thought i’d add my solution that has been going strong for 4-5 months.

Also as I don’t use emojis anywhere I thought I’d chime in.

Originally I had this issue. At the time I suspected too many read and writes, which would slowly burn out the card. While that may be related, despite my FAST SD card I came to think it was too much info to write at one given time.
In my setup there are well over 50 sensors all demanding a write at the same time, all the data must be pulled up when visualizing the graph. (despite hearing this happens on SSD, or in a VM, I decided to limit the data kept by purging after 1-2 days and using the exclusive setting to only include the data I wanted to see/keep. also omitting the data that changes a few times a second with my Bruh sensors (lux seems to go a little nuts on some sensors).

Which these changes I’d had NO issues.

I didnt want to start a new thread on this so I´m posting it here.

The flat-lining graph issue is a real pain in the butt. I ´m experiencing it ever since I started with HA on my Raspi4 with hassio. Everything works great except these graphs. All the threads (and the opened issues on github) end with “I deleted the DB and everything worked again”. Yeah. That works. But that is NOT a solution.

What I´ve tried:

  • Deleting DB : works for a while, error comes back within days
  • switching to mariadb: works a bit longer, in the end same result
  • switching to external mariadb (local, but different server): same as above
  • switching to InfluxDB: that works, no sensor data is lost - but you cant store all the DB stuff there so it also is no solution
  • regular recorder purges (after 1 day): keeps it running quite long, in the end it will flatline as it always does
  • reducing the amount of data by excluding stuff from the recorder: even better, but it WILL flatline eventually. Combined with daily purge it runs for days and weeks sometimes but not forever
  • reducing the database to the last 24h plus running OPTIMIZE on it via cron on the DB server AND restarting HASS everyday is the best “solution” so far - but it´s more like a workaround.

There seems to be a bug that is not resolved. Nobody even knows WHY the graphs flatline. It´d be great if I could keep state/event data from at least 2-3 days. I´m willing to try stuff to narrow it down but deleting the DB all the time sucks a bit.

Update: Interestingly, the “custom mini-graph card” is being updated while the standard lovelace-graphs AND the logbook arent. So there seems to be an issue with HA reading from a certain point on in the database…

have been experiencing the same since a few days (HA 107.x)
Hope to find a fix soon and will try and report back.
weird that this issue appears across so many versions…

Same Bad experience also for me. the problem starts passing from 106 to 107 version

Interestingly, the “custom mini-graph card” is being updated while the standard lovelace-graphs AND the logbook arent.

That’s interesting. I started from scratch with a new version of Hass.io, and I thought that had fixed it, but I also transferred all my temp sensors to mini-graph-card as well, so maybe that was the actual fix!

Yeah, I had other unrelated bad experiences with 0.107 (groups depreciated), so I downgraded to 0.105.5.