Home Assistant Add-on: InfluxDB v2

To access the DB you would go to homeassistant:8086. Question is, is there a way to access the DB remotely from outside your home network? For example I’m away and want to work on the DB or build queries, etc.

Thank you

Hi guys!

I’ve installed the Addon, onboarded and everything but there’s apparently no data figuring in my Influx HA bucket. Logs don’t indicate anything meaningul, rather retention specific results (see an excerpt below).

Any way to troubleshoot automated data ingestion? Or should I maybe forcefully import CSVs manually?

ts=2024-02-10T13:10:20.785377Z lvl=info msg="Retention policy deletion check (end)" log_id=0nGCKDlG000 service=retention op_name=retention_delete_check op_event=end op_elapsed=0.143ms
ts=2024-02-10T13:40:20.785953Z lvl=info msg="Retention policy deletion check (start)" log_id=0nGCKDlG000 service=retention op_name=retention_delete_check op_event=start
ts=2024-02-10T13:40:20.786192Z lvl=info msg="Retention policy deletion check (end)" log_id=0nGCKDlG000 service=retention op_name=retention_delete_check op_event=end op_elapsed=0.381ms
ts=2024-02-10T14:10:20.786624Z lvl=info msg="Retention policy deletion check (start)" log_id=0nGCKDlG000 service=retention op_name=retention_delete_check op_event=start
ts=2024-02-10T14:10:20.786796Z lvl=info msg="Retention policy deletion check (end)" log_id=0nGCKDlG000 service=retention op_name=retention_delete_check op_event=end op_elapsed=0.459ms
ts=2024-02-10T14:40:20.785348Z lvl=info msg="Retention policy deletion check (start)" log_id=0nGCKDlG000 service=retention op_name=retention_delete_check op_event=start
ts=2024-02-10T14:40:20.785470Z lvl=info msg="Retention policy deletion check (end)" log_id=0nGCKDlG000 service=retention op_name=retention_delete_check op_event=end op_elapsed=0.182ms
ts=2024-02-10T15:10:20.787362Z lvl=info msg="Retention policy deletion check (start)" log_id=0nGCKDlG000 service=retention op_name=retention_delete_check op_event=start
ts=2024-02-10T15:10:20.787681Z lvl=info msg="Retention policy deletion check (end)" log_id=0nGCKDlG000 service=retention op_name=retention_delete_check op_event=end op_elapsed=2.164ms
ts=2024-02-10T15:40:20.785577Z lvl=info msg="Retention policy deletion check (start)" log_id=0nGCKDlG000 service=retention op_name=retention_delete_check op_event=start
ts=2024-02-10T15:40:20.785725Z lvl=info msg="Retention policy deletion check (end)" log_id=0nGCKDlG000 service=retention op_name=retention_delete_check op_event=end op_elapsed=0.197ms
ts=2024-02-10T16:02:02.764943Z lvl=info msg=Unauthorized log_id=0nGCKDlG000 error="token required"
ts=2024-02-10T16:10:20.785133Z lvl=info msg="Retention policy deletion check (start)" log_id=0nGCKDlG000 service=retention op_name=retention_delete_check op_event=start
ts=2024-02-10T16:10:20.785242Z lvl=info msg="Retention policy deletion check (end)" log_id=0nGCKDlG000 service=retention op_name=retention_delete_check op_event=end op_elapsed=0.218ms

So with influx db2 I dont have to possibilty build my queries inside grafana with this:

image

Since this Plugin seems to be stale since a few month, i’ll leave a link to my implementation for this influx2 addon on github.

Since yesterday, i also managed to get ingress working. Thanks to @smoki3 for folling up these request :smiley:

That’s by design… influx2 nativly dropped the influxql language…
i’m using the “Data Explorer” from Influx to create my queries and if the work, simply transfer them to grafana…

Otherwise have a look for DBRP for Compatiblity…

I also mentioned these issue in my documentation for my plugin on GitHub - Dattel/homeassistant-influxdb2: Homeassistant Addon for InfluxDB2


If you need v1.x compatiblity for e.g. grafana, you have to create a retention policy for the database and a user for authentification. Replace the @bucket@ with your value.

Retention Policy

influx v1 dbrp create \ 
  --db homeassistant \ 
  --rp autogen \ 
  --bucket-id @bucket@ \ 
  --default

