Connecting OpenHab - TheThingsNetwork

Hello,

I am new with OpenHAB and am trying to connect with The things network to receive data from there.
I have installed the MQTT broker and created the broker and the topic, but the broker is always Offline.

I have checked the logs and i see this. It seems that the binding with TTN is working correctly and the problem is between topic and broker.

23:16:04.196 [INFO ] [o.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘eu.thethings.network’ with clientid 1368608d-36d3-47e1-bfb8-508a9ac131da
23:16:04.871 [WARN ] [o.transport.mqtt.MqttBrokerConnection] - Failed subscribing to topic homeassist

I have reviewed other messages in the forum but i dont see anything related.

Does anyone know why the broker is always offline?

Regards.

We cannot check without seeing your things and items config.

Did you install OH via the openhabian image or other?

Hello,

Thank you hmerk for your recommendation.

I add what i have configured.

  1. The MQTT Broker



    The comunicattion with the application (miguel635_prueba) in TTN seems OK.

  2. The Generic MQTT Thing.


    I have select the correct broker (I have only one)

  3. The channel

The name of the device in TTN is “demo”.

  1. Links
    image

  2. Data in TTN

Thank you in advance.

Try un-selecting the secure connection and see if the broker goes online.

Hello,

I have changed to unsecure connection and the broker remains offline.

It is a weird behaviour, because i have selectec/unselected the ssl connection a few times and the generic thing changes his status to Online sometimes and sometimes to offline. But the broker is always offline


image

I add the logs from the events

2020-04-19 17:30:07.339 [hingStatusInfoChangedEvent] - ‘mqtt:broker:b7c3fcf1’ changed from OFFLINE to OFFLINE (COMMUNICATION_ERROR): Timeout
2020-04-19 17:30:07.368 [hingStatusInfoChangedEvent] - ‘mqtt:broker:b7c3fcf1’ changed from OFFLINE (COMMUNICATION_ERROR): Timeout to ONLINE
2020-04-19 17:30:07.369 [me.event.ThingUpdatedEvent] - Thing ‘mqtt:broker:b7c3fcf1’ has been updated.
2020-04-19 17:30:07.369 [hingStatusInfoChangedEvent] - ‘mqtt:broker:b7c3fcf1’ changed from ONLINE to OFFLINE
2020-04-19 17:30:07.370 [hingStatusInfoChangedEvent] - ‘mqtt:topic:ed82f4e9’ changed from OFFLINE (COMMUNICATION_ERROR): java.lang.Exception: No MQTT client to OFFLINE (BRIDGE_OFFLINE)
2020-04-19 17:30:07.388 [me.event.ThingUpdatedEvent] - Thing ‘mqtt:broker:b7c3fcf1’ has been updated.
2020-04-19 17:30:07.472 [hingStatusInfoChangedEvent] - ‘mqtt:topic:ed82f4e9’ changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2020-04-19 17:32:17.436 [hingStatusInfoChangedEvent] - ‘mqtt:broker:b7c3fcf1’ changed from OFFLINE to OFFLINE (COMMUNICATION_ERROR): Timeout
2020-04-19 17:32:17.447 [hingStatusInfoChangedEvent] - ‘mqtt:broker:b7c3fcf1’ changed from OFFLINE (COMMUNICATION_ERROR): Timeout to ONLINE
2020-04-19 17:32:17.447 [me.event.ThingUpdatedEvent] - Thing ‘mqtt:broker:b7c3fcf1’ has been updated.
2020-04-19 17:32:17.448 [hingStatusInfoChangedEvent] - ‘mqtt:topic:ed82f4e9’ changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2020-04-19 17:32:17.448 [hingStatusInfoChangedEvent] - ‘mqtt:broker:b7c3fcf1’ changed from ONLINE to OFFLINE
2020-04-19 17:32:17.510 [hingStatusInfoChangedEvent] - ‘mqtt:topic:ed82f4e9’ changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2020-04-19 17:32:17.510 [hingStatusInfoChangedEvent] - ‘mqtt:topic:ed82f4e9’ changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2020-04-19 17:32:17.532 [me.event.ThingUpdatedEvent] - Thing ‘mqtt:broker:b7c3fcf1’ has been updated.
2020-04-19 17:32:35.200 [hingStatusInfoChangedEvent] - ‘mqtt:broker:b7c3fcf1’ changed from OFFLINE to OFFLINE (COMMUNICATION_ERROR): Timeout
2020-04-19 17:32:35.242 [hingStatusInfoChangedEvent] - ‘mqtt:broker:b7c3fcf1’ changed from OFFLINE (COMMUNICATION_ERROR): Timeout to ONLINE
2020-04-19 17:32:35.243 [me.event.ThingUpdatedEvent] - Thing ‘mqtt:broker:b7c3fcf1’ has been updated.
2020-04-19 17:32:35.243 [hingStatusInfoChangedEvent] - ‘mqtt:topic:ed82f4e9’ changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2020-04-19 17:32:35.247 [hingStatusInfoChangedEvent] - ‘mqtt:broker:b7c3fcf1’ changed from ONLINE to OFFLINE
2020-04-19 17:32:35.262 [hingStatusInfoChangedEvent] - ‘mqtt:topic:ed82f4e9’ changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2020-04-19 17:32:35.262 [me.event.ThingUpdatedEvent] - Thing ‘mqtt:broker:b7c3fcf1’ has been updated.

and logs from binding
2020-04-19 17:32:35.364 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘eu.thethings.network’ with clientid 1a34282a-f64b-49bd-ab52-baed5591aa79
2020-04-19 17:32:35.594 [WARN ] [.transport.mqtt.MqttBrokerConnection] - Failed subscribing to topic homeassistant/#
java.util.concurrent.CompletionException: com.hivemq.client.mqtt.mqtt3.exceptions.Mqtt3SubAckException: SUBACK contains only Error Codes
at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) ~[?:1.8.0_201]
at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) ~[?:1.8.0_201]
at java.util.concurrent.CompletableFuture.uniApply(Unknown Source) ~[?:1.8.0_201]
at java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source) ~[?:1.8.0_201]
at java.util.concurrent.CompletableFuture.postComplete(Unknown Source) ~[?:1.8.0_201]
at java.util.concurrent.CompletableFuture.completeExceptionally(Unknown Source) ~[?:1.8.0_201]
at com.hivemq.client.internal.mqtt.mqtt3.Mqtt3AsyncClientView.lambda$handleSubAck$0(Mqtt3AsyncClientView.java:64) ~[?:?]
at java.util.concurrent.CompletableFuture.uniWhenComplete(Unknown Source) [?:1.8.0_201]
at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(Unknown Source) [?:1.8.0_201]
at java.util.concurrent.CompletableFuture.postComplete(Unknown Source) [?:1.8.0_201]
at java.util.concurrent.CompletableFuture.completeExceptionally(Unknown Source) [?:1.8.0_201]
at com.hivemq.client.rx.FlowableWithSingle$SingleFutureSubscriber.onError(FlowableWithSingle.java:395) [bundleFile:?]
at com.hivemq.client.internal.rx.operators.FlowableWithSingleCombine$SplitSubscriber.onError(FlowableWithSingleCombine.java:178) [bundleFile:?]
at io.reactivex.internal.operators.flowable.FlowableObserveOn$BaseObserveOnSubscriber.checkTerminated(FlowableObserveOn.java:197) [bundleFile:?]
at io.reactivex.internal.operators.flowable.FlowableObserveOn$ObserveOnConditionalSubscriber.runAsync(FlowableObserveOn.java:641) [bundleFile:?]
at io.reactivex.internal.operators.flowable.FlowableObserveOn$BaseObserveOnSubscriber.run(FlowableObserveOn.java:176) [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(Unknown Source) [?:1.8.0_201]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source) [?:1.8.0_201]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [?:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_201]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_201]
Caused by: com.hivemq.client.mqtt.mqtt3.exceptions.Mqtt3SubAckException: SUBACK contains only Error Codes

