Getting data from LoRa - TTN network

Moderator: leecollings

PAHVelthuis
Posts: 5
Joined: Monday 11 May 2015 15:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Getting data from LoRa - TTN network

Post by PAHVelthuis »

I have my Gateway and nodes running on V3.
Does someone know if this plugin is actually compatible with V3?

Looks like everything has been configured as it should, however nothing happens (no new devices can be found) exept the following lines in the log file:

2021-06-18 23:25:03.377 Status: TheThings: Connecting to eu1.cloud.thethings.network:1883
2021-06-18 23:25:03.519 Status: TheThings: Connected to: eu1.cloud.thethings.network:1883
2021-06-18 23:25:03.619 Status: TheThings: Subscribed

And yes, I have allowed Domoticz to accept new devices for 5 minutes.
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Getting data from LoRa - TTN network

Post by kiddigital »

The current TTNMQTT module connects to the V2 TTN network.

If you are talking about the Python/Lua plugin, I do not know.

When I find some time, I will have a look at making the module compatible with V3 (others are free to beat me too it :) )
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
PAHVelthuis
Posts: 5
Joined: Monday 11 May 2015 15:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Getting data from LoRa - TTN network

Post by PAHVelthuis »

That would be great!
polo9222
Posts: 8
Joined: Saturday 09 December 2017 16:53
Target OS: -
Domoticz version:

Re: Getting data from LoRa - TTN network

Post by polo9222 »

I confirm ,it would bé great as nos it is impossible to work on v2 stack.
Thanks
boutje
Posts: 3
Joined: Wednesday 20 October 2021 9:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Getting data from LoRa - TTN network

Post by boutje »

Hi all,

I had the same problem. I have an end device that periodically sends CAYENNELPP data to Domoticz.
No problem in TTN V2 but MQTT registration fails when connecting to V3. Domoticz says “Subscribed” but that is not true.
After “steeling” various codes from the internet I have a “workaround” at least for receiving data.
Basically mosquitto_sub subscribes to the TTN topic, some bash code translates the data and mosquitto_pub publishes the data locally to Domoticz.
The Cayenne data is:
analog_in_2
barometric_pressure_1
relative_humidity_1
temperature_1
It works for me in ubuntu and Raspbian.
In Domoticz add a hardware MQTT Client gateway with LAN interface.
Set the remote address to localhost and the port to 1883.
I set the publish topic to None because I don’t need outgoing MQTT messages.
Then I added a hardware type Dummy from witch I created a Temperature-, Barometer-, Humidity- and Custom sensor.
I installed mosquitto, mosquitto-clients and jq.
In terminal enter the following code after replacing your TTN data (if it works then make a bash script), you can uncomment the echo $RAW_DATA to see if you receive the data and check the code if necessary.
Be sure to copy your API key at the moment you generate it in V3 because afterwards you can only copy part of the key.
Change the device idx in the code to the appropriate numbers.

Code: Select all

mosquitto_sub -h eu1.cloud.thethings.network -p 1883 -t 'v3/---your-application-id---@ttn/devices/your---device/up' -u your---application-id--- -P '---your-password=API-key' | 
while read RAW_DATA
do
 #echo $RAW_DATA
 ana=`echo $RAW_DATA | jq -r '.uplink_message.decoded_payload.analog_in_2'`
 bar=`echo $RAW_DATA | jq -r '.uplink_message.decoded_payload.barometric_pressure_1'`
 hum=`echo $RAW_DATA | jq -r '.uplink_message.decoded_payload.relative_humidity_1'`
 tmp=`echo $RAW_DATA | jq -r '.uplink_message.decoded_payload.temperature_1'`
 mosquitto_pub -h localhost -m '{ "idx" : 168, "svalue" : "'$tmp'"}' -t 'domoticz/in'
 mosquitto_pub -h localhost -m '{ "idx" : 172, "svalue" : "'$ana'"}' -t 'domoticz/in'
 if (( $(echo "$hum > 70" |bc -l) ))
 then
  hum_stat=3
 elif (( $(echo "$hum < 30" |bc -l) ))
 then
  hum_stat=2
 elif (( $(echo "$hum >= 30 && $hum <= 45" |bc -l) ))
 then
  hum_stat=0
 elif (( $(echo "$hum > 45 && $hum <= 70" |bc -l) ))
 then
  hum_stat=1
 fi
 mosquitto_pub -h localhost -m '{ "idx" : 170, "nvalue" : '${hum/\.*/}', "svalue" : "'$hum_stat'"}' -t 'domoticz/in'
 bar_for=0
 if (( $(echo "$bar > 1030" |bc -l) ))
 then
  bar_for=1
 elif (( $(echo "$bar > 1010 && $bar <= 1030" |bc -l) ))
 then
  bar_for=2
 elif (( $(echo "$bar > 990 && $bar <= 1010" |bc -l) ))
 then
  bar_for=3
 elif (( $(echo "$bar > 970 && $bar <= 990" |bc -l) ))
 then
  bar_for=4
 fi
 mosquitto_pub -h localhost -m '{ "idx" : 173, "nvalue" : 0, "svalue" : "'$bar';'$bar_for'"}' -t 'domoticz/in'
 echo $(date)
