OH3 authorization problems with influxDB2

I’m running OH3.4 and InfluxDB2 (v2.5.1) under Windows 11. I’m having unauthorized access problem so my data is not persisted to influxdb.

I get following messages in OH log:

2023-01-06 08:08:02.396 [ERROR] [.client.write.events.WriteErrorEvent] - The error occurred during writing of data
com.influxdb.exceptions.UnauthorizedException: unauthorized access
	at com.influxdb.internal.AbstractRestClient.responseToError(AbstractRestClient.java:98) ~[bundleFile:?]
	at com.influxdb.client.internal.AbstractWriteClient.toInfluxException(AbstractWriteClient.java:574) ~[bundleFile:?]
	at com.influxdb.client.internal.AbstractWriteClient.lambda$new$12(AbstractWriteClient.java:181) ~[bundleFile:?]
	at io.reactivex.internal.subscribers.LambdaSubscriber.onNext(LambdaSubscriber.java:65) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableDoFinally$DoFinallySubscriber.onNext(FlowableDoFinally.java:84) [bundleFile:?]
	at io.reactivex.internal.operators.mixed.FlowableConcatMapMaybe$ConcatMapMaybeSubscriber.drain(FlowableConcatMapMaybe.java:284) [bundleFile:?]
	at io.reactivex.internal.operators.mixed.FlowableConcatMapMaybe$ConcatMapMaybeSubscriber.onNext(FlowableConcatMapMaybe.java:137) [bundleFile:?]
	at io.reactivex.internal.operators.mixed.FlowableConcatMapSingle$ConcatMapSingleSubscriber.drain(FlowableConcatMapSingle.java:279) [bundleFile:?]
	at io.reactivex.internal.operators.mixed.FlowableConcatMapSingle$ConcatMapSingleSubscriber.innerSuccess(FlowableConcatMapSingle.java:179) [bundleFile:?]
	at io.reactivex.internal.operators.mixed.FlowableConcatMapSingle$ConcatMapSingleSubscriber$ConcatMapSingleObserver.onSuccess(FlowableConcatMapSingle.java:317) [bundleFile:?]
	at io.reactivex.internal.operators.single.SingleMap$MapSingleObserver.onSuccess(SingleMap.java:64) [bundleFile:?]
	at io.reactivex.internal.operators.single.SingleMap$MapSingleObserver.onSuccess(SingleMap.java:64) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableCollectSingle$CollectSubscriber.onComplete(FlowableCollectSingle.java:119) [bundleFile:?]
	at io.reactivex.internal.subscribers.BasicFuseableSubscriber.onComplete(BasicFuseableSubscriber.java:120) [bundleFile:?]
	at io.reactivex.internal.subscribers.BasicFuseableConditionalSubscriber.onComplete(BasicFuseableConditionalSubscriber.java:119) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableGroupBy$State.checkTerminated(FlowableGroupBy.java:686) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableGroupBy$State.drainNormal(FlowableGroupBy.java:626) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableGroupBy$State.drain(FlowableGroupBy.java:558) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableGroupBy$State.onComplete(FlowableGroupBy.java:548) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableGroupBy$GroupedUnicast.onComplete(FlowableGroupBy.java:474) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableGroupBy$GroupBySubscriber.onComplete(FlowableGroupBy.java:213) [bundleFile:?]
	at io.reactivex.processors.UnicastProcessor.checkTerminated(UnicastProcessor.java:430) [bundleFile:?]
	at io.reactivex.processors.UnicastProcessor.drainRegular(UnicastProcessor.java:314) [bundleFile:?]
	at io.reactivex.processors.UnicastProcessor.drain(UnicastProcessor.java:397) [bundleFile:?]
	at io.reactivex.processors.UnicastProcessor.onComplete(UnicastProcessor.java:487) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableWindowBoundarySupplier$WindowBoundaryMainSubscriber.drain(FlowableWindowBoundarySupplier.java:254) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableWindowBoundarySupplier$WindowBoundaryMainSubscriber.innerNext(FlowableWindowBoundarySupplier.java:166) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableWindowBoundarySupplier$WindowBoundaryInnerSubscriber.onNext(FlowableWindowBoundarySupplier.java:316) [bundleFile:?]
	at io.reactivex.processors.PublishProcessor$PublishSubscription.onNext(PublishProcessor.java:360) [bundleFile:?]
	at io.reactivex.processors.PublishProcessor.onNext(PublishProcessor.java:243) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.tryEmit(FlowableFlatMap.java:282) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableFlatMap$InnerSubscriber.onNext(FlowableFlatMap.java:668) [bundleFile:?]
	at io.reactivex.subscribers.SerializedSubscriber.onNext(SerializedSubscriber.java:100) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableWindowTimed$WindowExactBoundedSubscriber.drainLoop(FlowableWindowTimed.java:498) [bundleFile:?]
	at io.reactivex.internal.operators.flowable.FlowableWindowTimed$WindowExactBoundedSubscriber$ConsumerIndexHolder.run(FlowableWindowTimed.java:579) [bundleFile:?]
	at io.reactivex.Scheduler$Worker$PeriodicTask.run(Scheduler.java:479) [bundleFile:?]
	at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66) [bundleFile:?]
	at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:829) [?:?]