Create User for authentification ====

influx v1 auth create \ 
  --read-bucket @bucket@ \ 
  --write-bucket @bucket@ \ 
  --username homeassistant

I cant seem to get HA to talk to influxdb v2. I have this as an error message:

2024-02-26 04:27:17.466 ERROR (SyncWorker_15) [homeassistant.components.influxdb] InfluxDB bucket is not accessible due to '(503)
Reason: Service Temporarily Unavailable
HTTP response headers: HTTPHeaderDict({'Server': 'nginx', 'Date': 'Mon, 26 Feb 2024 04:27:17 GMT', 'Content-Type': 'text/html', 'Content-Length': '190', 'Connection': 'keep-alive'})
HTTP response body: <html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body>
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>nginx</center>
</body>
</html>

'. Please check that the bucket, org and token are correct and that the token has the correct permissions set. Retrying in 60 seconds.

This is my HA config:

influxdb:
  host: <host?
  port: 8086
  api_version: 2
  ssl: false
  organization: myorg
  token: <token>
  bucket: homeassistant
  include:
    entities:
        - sensor.family_room_multi_sensor_air_temperature
        - sensor.family_room_temperature
        - sensor.garage_temperature
        - sensor.living_room_multi_sensor_air_temperature_2
        - sensor.master_multi_sensor_air_temperature

Token, org and bucket are all correct. Any thoughts? Does the influxdb integration still work with influx v2?

Hi, yes, I’ve not had the time to prioritize this, as I’ve myself switched to VictoriaMetrics. Please consider using any of the two forks if they are better maintained.

1 Like

I have also an error in the export:


But I use the correct code.
Can you help

I’m so stupid: First step ist: create the folder!

I never used any include and exclude option and in the past year my database size has grown significantly, 30GB to 55GB. I don’t use any purge also.

Today, I have added the include and exclude options. Hopefully size increase will be in check now.

my question is:
can I delete all the entities that are filtered out now from the influxdb?
or maybe just delete entries that haven’t been updated for six months?

Hi @danieloldberg , thanks for your work on influxdbv2. I was about to stream my data to a local instance but I have been unable get it to write to influxdb cloud using the same configuration.

I only modified the host to my cloud URL.

Wonder about two things:

  1. What token when importing? The one of the influxdb2 initialization? I can’t find a token in my 1.8 setup.

Error: failed to write data: 401 Unauthorized: unauthorized access

I’d go with bucket, organization and token of the influxdb2 setup. But it doesn’t work.

  1. The export file is only 3 MB. When I run a backup for my db it is round about 600mb.

All in all. I am not able to import the data without the correct token.

//EDIT: ok, i just created a new token. import works but the old values aren’t existent just the metadata is imported this way.

Hello,

I have sensor data written to InfluxDB
“2024-07-19T00:00:00Z”,
0.633

Is it possible to update this data to 0.733 and keep the same timedata?

Just send same new value with same timestamp to influxdb. It’s like an update statement.

https://docs.influxdata.com/influxdb/v2/write-data/best-practices/duplicate-points/

Someone know how to do this in HomeAssistant?

Why would you go thru Home Assisstant? You are asking for data manipulation. HA is a client to write data into influxdb only. When you want to manipulate data its best to use the tools which influxdb provides. Cli, http-api or influxdb tools. Best you check their official documents or their forums.

I want to manipulate my data what is written in InfluxDB with Home Assistant

That’s irrelevant. You want to manipulate data. Best tools are the once which are provided by the vendor. When you want to rename a word document you will use the windows explorer to rename the file, I doubt you would wait until Microsoft build a file explorer into the Word applicaiton, yes Word was the tool which created the file initially. But the Winodws Explorer was build to handle files. So it’s better to use the tool which was build to handle specific tasks.

Homeassistant did what you told to do, log the current values or defined sensors. Nothing more, nothing less.

InfluxDB is in HomeAssistant, my sensor is in HomeAssistant, so i want to change that value in InfluxDB

I dont want to manually change data

You don’t need to convice me. I gave you 2 (3) options in influxdb how you could make the adjustment. It’s your decission whether you want to read thru the documents, when you wait long enough there could be somebody who provide you a script or tool. It could take a while, probably never.

Maybe it’s possible with a script, as long as it is in HomeAssistant :slightly_smiling_face: