Page 3 of 5

Re: Getting data from LoRa - TTN network

Posted: Friday 18 June 2021 23:34
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.

Getting data from LoRa - TTN network

Posted: Saturday 19 June 2021 8:39
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 :) )

Re: Getting data from LoRa - TTN network

Posted: Saturday 19 June 2021 10:19
by PAHVelthuis
That would be great!

Re: Getting data from LoRa - TTN network

Posted: Tuesday 06 July 2021 8:51
by polo9222
I confirm ,it would bé great as nos it is impossible to work on v2 stack.
Thanks

Re: Getting data from LoRa - TTN network

Posted: Wednesday 20 October 2021 10:41
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.

Re: Getting data from LoRa - TTN network

Posted: Wednesday 20 October 2021 12:42
by polo9222
Thanks for your précise information. I will try soon.

Re: Getting data from LoRa - TTN network

Posted: Wednesday 20 October 2021 14:44
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).

Re: Getting data from LoRa - TTN network

Posted: Monday 01 November 2021 17:49
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).

Re: Getting data from LoRa - TTN network

Posted: Wednesday 10 November 2021 7:34
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.

Re: Getting data from LoRa - TTN network

Posted: Wednesday 10 November 2021 13:39
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!

Re: Getting data from LoRa - TTN network

Posted: Wednesday 10 November 2021 17:38
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...

Re: Getting data from LoRa - TTN network

Posted: Wednesday 10 November 2021 22:05
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.

Re: Getting data from LoRa - TTN network

Posted: Friday 12 November 2021 11:22
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.

Re: Getting data from LoRa - TTN network

Posted: Saturday 13 November 2021 15:52
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

Re: Getting data from LoRa - TTN network

Posted: Saturday 13 November 2021 16:02
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!)

Getting data from LoRa - TTN network

Posted: Saturday 13 November 2021 17:12
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’.

Re: Getting data from LoRa - TTN network

Posted: Saturday 13 November 2021 20:21
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?

Re: Getting data from LoRa - TTN network

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

If not (it should), you could create it your self. See GitHub repo (Beta).

Re: Getting data from LoRa - TTN network

Posted: Sunday 14 November 2021 8:24
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

Getting data from LoRa - TTN network

Posted: Sunday 14 November 2021 8:34
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’.