[SOLVED] The Thing Stack Plugin - decode TTS payload

Im currently trying to migrate my TTN devices over from using Functions to using the TTS Plugin.

Follwing the Ubitdots tutorial for setup here. F Port, Frame Counter, rssi and snr variables are displayed as a new device in ubidots, however im having trouble with the TTS device’s decoded payload not creating device variables in Ubitdots. I have also uncommented the line below as instructed in the ubidots TTS decoder script.

var decoded_payload = args['uplink_message']['decoded_payload'];

Below is the plugin log with device (current device is a Dragino Soil Moisture Probe - LSE01)

2021-09-30T01:46:39.036149Z stderr: raven@2.6.4 alert: no DSN provided, error reporting disabled
2021-09-30T01:46:39.047002Z stdout: [INFO] Received args:
2021-09-30T01:46:39.047328Z stdout: {"_parameters":{"token":"TOKEN REMOVED","device_type":"tts-devices","plugin_version_id":"614d7a38bceb5c0707b9d509","is_new_webhook_url":true,"_plugin_env_BASE_URL":"https://industrial.api.ubidots.com","_plugin_env_tti_main_color":"#0040E5","_plugin_env_tti_secondary_color":"#6C95FF"},"correlation_ids":["as:up:01FGT63M4SGX6BVJPPY77NVR54","gs:conn:01FG16AF2W7NZQAPBX4JNKBK59","gs:up:host:01FG16ANAWE2ZRQKCKNNBTHJV8","gs:uplink:01FGT63KX1RDGXC9ECXXR2GP5E","ns:uplink:01FGT63KX4N5JGFFXKBW53FN40","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FGT63KX4S0JMKK3F1WZZ5K44","rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FGT63M4RPDV47G8A06DARD0C"],"end_device_ids":{"application_ids":{"application_id":"windorahlse01"},"dev_addr":"REMOVED","dev_eui":"REMOVED","device_id":"lse012412-1","join_eui":"A000000000000101"},"received_at":"2021-09-30T01:46:38.106745571Z","uplink_message":{"consumed_airtime":"0.061696s","decoded_payload":{"Bat":3.322,"TempC_DS18B20":"0.00","conduct_SOIL":2,"temp_SOIL":"13.47","water_SOIL":"4.57"},"f_cnt":10560,"f_port":2,"frm_payload":"DPoAAAHJBUMAAgA=","network_ids":{"cluster_id":"ttn-au1","net_id":"000013","tenant_id":"ttn"},"received_at":"2021-09-30T01:46:37.860135992Z","rx_metadata":[{"channel_index":4,"channel_rssi":-44,"gateway_ids":{"eui":"60C5A8FFFE76F85F","gateway_id":"windorah001"},"location":{"altitude":365,"latitude":-32.870143,"longitude":117.578888,"source":"SOURCE_REGISTRY"},"rssi":-44,"snr":9.5,"time":"2021-09-30T01:46:37.805811Z","timestamp":2148355787,"uplink_token":"ChkKFwoLd2luZG9yYWgwMDESCGDFqP/+dvhfEMudtYAIGgwI/a3UigYQo677mAMg+JHvn8P1vgE="}],"session_key_id":"AXtsrkxsAVkGbGYrTUhtCQ==","settings":{"coding_rate":"4/5","data_rate":{"lora":{"bandwidth":125000,"spreading_factor":7}},"data_rate_index":5,"frequency":"917600000","time":"2021-09-30T01:46:37.805811Z","timestamp":2148355787},"version_ids":{"band_id":"AU_915_928","brand_id":"dragino","firmware_version":"1.3","hardware_version":"_unknown_hw_version_","model_id":"lse01"}}}

and returned JSON

{
  "success": true,
  "message": {
    "results": [
      {
        "f_cnt": [
          {
            "status_code": 201
          }
        ],
        "f_port": [
          {
            "status_code": 201
          }
        ],
        "rssi-windorah001": [
          {
            "status_code": 201
          }
        ],
        "snr-windorah001": [
          {
            "status_code": 201
          }
        ]
      }
    ]
  }
}

The below link is the device payload decoder im using in TTS - here
Note i have removed any measurement unit text from each variable decoded.

I realise this is probably a lack of knowledge of JS, and have read the Ubidots Docs regarding this, but cannot get it happening! Any help is appreciated.

thanks

Hello, windorah

I’m Santiago from Ubidots, we hope you’re doing great,

We have verified the plugin’s decoding function, all it was needed was to comment out the following lines:

let bytes =  Buffer.from(args['uplink_message']['frm_payload'], 'base64');
var decoded_payload = decodeUplink(bytes)['data'];

Please check on your device if the variables were created and updated with the decoded data.

Regards.

Hi Santiago,

I can confirm the payload from TTS is now coming through. Perhaps a few extra lines of comments indicating to comment out some lines in the standard Ubidots decoder could help this situation.

Many thanks

Rowan

2 Likes