done
Hope it works for you too.
Success.
polo9222
Posts: 8
Joined: Saturday 09 December 2017 16:53
Target OS: -
Domoticz version:

Re: Getting data from LoRa - TTN network

Post by polo9222 »

Thanks for your précise information. I will try soon.
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Getting data from LoRa - TTN network

Post by kiddigital »

kiddigital wrote:The current TTNMQTT module connects to the V2 TTN network.

If you are talking about the Python/Lua plugin, I do not know.

When I find some time, I will have a look at making the module compatible with V3 (others are free to beat me too it :) )
Started first development on V3 support.. hope to finish it in coming week(s).
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Getting data from LoRa - TTN network

Post by kiddigital »

kiddigital wrote: Wednesday 20 October 2021 14:44
kiddigital wrote:The current TTNMQTT module connects to the V2 TTN network.

If you are talking about the Python/Lua plugin, I do not know.

When I find some time, I will have a look at making the module compatible with V3 (others are free to beat me too it :) )
Started first development on V3 support.. hope to finish it in coming week(s).
See PR #5005 for an updated version that works with the Community Edition (v3).
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Getting data from LoRa - TTN network

Post by kiddigital »

Since Beta build 13871 (or higher), the TTNMQTT module now connects to the Community Edition (v3) of The Things Network and handles the new message format of v3.

@PAHVelthuis , @boutje, @polo9222 (and others), give it a try and let us know if everything works as it should.
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
boutje
Posts: 3
Joined: Wednesday 20 October 2021 9:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Getting data from LoRa - TTN network

Post by boutje »

Hi kiddigital, I have a testdevice at home and now I see new devices in domoticz so this works.
There is now a "Temp + Humidity + Baro" and a "General/Custom Sensor"
My CayenneLPP payload consists of a type 0x2 (Analog Input), 0x73 (Barometer), 0x68 (Humidity Sensor), 0x67 (Temperature Sensor).
There are however also devices "Geo", "Home Distance" and "Gateway Distance" generated.
I have a device in the fields still working on V2 which I shall switch to V3 a soon as possible.
But for now, great job!
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Getting data from LoRa - TTN network

Post by kiddigital »

boutje wrote: Wednesday 10 November 2021 13:39 Hi kiddigital, I have a testdevice at home and now I see new devices in domoticz so this works.
There is now a "Temp + Humidity + Baro" and a "General/Custom Sensor"
My CayenneLPP payload consists of a type 0x2 (Analog Input), 0x73 (Barometer), 0x68 (Humidity Sensor), 0x67 (Temperature Sensor).
Nice :)
boutje wrote: Wednesday 10 November 2021 13:39 There are however also devices "Geo", "Home Distance" and "Gateway Distance" generated.
Correct, those are bonus devices that represent the distance (in centimeters at the moment) between the location of the sensor (either from the GPS data from the sensor if available but most likely based on the location of the device as set in the TTN console) and the Domoticz Home location and the distance to the Gateway that was the most nearby the sensor. This info can be used for Geo(fencing) use-cases.

At the moment, these extra devices are always created. But maybe it could become an optional setting.. Problem is that you can not pick for which sensors it should or should not apply. It is for the whole module.

When a sensor does not have Location data (so also not via data set in the TTN Console), these devices are not generated.

Are these 'extra' devices useful for you? Or would you rather not have them, or leave them but just not used :) ?
boutje wrote: Wednesday 10 November 2021 13:39 I have a device in the fields still working on V2 which I shall switch to V3 a soon as possible.
But for now, great job!
Thx, great to hear it works...
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
polo9222
Posts: 8
Joined: Saturday 09 December 2017 16:53
Target OS: -
Domoticz version:

Re: Getting data from LoRa - TTN network

Post by polo9222 »

kiddigital wrote: Wednesday 10 November 2021 7:34 Since Beta build 13871 (or higher), the TTNMQTT module now connects to the Community Edition (v3) of The Things Network and handles the new message format of v3.

