Connecting TTN - OpenHab

Hi everyone,

I am trying to connect OpenHab with TTN throug the MQTT binding to visualyze the data but i am not able to do it.
According to the OpenHab documentation, the first step is create the MQTT broker but it remains always Offline.
Uploading: image.png…

I have configured the binding to eu.thethings.network adding my app_id and access_key.
That part seems ok because if (only for test) i write a bad password on purpose i receive an error message. So app_id and password are OK.

It is a bit strange, because the configuration for the broker only needs those 3 fields.

Reviewing the logs you can see the following:
2020-04-19 18:30:56.719 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘eu.thethings.network’ with clientid miguel635_prueba
2020-04-19 18:30:57.027 [WARN ] [.transport.mqtt.MqttBrokerConnection] - Failed subscribing to topic homeassistant/#

It seems that the second message is the cause but i dont know why. I have asked in the openhab community forum and probably the root cause is that TTN is rejecting the connection for some reason.

Have anyone connected OpenHab with TTN?
Does anyone know the reason for that message?

Thank you in advance.

Regards.

There is no such topic on TTN. Check the mqtt quickstart documentation (In the examples after the -t command line switch) or the mqtt api documentation for the topic format used by TTN.

Dear Miguel,
This is the configuration I use in openHAB
imagen
imagen

Then I install de JSON path transformation binding
imagen
And finally I configure an MQTT Generic Thing with its channels
imagen
And in each channel I subscribe it to the full uplink topic and then get the data with a JSON transformation
imagen

1 Like

Hello kersing, jfmateos,

Thank you for your answer.

I have compared your configuration with mine and seems OK.

  1. Broker MQTT
    image
    image

  2. Generic Thing
    image
    image

  3. Channel
    image

Is it neccessary activate anything in TTN applicattion?

I dont understand why the broker is looking for a topic called “homeassistant” since i have not configured anything with that name.

Thank you for your help.

Regards.

Dear Miguel,
Are you sure temperature is the name of the field? Take into account that TTN usually uses a raw payload, and will only decode it as payload fields if you select a payload format. For example, i use Cayenne LPP
imagen

With this payload format, a typical packet will decode this way
imagen

Hello,

I am using a custom payload as follows:
image

And this is how is decoding the payload
image

I am going to test with CayennLPP to check if that can be the problem.

Regards.

Your sending sensor packets every 15 seconds ?

Ok I see the problem, you have written payloads_fields, but it should be payload_fields

Hello again,

I have fix the error in the payload but the broker is still Offline:
image
image

Regards.

Dear Miguel,
Please compare yours
imagen
with mine
imagen

You are right, sorry.

image

But still Offline.

One doubt, Apart from that, Shouldn’t the broker be online even when the JsonPath was wrong?

Regards.

Yes, the MQTT broker should be online
imagen
Miguel, would you mind to allow me (jfmateos) as collaborator of your miguel635_prueba application (through the Settings tab) to check it
imagen

Sure, done.

Dear Miguel,
I have just configured your user in my openHAB installation and the broker is online.
Please check the full configuration carefully; if everything is OK, I would bet for a problem with the firewall or other network issue
imagen

imagen

imagen

I have also configured your sensor and it is working properly
imagen

imagen

Please remember that openhab must be rebooted after any modification related to MQTT

Hello,

According to your recomendation, i am going to reinstall everything, test with other pc or other network to determine where is the problem.

I will let it know what is the issue.

I really appreciate your help

1 Like

Thanks Miguel, take into account that my installation is OpenHAB 2.4 (not 2.5)
I’ve already removed myself as collaborator of your application

Do you keep the TTN fair access policy in mind with you sensors? On average 30 seconds of airtime each day for a sensor means you can send small amounts of data about every 5 minutes using SF7, more often means your usage is in excess of the fair access policy.

Hi, I have a similar problem. Everything works fine for openhab running in a docker container on an debioan server. The same configuration is not working with openhab running in a docker container on a synology NAS system. I don’t know why, but maybe you have the same issue.