InfluxDB - Abililty to Write to More than One Database

InfluxDB is a fantastic integration in HA. Thank you for providing it.
[ InfluxDB - Home Assistant ]

The existing integration writes/stores values from Home Assistant to an external InfluxDB database. It’s helpful for use cases including longer retention and building Grafana Dashboards around sensor data.

Feature Request - Ability to write to more than one InfluxDB Database

Use case:
I store all HA sensor data in an external Influx (v1.8) database. This request is to enable writing to multiple databases on the same InfluxDB server. A closely related feature it could enable is the ability to write to Influx databases on multiple hosts.

This would enable the following additional use cases:

  • Storing specific sensors into other existing databases (example, long term weather record keeping)
  • Enabling users to have a cloud based InfluxDB in additional to a local database. This can be for backup/redundancy uses or for publishing sensor data in a publicly accessible database outside of the home network

The feature would be implemented so multiple databases could be configured under the influxdb: root in configuration.yaml. All of the parameters currently supported (host:, database:, etc) should be supported under the addition of a YAML sequence named instance.

Example current configuration:

influxdb:
  host: <HOST_IP>
  database: home_assistant

Example proposed configuation with new feature:

influxdb:
  - instance: 1
    host: <HOST_IP>
    database: home_assistant
  - instance: 2
    host: <HOST_IP>
    database: weather_db
    include:
      entities:
      - sensor.temperature_tempest

Backward Compatibilty
This would not be a breaking change to existing InfluxDB integration users.

  • The YAML supports both single mappings and sequences of mappings
  • The existing format maps directly to an “instance” in the new format

When implementing, the code would:

  • Check if configuration is a sequence (new format)
  • If not, treat single mapping as default instance (old format)
  • Process each instance accordingly

Impact
7.2% of the active Home Assistant installations use the InfluxDB integration. That is a lot of users!

A quick search revealed other users requesting a feature like this:

Hi,

I am using a workaround since my request (Not possible to integrate multiple InfluxDB databases/buckets · Issue #106849 · home-assistant/core · GitHub) was marked as “not planned”.

I have disabled InfluxDB as target for HA and limited the regular (in my case SQLite) database to a few weeks and for several sensors.

My InfluxDB has several databases with differing retention policies etc.
I use good old Node-Red to send data to InfluxDB. Bit of a hassle to setup initially (pull each sensor in NR, do some transformation to build the right message etc.) but has been running for several months now without issues.

I’d love to see the support for multiple influxdb instances.
Particularly now as I am trialling InfluxDB3.
I don’t want to switch over fully to V3 as I do not fully trust it after my experience with it over the last few months.
So ATM, I have the choice of either V2 or V3.