InfluxDB configure as influxdb: or history: I don't understand the difference

I’ve become relatively experienced with Home Assistant. And my hardware integrated with it is increasing and will increase more.

My current setup is Hass as docker container on a Synology NAS and MariaDB as recorder. I record everything with retention of 14 days. I have Deconz Zigbee sensors and a utility meter that sends info to Mosquitto every 10s or something, among others.

I’m not surprised my extensive custom yaml lovelace dashboard sometimes struggles a bit.

So I’m looking for performance improvements.

  • Reducing the recorder retention
  • Keeping history in InfluxDB and create Grafana dashboards
  • Filter entities to record and log to InfluxDB

I hope this will improve performance indeed.

However I’m totally confused how to configure the influxDB.

  • Do I do this with influxdb: in configuration.yaml, or
  • Do I do this with history: in configuration.yaml

I’ve seen both being used in guides, but I couldn’t find a clear explanation what the difference is and which one I should use.

Thanks!

The recorder component needs an SQL database to store history. Which influxDB is not. If you want more performance with this try MariaDB.

See this guide on how to reduce your DB size: How to reduce your database size and extend the life of your SD card

You can store data in influxDB but the home assistant more info pop-ups are not able to use this (you still need the recorder DB). You have to supply your own Grafana graphs. I do this for very ‘chatty’ sensors and sensors I want to keep long term data for (2 years).

Yes this is correct.

This is not correct and I’d be interested to see where you got the idea it was. The history integration is for displaying data from the recorder DB. Like the logbook integration, which also uses the recorder database but displays in a different format.

If you still want to set up influxDB, watch Frenk’s tutorial on setting up influxDB and Grafana:

2 Likes

Thanks a lot! This is clearing most of the confusion up now. I read, or at least interpreted, from this article there was an option to add influx to history: https://github.com/Burningstone91/smart-home-setup#history--databases-

And here https://www.home-assistant.io/integrations/influxdb/ halfway the page in the sensor section. You’ll have to agree, it’s not all that crystal clear :slight_smile:

Hey that’s my guide :slight_smile: Can you tell me what exactly was confusing you? Maybe that I said to put the configuration in history.yaml? Because that’s intentionally done like this, I keep everything that belongs together in a package -> history.yaml

Yes, it’s the History section where you explain to create a history.yaml file with an “empty” history: entry. Later on you explain about the influxdb: entry in history.yaml. Which made me think, that probably needs to be part of the history: entry and not a separate one. Why else would I need to create the history: entry?

So now I still don’t understand what that “empty” history: entry offers additionally to both recorder: & influxdb:

The history: entry is used to enable the history integration. If you have default_config: in your configuration.yaml, it is already enabled.
Once the history integration is enabled, you’ll see a new tab in the sidebar called History and you’ll also have the graphs when you click on an entity to show more info. The history depends on the recorder, when you exclude something from the recorder, you won’t get any history.
You can read more about the history integration here.

1 Like

Hi Tom,
I’m replying to this as you helped me in the past on Mariadb and have some good insight on it.
I just converted my RPI4 to 64bit and SSD. After the restore, I had the following integrations and platforms could not be set up: recorder, history, logbook, default_config. It looks like the db got corrupted during the snapshot restore. I then uninstalled Mariadb rebooted, then reinstalled. Everything cleared up except recorder. Recorder had the identical setup as before.

recorder:
  purge_keep_days: 5
  db_url: mysql://homeassistant:password@core-mariadb/homeassistant?charset=utf8

I changed recorder to:

recorder:
  purge_keep_days: 5
  db_url: mysql://homeassistant:~Michael17@core-mariadb/homeassistant?charset=utf8mb4

And this worked. This morning, I changed it back to utf8 and it still works. Not sure what is going on and would like to learn more.
In searching the forums I found a lot of people having issues with the Db on snapshot restore. It seems crazy that you lose your history on a restore?

Bill

Yeah. That’s the way it seems to be though.

any idea on where the db is stored and If I can recover it from a backup?