Home assistant makes it super-easy to capture data from devices around your home by adding plugins, and it makes that data available in the history tab, so you can keep track of what’s going on, like this.

Home Assistant History tab showing Solar production

But what if we want to do more analysis, combine various metrics and do calculations, so that we can get a more in depth look at what’s going on? Luckily for us, Home Assistant already has InfluxDB export capability built in, so all we need to do is configure it.

There’s lots of information on how to configure the export in the Home Assistant docs, which is what I’ve used to create my very basic config that just takes a few fields that I want to be able to use.

Prerequisites

You’ll need to be able to edit the Home Assistant config, which might be by SSH, or via the File Editor plugin from the Home Assistant interface.

You’ll need the IP address/hostname and port of your InfluxDB instance. You’ll also need to check which version of InfluxDB you’re running. v1 allows API authentication by username and password, whereas v2, which I’m using here, only allows tokens. So if using v2, you’ll also need an API token from InfluxDB. You can find out how to create one here.

Configuration

To keep things tidy, I’m going to create a new file in the config folder called influxdb.yaml that will hold all of the config for InfluxDB. This will help to keep the config file clean, and means the integration config can easily be removed if required.

Below is a snippet of my influxdb.yaml. /config/influxdb.yaml

api_version: 2 # Ensure the version matches your InfluxDB instance.
ssl: false # Can omit this if using https.
host: 10.0.0.1
port: 8086
token: # Your api token
organization: home # The InfluxDB organisation that the bucket will belong to.
bucket: hass # The name of the bucket where the data will be saved
include:
    entities:
      - weather.home
      - sensor.solaredge_ac_energy_kwh
      - sensor.solaredge_ac_power

In the include section, I’m specifying which sensors’ data I want to be sent to InfluxDB. You can omit the include section, and Home Assistant will send the whole firehose of sensor data to InfluxDB.

Once influxdb.yaml is saved, we can add it to the main Home Assistant config like so.

/config/configuration.yaml

influxdb: !include influxdb.yaml

After saving, I strongly recommend validating the changes by using the Check configuration button on the developer tab. Once you’re happy that the changes are valid, hit the restart button on the same tab. Once it restarts, Home Assistant should start sending data to InfluxDB.

Once some data has been exported into InfluxDB, you should be able to see your entities’ data like this:

Viewing the data in InfluxDB Explorer

I hope this has been helpful. Thanks for reading. :-)