How to Correctly Setup Influxdb2 for Openhab

The setup page for InfluxDB Persistence does not seem clear. I have read multiple guides, including InfluxDB’s own setup guide for v2. No matter what settings I use or how I try to set up InfluxDBv2, I receive an “unauthorized access” in InfluxDB when attempting to save the persistence settings.

I have an existing organization in InfluxDBv2. What do I need to set up there so that OpenHab can actually use it?

You’ve not provided much details so about the only thing I can do is show the table saying how to set it up with the V1 stuff removed. Hopefully that will make it more clear.

This service can be configured in the UI under SettingsOther ServicesInfluxDB Persistence Service or in the file services/influxdb.cfg. Attention: The file-based configuration overrides the UI configuration.

Property Default Required Description [What you should enter]
version V1 No InfluxDB database version V1 for 1.X and V2 for 2.x [Choose V2]
url http://127.0.0.1:8086(opens new window) No database URL [the network path to your InfluxDB instance and the port. 127.0.0.1 means localhost]
user openhab No name of the database user, e.g. openhab [user you created in InfluxDB that has access to the organization]
password No(*) password of the database user you choose [password for the user you created in InfluxDB that has access to the organization or blank if you created an access token]
token No(*) token to authenticate the database (only for V2) Intructions about how to create one(opens new window) [If you created a token to use instead of password, enter that access token here, otherwise leave blank]
db openhab No name of the database for V1 and name of the organization for V2 [the organization you created]
retentionPolicy autogen No name of the retention policy for V1 and name of the bucket for V2 [the bucket you created if you created one in the organization]

I am trying to understand what specifically needs to be set up in InfluxDBv2 in order to have all the information necessary for that page. I have tried everything that seems right, and I just continually get “unauthorized access”; clearly something about my InfluxDBv2 setup is incomplete.

Did you already login to InfluxDB? You have to create an Organization - e.g. “private” and a user to administrate your InfluxDB.
After that, create a Bucket (e.g. “openHAB”). Set the retention policy to a reasonable value, e.g. “1 year”, which means InfluxDB will delete data older than one year.
Switch to “API tokens” and generate a token for openHAB - Custom API Token, read/write Access for bucket “openHAB”.
Copy the Token. Don’t use the “Copy to Clipboard” Button, it’s not functional (at least in Firefox)

Go to openHAB and setup the InfluxDB Persistence Addon.
Use the Token, not the password (there is no usable password in v2)
You don’t need to set a user name (but you could).
Of course you have to set the bucket to “openHAB” and the organization to “private” (if these are the correct values set by you in the first step).

1 Like

THX for this guide - worked in first attempt.