I wanted my Lora devices on The Things Network (TTN) integrated within Home-Assistant and created a flow in Node Red to achieve this. Maybe others are also interested how I solved it and thereby I have placed it in GitHub. There are examples for sensors and also one actuator (power plug switch).
I have updated github with a more enhanced version. Here an example from a MClimate Vicki - LoRaWAN Smart Radiator Thermostat
@cnoork Just found your project it looks amazing, however I want to adapt it to Chirpstack for my usecase. Can you provide an example input payload you get from TTN, as well as a example of all output payloads you send to the HA MQTT Broker?
That would allow me to map it to Chirpstack Message format.
I will check or even add this that it is also working also with ChirpStack
This is an example how the collected data should look like after “Collect all data” The number of key’s in sensorData is dependent on the sensor. Unfortunately the ChirpStack implementation I could check does not have the join_eui (app_eui) where I make the decision what type of sensor it is.
msg.result = {
"loraData":{
"metaData":{
"deviceName":"eui-123456789abcdef0",
"join_eui":"70B3D52DD8000000",
"application":"mclimate-wirelessthermostat",
"timestamp":1742747419687,
"timestamp_hr":"2025/03/23 17:30:19 GMT"
},
"sensorData":{
"rssi":-69,
"batteryPct":73,
"lux":92,
"pir":false,
"powerSourceStatus":0,
"relativeHumidity":53.91,
"sensorTemperature":22.9,
"targetTemperature":19
}
}
}
And below is the original message from TTN:
msg = {
"end_device_ids":{
"device_id":"eui-123456789abcdef0",
"application_ids":{
"application_id":"mclimate-wirelessthermostat"
},
"dev_eui":"123456789ABCDEF0",
"join_eui":"70B3D52DD8000000",
"dev_addr":"260BFB4C"
},
"received_at":"2025-03-23T16:30:19.687815603Z",
"uplink_message":{
"session_key_id":"AZVKGRpfaiKsRti45Q194Q==",
"f_port":2,
"f_cnt":3397,
"frm_payload":"AQJ1igw2EwAAXAA=",
"decoded_payload":{
"batteryPct":73,
"lux":92,
"payloadHex":"0102758a0c361300005c00",
"pir":false,
"powerSourceStatus":0,
"relativeHumidity":53.91,
"sensorTemperature":22.9,
"targetTemperature":19
},
"rx_metadata":[
{
"gateway_ids":{
"gateway_id":"gateway_name",
"eui":"58A0CBFFFE123456"
},
"time":"2025-03-23T16:30:19.405189990Z",
"timestamp":3908887531,
"rssi":-69,
"channel_rssi":-69,
"snr":10.5,
"location":{
"latitude":0.0,
"longitude":0.0,
"altitude":0,
"source":"SOURCE_REGISTRY"
},
"uplink_token":"ChgKFgKGFiy1ub9yaxIIWKDL//6ABQ8fzxw4aAib7oC/BhDkNvkSDm+ne4eIF",
"received_at":"2025-03-23T16:30:19.426231909Z"
}
],
"settings":{
"data_rate":{
"lora":{
"bandwidth":125000,
"spreading_factor":7,
"coding_rate":"4/5"
}
},
"frequency":"867100000",
"timestamp":3908887531,
"time":"2025-03-23T16:30:19.405189990Z"
},
"received_at":"2025-03-23T16:30:19.480323863Z",
"consumed_airtime":"0.061696s",
"version_ids":{
"brand_id":"mclimate",
"model_id":"wireless-thermostat",
"hardware_version":"2.5",
"firmware_version":"1.4",
"band_id":"EU_863_870"
},
"network_ids":{
"net_id":"000013",
"ns_id":"EC656E0000000181",
"tenant_id":"ttn",
"cluster_id":"eu1",
"cluster_address":"eu1.cloud.thethings.network"
},
"last_battery_percentage":{
"f_cnt":3339,
"value":73.91304,
"received_at":"2025-03-23T06:49:38.926953928Z"
}
}
}
For downlink you need to look at MQTT - ChirpStack open-source LoRaWAN<sup>®</sup> Network Server
Only TTN is using the application name from the GUI also in the backend while ChirpStack is using an id from the application, Probably it more wise to use the ID as application in Node Red, this info is also only used for the downlinks and thereby it is not important.