Thank you

That repeatedly happening will stop it working. It’s not talking about the online/online status, it’s talking about Thing properties (like when you edit them) so it triggers a re-initialize.
I couldn’t tell you why it is updating.

That is likely a non-issue, the binding trying to discover any home assistant topics and the remote broker rejecting it.
Unless … it is the root cause of thing update.
Anyone know how to suppress HA MQTT discovery?

As far as I can tell you can’t. This has come up on another thread regarding FarmBot that actually kicks a client offline when it tries to subscribe to any topic outside of the officially supported ones. My advice there was to file an issue to let us turn off autodiscovery for Homie and HA MQTT but I don’t know if such an issue has been filed.

A work around is to set up a local MQTT Broker to bridge with the cloud broker only those topics that are relevant. The local broker will happily ignore the subscriptions caused by the autodiscovery.

Hello,

Thank you for your answers/advices.

One colleage has tried the connection from his PC at his home and the broker works correctly so the issue must be in my PC.

I have reinstalled everything, openhab, Zulu. I have also tried the connection from my mobile connection and the result is the same

Does anyone has some idea about what can i configure/desconfigure in my pc?

Like I said in the very text you quoted.

  1. File an issue and wait for the developers to provide a way to turn off the autodiscovery or
  2. Set up your own MQTT broker and configure it to bridge the Thing Network broker; your OH will connect to this local MQTT broker.

@miguel635 I have exactly the same problem. I just reported this as an issue on GitHub: https://github.com/openhab/openhab-addons/issues/8056

@miguel635 This problem was now solved with OpenHab 2.5.8: https://github.com/openhab/openhab-distro/releases

I just tested this. I simply disabled the discovery in the broker settings after upgrading to the new version and now I can connect to TheThingsNetwork without any problems.