@PAHVelthuis , @boutje, @polo9222 (and others), give it a try and let us know if everything works as it should.
Hi kiddigital,
Let me thank you for this interesting information. Unfortunately I will not be able to check before Christmas at least. I have no spare equipment presently.
I will keep you informed anyway.
boutje
Posts: 3
Joined: Wednesday 20 October 2021 9:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Getting data from LoRa - TTN network

Post by boutje »

Are these 'extra' devices useful for you? Or would you rather not have them, or leave them but just not used :) ?
Hi kiddigital,

I will leave these extra devices unused for now but might be handy in the future.
jeroenkl
Posts: 113
Joined: Sunday 14 July 2013 22:00
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: NL
Contact:

Re: Getting data from LoRa - TTN network

Post by jeroenkl »

For my Wisblock device, the LPP data is not accepted by domoticz:

2021-11-13 15:52:37.632 Error: TESTv3MQTT client gateway Wisblocks: Invalid data received! Unable to decode the raw payload and the decoded payload does not contain any (valid) data!

Payload:
"decoded_payload": {
"analog_in_8": 4.38,
"barometric_pressure_6": 761,
"luminosity_5": 0,
"relative_humidity_7": 61,
"temperature_2": 20.7
},

https://github.com/beegee-tokyo/RAK4631 ... 02-RAK1903

@kiddigital could you help?

BR,
Jeroen
jeroenkl
Posts: 113
Joined: Sunday 14 July 2013 22:00
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: NL
Contact:

Re: Getting data from LoRa - TTN network

Post by jeroenkl »

Second device, also Wisblock, build with: https://github.com/beegee-tokyo/RAK4631 ... 04-RAK1906

Got this log message:
2021-11-13 16:00:55.391 Error: TESTv3MQTT client gateway Wisblocks: Error parsing message (Type is not convertible to string)!!!


"decoded_payload": {
"accelerometer_3": {
"x": 0.032,
"y": -0.032,
"z": -1.024
},
"analog_in_4": 3.77,
"analog_in_8": 4.12,
"barometric_pressure_6": 1012.7,
"gps_1": {
"altitude": 20.8,
"latitude": 52.xxxx,
"longitude": 5.xxxx
},
"relative_humidity_7": 67,
"temperature_2": 18.9
},

any advise?

BR,

Jeroen

(my RAk7200 LPP is working great! thanks!)
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Getting data from LoRa - TTN network

Post by kiddigital »

@jeroenkl , take a look at the aliases file (ttnmqtt_aliases.json). There you can fill in aliases for decodes payload values.

Example ‘’temperature_2” as “temperature”, so the module knowns how to treat ‘temperature_2’.
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
jeroenkl
Posts: 113
Joined: Sunday 14 July 2013 22:00
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: NL
Contact:

Re: Getting data from LoRa - TTN network

Post by jeroenkl »

kiddigital wrote: Saturday 13 November 2021 17:12 @jeroenkl , take a look at the aliases file (ttnmqtt_aliases.json). There you can fill in aliases for decodes payload values.

Example ‘’temperature_2” as “temperature”, so the module knowns how to treat ‘temperature_2’.
thxs!
Ehhh where can I find this file in my Raspberry Pi?
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Getting data from LoRa - TTN network

Post by kiddigital »

Domoticz root directory…

If not (it should), you could create it your self. See GitHub repo (Beta).
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
jeroenkl
Posts: 113
Joined: Sunday 14 July 2013 22:00
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: NL
Contact:

Re: Getting data from LoRa - TTN network

Post by jeroenkl »

kiddigital wrote: Saturday 13 November 2021 20:39 Domoticz root directory…

If not (it should), you could create it your self. See GitHub repo (Beta).
I'm sorry I need some help on this.
I created the file in domoticz root (/home/pi/domoticz/

Code: Select all

{
  "temp": [
    "temperature",
    "ambient_temperature"
  ],
  "humidity": [
    "hum"
  ],
  "baro": [
    "barometer"
  ],
  "batterylevel": [
    "battery_level"
  ],
  "gps": [],
  "luminosity": [],
  "presense": [],
  "analog_input": [],
  "analog_output": [],
  "digital_output": [],
  "digital_input": []
}
- Is this the correct file and location?

BR,

Jeroen
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Getting data from LoRa - TTN network

Post by kiddigital »

Yes that is correct. And you should see in the logging a status message telling you that the aliasses file is found and used (or not).

And in this file tou can add “temperature_2” as an entry under ‘temp’.
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest