The Things Network (TTN) - new adapter for v3

You should forget about that integration that works not well and is not supported. Use the mqtt bridge as explained in previous posts, it works fantastic and is very reliable (a lot more than using TTN API that has sometimes some lags or failures !)

the problem seems to be the credentials to connect - these credentials are given when you add the integration. Currently is not possible to change them afterwards so you might try removing and re-addign the integration.

@vincen - your statement about not being supported or not working is wrong - it does work for some of us and it does has some advantages over using mqttp. Yes, it is a hobby project so support it is done when time allows - PRs are always welcome.

So if some want to use mqttp that is fine - it is good to have options - but let us not confuse users with there only being an option.

I have a door sensor and the state change only comes with the next polling of the persistent TTN storage. Is there a way to get notified immediately similar to MQTT? Webhooks will work, but it seems hardly possible to integrate with HA.

Use MQTT to connect HA with TTN and you’ll get immediate notifications :wink:

After asking the HA community the decision was to upgrade the v2 integration in core to v3 based on my code: Deprecated TheThingsNetwork - replace or remove? · Issue #112491 · home-assistant/core · GitHub

I am in the process of doing so. Once the basics are there I can add support to combine the storage API with the MQTT updates: in fact the client I splitted at GitHub - angelnu/thethingsnetwork_python_client: A python client to fetch/receive and parse uplink messages from The Thinks Network already has the API prepared for it

Using the MQTT integrationw ill still work. IMO the MQTT allows for further control of how the TTN sensors looks like in HA but it requires adding each single device in the HA configuration.yaml while the integration automates this: any TTN with a decoded_payload will be automatically added. Also, using the options of the integration, is possible to define how each of this values will be represented as (platform, device/class type, icon, measurement unit, entity name, etc)

4 Likes

Just wanted to let you know that I’m looking forward to this being implemented. LoRa as a radio technology is amazing, but the lack of good interfaces to HA makes using it really hard. Thanks for reducing the friction!

1 Like

Another thing to make the TTN devices work out of the box would be to have a list of “known” values such as temperature, humidity, luminosity, etc. In the custom adapter you could create such mappings in the integration option. For the integration into core I am thinking about shipping some defaults in the base client library.

If anyone is aware of an standard for this mapping please reply. If not I would likely implement it as yaml in the base library.

Hello

The integration worked for me once. Now I have created a new application ID in the TTN portal and added a sensor (LHT65N).
Unfortunately, I cannot link the new application ID, no sensor is displayed.
Can only 1 application ID be linked with this integration?

I cannot delete a single sensor or device in the working integration, how does deletion work?

Greetings

If you creae a new app in TTN console just add again the integration with new API credentials and you should be all good :wink:

Yes, I did that, unfortunately without success.
Deleting the entire integration did not help either.

I would check that you have a decoder in your application that us being able to get ypu a decoded_payload for your device.

It should be possible to add multiple instances of the integration. I did not explicitly test it in the custom integration but with the WIP to merge into home assustant core this was one of the tests.

need some help on this integration.
I created the access key on TTS and added the Application ID as well the access the the config of the integration.
following the debug log:

2024-04-25 17:17:59.449 DEBUG (MainThread) [custom_components.thethingsnetwork] Fetch of ttn data: 360s
2024-04-25 17:17:59.449 DEBUG (MainThread) [custom_components.thethingsnetwork] URL: https://eu1.cloud.thethings.network/api/v3/as/applications/eui-2cf7f1c054xxxxxx/packages/storage/uplink_message?last=360s&order=received_at
2024-04-25 17:17:59.628 DEBUG (MainThread) [custom_components.thethingsnetwork] TTN entry: b'{"error":{"code":7, "message":"error:pkg/auth/rights:no_application_rights (no rights for application `eui-2cf7f1c054xxxxxx@ttn`)", "details":[{"@type":"type.googleapis.com/ttn.lorawan.v3.ErrorDetails", "namespace":"pkg/auth/rights", "name":"no_application_rights", "message_format":"no rights for application `{uid}`", "attributes":{"uid":"eui-2cf7f1c054xxxxxx@ttn"}, "correlation_id":"55b76859d2a34dd48929c62a88xxxxxx", "code":7}]}}\n'
2024-04-25 17:17:59.629 ERROR (MainThread) [custom_components.thethingsnetwork] TTN entry without result: {'error': {'code': 7, 'message': 'error:pkg/auth/rights:no_application_rights (no rights for application `eui-2cf7f1c054xxxxxx@ttn`)', 'details': [{'@type': 'type.googleapis.com/ttn.lorawan.v3.ErrorDetails', 'namespace': 'pkg/auth/rights', 'name': 'no_application_rights', 'message_format': 'no rights for application `{uid}`', 'attributes': {'uid': 'eui-2cf7f1c054xxxxxx@ttn'}, 'correlation_id': '55b76859d2a34dd48929c62a88xxxxxx', 'code': 7}]}}
2024-04-25 17:17:59.629 DEBUG (MainThread) [custom_components.thethingsnetwork] Finished fetching The Things Network data in 0.181 seconds (success: True)

what am i doing wrong or is there a hint on what to do different?

it’s a problem of rights ! You have well created the API key for the application ? Also you are well using ttn Europe server ? eu1 in url when you login in console of ttn ?
Are you sure you are on TTS ? If so integration supports only TTN (the public lorawan network)

you are right, I am using the TTN not TTS …

lookes like I mixed up the end device id with application id. So i set it up from scratch with new key and added the correct information into the integration config.

2024-04-26 13:04:47.556 DEBUG (MainThread) [custom_components.thethingsnetwork] Fetch of ttn data: 360s
2024-04-26 13:04:47.556 DEBUG (MainThread) [custom_components.thethingsnetwork] URL: https://eu1.cloud.thethings.network/api/v3/as/applications/tracker-seeed/packages/storage/uplink_message?last=360s&order=received_at
2024-04-26 13:04:47.758 DEBUG (MainThread) [custom_components.thethingsnetwork] Finished fetching The Things Network data in 0.202 seconds (success: True)

the log result looks promising … only the device is missing on the integration list:

any idea on why this could be and what to do next … ?
thanks a lot

Your devices are well in that application tracker-seeed in TTN console ?

I am not sure about your question. the device
End device ID: eui-2cf7f1c054600497 is in the application
Application ID; tracker-seeed

Did you check if the messages are decoded? My integration relays on decoded_payload being in the message. See Payload Formatters | The Things Stack for LoRaWAN for more info

Example:

the decoder was added … as seen on the live data the data is readble.

I use two different tracker … seeed and dragino. both are on the TTN and with e.g. on the lowtrack app visible. …

found my mistake … the Storage Integration was not enabled … not it is working like a charm.
Thanks a lot!!!

1 Like