# Connecting TTN - OpenHab

**URL:** <https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289>\
**Category:** Application Development\
**Created:** [April 19, 2020, 8:23pm UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289 "2020-04-19T20:23:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![miguel635](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/miguel635/32/25844_2.png) [@miguel635](https://www.thethingsnetwork.org/forum/u/miguel635)\
**Post date:** [April 19, 2020, 8:23pm UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/1 "2020-04-19T20:23:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [April 19, 2020, 8:59pm UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/2 "2020-04-19T20:59:40Z")

</div>

> [@miguel635](#):
>
> Failed subscribing to topic homeassistant/#

There is no such topic on TTN. Check [the mqtt quickstart documentation](https://www.thethingsnetwork.org/docs/applications/mqtt/quick-start.html) (In the examples after the -t command line switch) or the [mqtt api documentation](https://www.thethingsnetwork.org/docs/applications/mqtt/api.html) for the topic format used by TTN.

---

<div class="post-metadata">

**Author:** ![jfmateos](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jfmateos/32/48524_2.png) [@jfmateos](https://www.thethingsnetwork.org/forum/u/jfmateos)\
**Post date:** [April 20, 2020, 6:13am UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/3 "2020-04-20T06:13:18Z")

</div>

Dear Miguel,  
This is the configuration I use in openHAB  
 ![imagen](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/c/2/c2ef970a558dae90bb08642b83e444a0e15c32f4.png)  
 ![imagen](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/5/c/5c2c318b7eaa1b16043e6dfd95269e53f00b557a.png)

Then I install de JSON path transformation binding  
 ![imagen](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/a/b/ab43fcddda1f3a23bf0180dcaf65cf6b70c384af.png)  
And finally I configure an MQTT Generic Thing with its channels  
 ![imagen](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/1/e/1e74ff2ea19b2db1b1888fcd647821e21c105efe.png)  
And in each channel I subscribe it to the full uplink topic and then get the data with a JSON transformation  
 ![imagen](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/e/6/e6474c3c2f8acc2b26ac995bbf979f1391ce6805.png)

---

<div class="post-metadata">

**Author:** ![miguel635](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/miguel635/32/25844_2.png) [@miguel635](https://www.thethingsnetwork.org/forum/u/miguel635)\
**Post date:** [April 20, 2020, 9:35am UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/4 "2020-04-20T09:35:47Z")

</div>

Hello kersing, jfmateos,

Thank you for your answer.

I have compared your configuration with mine and seems OK.

1. Broker MQTT  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/7/5/750c2667c53ea57df61ea79ab9f8b2e61d2e8120.png)  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/a/9/a94042ef53b2d7d8fc35f40d667cf095dcaa7cb3.png)

2. Generic Thing  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/8/1/8171e7110a4f48a45e06a8bbe0aa3e7587d82aaa.png)  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/4/b/4be6df260e4908d2c0a73f8666a48097202f0290.png)

3. Channel  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/f/d/fdccc136a92d820f6f9a8f50cc2545728b549cf1.png)

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.

---

<div class="post-metadata">

**Author:** ![jfmateos](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jfmateos/32/48524_2.png) [@jfmateos](https://www.thethingsnetwork.org/forum/u/jfmateos)\
**Post date:** [April 20, 2020, 9:42am UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/5 "2020-04-20T09:42:14Z")

</div>

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](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/c/1/c1ef009c7dda15d70fba8000544e4cb4153ee6f9.png)

With this payload format, a typical packet will decode this way  
 ![imagen](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/0/5/05c6d6a79e4d87026d23013da3c6a95d02a4922d.png)

---

<div class="post-metadata">

**Author:** ![miguel635](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/miguel635/32/25844_2.png) [@miguel635](https://www.thethingsnetwork.org/forum/u/miguel635)\
**Post date:** [April 20, 2020, 10:19am UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/6 "2020-04-20T10:19:24Z")

</div>

Hello,

I am using a custom payload as follows:  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/4/5/452a5444cbcc1659f97a4d0974196171142bdbaa.png)

And this is how is decoding the payload  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/1/7/17596efa794d940e916f829d2fb2d1c203b7e77f.png)

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

Regards.

---

<div class="post-metadata">