INfluxDB persistence service window is shown below:

I have looked at the community and there have been rather similar issues, e.g. in this post.

InfluxDB window shows also errors (see below):

My influxdb persist file is:

// persistence strategies have a name and definition and are referred to in the "Items" section
Strategies {
        everymin : "0 * * * * ?"
}

/*
 * Each line in this section defines for which Item(s) which strategy(ies) should be applied.
 * You can list single items, use "*" for all items or "groupitem*" for all members of a group
 * Item (excl. the group Item itself).
 */
Items {
        ABB_A43_imp_energy : strategy = everymin
	Adam6250_Fortum_emittari : strategy = everymin
	Adam6250_vesimittari : strategy = everymin
	       
}

I have checked that the token which I created in Influxdb web interface is active and it is All Access API Token.

I have tried to use username/password authorization without the token and also without username/password but with the token but I still get the same errors in the OH log.

I can import my historic data into the bucket using annotated csv format so the database should be fine and I can look at the data in the web interface.

Any ideas?

I’m not sure because I use text file configurations only, but InfluxDB v2 does not use database user/password anymore, only organization, bucket and token. Perhaps if you remove Username and Database Password?
And are you sure your organization and bucket have the same name?
For reference, my influxdb.cfg looks like this (token is redacted):

# services/influxdb.cfg

# InfluxDB database version V1 for 1.X and V2 for 2.x
version=V2
# The database URL.
url=http://influxdb:8086
# Token to authenticate to the database.
token=aFL6l0lnu4YX1JatCJ6DdrKL75b9Q_KiVUfxfdy4qAbW5_NIw2Z-pwe62AJhYay-zdX4rvYRh4VzSdIal22WJg==
# The name of the organization.
db=moerman
# Name of the bucket.
retentionPolicy=openhab

I think I have made a mistake with the organization. I’m now making new tests and I have made some progress but still no data persisted into influxdb. Another mistake is that I had originally the name of the token in the InfluxDB persistence service window but I changed this to the actual API token which is shown in the web interrface right after I created the token.

I have made progress and managed to persist my measurement data into influxdb. I then wanted to change the name of the bucket (openhabtest–>openhab) in the influxdb web interface. Now I get following error message in the web interface:

For some reason the influx UI still points to the old bucket name (openhabtest). I have checked in the InfluxDB persistence service window that the bucket is openhab and not openhabtest. I have restarted both influxdb and OH.

I have now managed to get InfluxDB persistence working. There were few problems; I hadn’t copied the actual token to InfluxDB persistence service window but it’s name only. In addition, I had overlooked my organization. Of course I had to create it when setting up InfluxDB. One thing which I also noticed that when I had same name for organization and bucket, writing to the database failed due to some sort of access failure.

I had to recreate my InfluxDB database because I had used wrong (old) measurement names (from Homeseer) and it seems that you can’t change the names very easily (which I don’t quite understand). Importing old historic data (from Homeseer) is really a big breakthrough for me which means that I can shutdown Homeseer finally. Next step is to setup Grafana but I guess this will be somewhat easier.

1 Like