I am pretty late in switching from my own handcrafted Flask/file-based solution to HomeAssistant. For this to replace my old solution some problems need to be solved and I will try to write about them in future blog posts. This post is about saving everything into InfluxDB 2.7 which was not as well documented as I hoped.
There are different ways to run HomeAssistant and I chose the systemd/virtualenv one.
My host system is shuttle PC with ArchLinux installed and systemd based services is what I run most.
So InfluxDB is a systemd process too installed via pacman (
After that the documentation is vague, contains links to old (InfluxDB) documentation and is not helpful anymore.
The ArchLinux package is InfluxDB is version 2.7.1 so the config cannot be based on version 1.7.x.
So the first thing after starting the influxdb service was running setup (on purpose interactive, so see options) to get a user, an org, a bucket and finally a token:
$ influx setup > Welcome to InfluxDB 2.0! ? Please type your primary username hass ? Please type your password ************** ? Please type your password again ************** ? Please type your primary organization name hass ? Please type your primary bucket name home_assistant ? Please type your retention period in hours, or 0 for infinite 0 ? Setup with these parameters? Username: hass Organization: hass Bucket: home_assistant Retention Period: infinite Yes User Organization Bucket hass hass home_assistant
We need to use the organization id and the bucket id later, so lets get them:
And we need a token to read/write to the bucket:
Add the token to
secrets.yaml and create a
influxdb.yaml in your configuration folder.
Mine looks like this:
And the file is included in the
configuration.yaml like this
This returns datasets added to the home_assistant bucket in the last 5 minutes.