The Things Stack integration ? (on TTN V3)?

+1 to the mqtt solution. I initially tried the plugin, but switched to mqtt via the included HA addon. For those looking for how, it’s really easy:

File: share/mosquitto/mosquitto.conf

connection bridge-nam1-nodes
address nam1.cloud.thethings.network:8883
bridge_protocol_version mqttv311
bridge_capath /etc/ssl/certs 
try_private false   
bridge_insecure false
notifications false
remote_username <REPLACEUSERNAME>
remote_password <REPLACEPASSWORD>
topic # in 0 /ttn/
cleansession true

I did put their root ca into my config/certs directory, but not sure if necessary.

3 Likes

I am a beginner on HA, I am just getting to grip with things.
I have used TTNv2 and TTNv3 for a while now and I send data from various lorawan devices there to an IoT stack (influxDB/Grafana). Someone else help me set that one up.
I was impressed to see a TTNv2 integragration, hence I was very interested to check if TTNv3 might be fully integrated at some point. It would be great to easily connect HA to TTNv3.

I haven’t tried MQTT in HA yet, but I will try to find out more on how it could be done.
I am reading the instructions by @noebl1 but I am probably missing some of the necessary steps, as I cannot understand how to use the file and commands given.

2 Likes

If you need some help, @sp8 , feel free to dm me! I currently run the MQTT add on which isn’t too bad to set up. For it to work with TTN, you need to set up an MQTT bridge so you can watch your node(s) traffic. You can even have multiple bridges for multiple applications (which is what I do for testing).

I also send all my traffic to my TIG stack :blush:

1 Like

same here, one bridge per application in TTNv3 and all good :wink: and it works perfect since a year when V3 was released :wink:

1 Like

Can you share the speed of reaction?

latency/speed on TTN is diabolical… look at Chirpstack and self host…

@anon63427907 sorry for late answer but not really any real latency but I use it only for some weather sensors and I have a local TTN gateway but everything runs still through TTN servers for sure :slight_smile:

1 Like

Hey,
thanks for the introduction to the mqtt bridge. I can receive data. The only thing, I haven’t figured it is how to access the values correctly.
My live data format on TTN looks like following:

 "received_at": "2023-03-08T09:50:48.979376486Z",
    "uplink_message": {
      "session_key_id": "AYbAlRIHL38aAluagjIbeA==",
      "f_port": 1,
      "f_cnt": 6,
      "frm_payload": "V9QAowCgEyZBhw==",
      "decoded_payload": {
        "bytes": {
          "decodingInfo": "values: [t=0, t-1, t-2, ...]",
          "status": {
            "configuration2ChannelsActivated": true,
            "configurationDone": false,
            "configurationInconsistency": false,
            "frameCounter": 6,
            "hardwareError": false,
            "lowBattery": false,
            "timestamp": true
          },
          "temperatures": [
            {
              "name": "temperature 1",
              "unit": "°C",
              "values": [
                16.3
              ]
            },
            {
              "name": "temperature 2",
              "unit": "°C",
              "values": [
                16
              ]
            }
          ],
          "timestamp": "2023-03-08T10:50:47.000",
          "type": "0x57 Temp 4 periodic data"
        }
      },

How can I access the both temperature values? The only thing I can access is f_port by using

value_template: "{{ value_json.uplink_message.f_port }}"

Anyone has an idea how to write the correct value_template?

I’ve solved it with the following value_template:

value_json.uplink_message.decoded_payload.bytes.temperatures[0]['values'][0]

I also added:

device_class: "temperature"
unit_of_measurement: '°C'

and now it’s working fine.

1 Like

perfect you found out by yourself the good way and I can also add that now at least for sensors you don’t need anymore all the mqtt thing and the parsing, it exists a non official but working perfect so far integration for TTN V3: GitHub - angelnu/home_assistant_thethingsnetwork: TheThingsNetwork v3 integration for Home Assistant :sunglasses:

1 Like

Is that an HACS integration? I cannot find it over HACS if I search for “TTN”, “the things” or “adapter”. Do I need to add the repository first?

It needs to be added to the list of repositories for HACS, as it’s not included by default yet.

Any idea where I can find some payload formatter code to decrypt the messages on TTN? I have an Innotas heating counter but the payload doesnt decrypt with the standard formatter on the Thing Stack.

Manufacturer is the first place to check for that :wink:

1 Like

Hi Emily,
how did you managed that the bridge now works with TLS over the port 8883 ?
I still get an error because of protocol and can´t establish a stable connection.
Thanks and kind regards