**Author:** ![LoRaTracker](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/loratracker/32/48502_2.png) [@LoRaTracker](https://www.thethingsnetwork.org/forum/u/LoRaTracker)\
**Post date:** [April 20, 2020, 11:12am UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/7 "2020-04-20T11:12:13Z")

</div>

Your sending sensor packets every 15 seconds ?

---

<div class="post-metadata">

**Author:** ![jfmateos](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jfmateos/32/48524_2.png) [@jfmateos](https://www.thethingsnetwork.org/forum/u/jfmateos)\
**Post date:** [April 20, 2020, 11:18am UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/8 "2020-04-20T11:18:56Z")

</div>

Ok I see the problem, you have written payloads\_fields, but it should be payload\_fields

---

<div class="post-metadata">

**Author:** ![miguel635](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/miguel635/32/25844_2.png) [@miguel635](https://www.thethingsnetwork.org/forum/u/miguel635)\
**Post date:** [April 20, 2020, 12:23pm UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/9 "2020-04-20T12:23:27Z")

</div>

Hello again,

I have fix the error in the payload but the broker is still Offline:  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/4/9/493ce039151d599f07198803b61325e6fae965a4.png)  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/1/1/11e34d9f7704bcad48a2470c4626d26b172da6ee.png)

Regards.

---

<div class="post-metadata">

**Author:** ![jfmateos](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jfmateos/32/48524_2.png) [@jfmateos](https://www.thethingsnetwork.org/forum/u/jfmateos)\
**Post date:** [April 20, 2020, 12:27pm UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/10 "2020-04-20T12:27:37Z")

</div>

Dear Miguel,  
Please compare yours  
 ![imagen](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/c/f/cf1db450fd31f9327f5883c93618fae2cb21f9e8.png)  
with mine  
 ![imagen](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/c/4/c4aa6d021a6ca8c0a7f4851babaf97624a2fad99.png)

---

<div class="post-metadata">

**Author:** ![miguel635](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/miguel635/32/25844_2.png) [@miguel635](https://www.thethingsnetwork.org/forum/u/miguel635)\
**Post date:** [April 20, 2020, 12:39pm UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/11 "2020-04-20T12:39:46Z")

</div>

You are right, sorry.

![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/4/c/4cf9109828ae5ee4c52d5109fab302cc8041e6cb.png)

But still Offline.

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

Regards.

---

<div class="post-metadata">

**Author:** ![jfmateos](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jfmateos/32/48524_2.png) [@jfmateos](https://www.thethingsnetwork.org/forum/u/jfmateos)\
**Post date:** [April 20, 2020, 2:02pm UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/12 "2020-04-20T14:02:30Z")

</div>

Yes, the MQTT broker should be online  
 ![imagen](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/6/0/605ce216fd1c2d97867071e43b5dcb953fbf7743.png)  
Miguel, would you mind to allow me (jfmateos) as collaborator of your miguel635\_prueba application (through the Settings tab) to check it  
 ![imagen](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/c/5/c5b72aa7fe10618b5547fd269cec8bb0b883fda6.png)

---

<div class="post-metadata">

**Author:** ![miguel635](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/miguel635/32/25844_2.png) [@miguel635](https://www.thethingsnetwork.org/forum/u/miguel635)\
**Post date:** [April 20, 2020, 2:06pm UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/13 "2020-04-20T14:06:34Z")

</div>

Sure, done.

---

<div class="post-metadata">

**Author:** ![jfmateos](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jfmateos/32/48524_2.png) [@jfmateos](https://www.thethingsnetwork.org/forum/u/jfmateos)\
**Post date:** [April 20, 2020, 2:15pm UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/14 "2020-04-20T14:15:05Z")

</div>

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](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/3/d/3d3436c825296b6f040c73022fb3c5e9d8a803fc.png)

![imagen](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/9/4/94df7bff8e7f817e06681e3943c96175bf96a942.png)

![imagen](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/3/d/3d4d42fee5ce96c4f91f3c0f3863a3e8c0a99bfc.png)

---

<div class="post-metadata">

**Author:** ![jfmateos](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jfmateos/32/48524_2.png) [@jfmateos](https://www.thethingsnetwork.org/forum/u/jfmateos)\
**Post date:** [April 20, 2020, 2:34pm UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/15 "2020-04-20T14:34:04Z")

</div>

I have also configured your sensor and it is working properly  
 ![imagen](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/9/8/985a88c34616cd5605f15b89c0efb0a47defe4c0.png)

![imagen](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/7/a/7a52f7899af93c8495683e9a6a096543a2439f5b.png)

---

<div class="post-metadata">

**Author:** ![jfmateos](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jfmateos/32/48524_2.png) [@jfmateos](https://www.thethingsnetwork.org/forum/u/jfmateos)\
**Post date:** [April 20, 2020, 2:34pm UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/16 "2020-04-20T14:34:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![miguel635](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/miguel635/32/25844_2.png) [@miguel635](https://www.thethingsnetwork.org/forum/u/miguel635)\
**Post date:** [April 20, 2020, 3:16pm UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/17 "2020-04-20T15:16:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jfmateos](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jfmateos/32/48524_2.png) [@jfmateos](https://www.thethingsnetwork.org/forum/u/jfmateos)\
**Post date:** [April 20, 2020, 3:20pm UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/18 "2020-04-20T15:20:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [April 20, 2020, 3:33pm UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/19 "2020-04-20T15:33:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![PAntoni](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/pantoni/32/46500_2.png) [@PAntoni](https://www.thethingsnetwork.org/forum/u/PAntoni)\
**Post date:** [June 11, 2024, 9:48am UTC](https://www.thethingsnetwork.org/forum/t/connecting-ttn-openhab/36289/20 "2024-06-11T09:48:42Z")

</div>

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.
