Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove empty "object" variable from payload.js #89

Merged
merged 2 commits into from
Oct 24, 2024

Conversation

Freddyminu
Copy link
Collaborator

@Freddyminu Freddyminu commented Oct 24, 2024

Decoder Description

Adding removal of the empty "object" key. An empty object key is generated by the toTagoFormat function whenever chirpstack sends a multi leveled json of decoded data from their CODEC.

Added the removal of the object key if its value is empty since this causes connectors to fail.

Type of change

  • Adding a new Decoder of Connector
  • Adding a new Decoder of Network
  • Update or fixing an issue in existing Decoder

Decoder Information and Payload to test and review

  • Documentation of the hardware or protocol:
  • Payload of example the test the decoder:

Checklist for Adding a New Decoder

  • Created a new folder under ./decoders/network/ or ./decoders/connector/ with the name of your decoder.
  • Added a network.jsonc or connector.jsonc file that follows the structure defined in ./schema/.
  • Created version folders and added manifest.jsonc files for each version.
  • Followed the folder structure guidelines for manufacturer and sensor/device model.
  • The code has unit test and it's in TypeScript.

Additional Notes

Please add any other information that you think is important.

@Freddyminu Freddyminu self-assigned this Oct 24, 2024
@vitorfdl
Copy link
Member

Can you provide the JSON of the Chirpstack payload you're proposing to fix with this PR ?

@Freddyminu
Copy link
Collaborator Author

Freddyminu commented Oct 24, 2024

Can you provide the JSON of the Chirpstack payload you're proposing to fix with this PR ?

Rawpayload: [
  {
    "variable": "chirpstack_payload",
    "value": "{\"devAddr\":\"007ca714\",\"fCnt\":118495,\"fPort\":7,\"deduplicationId\":\"64f102a3-bbf6-4154-a158-67192f2c4f23\",\"time\":\"2024-10-21T22:18:02.974383993+00:00\",\"deviceInfo\":{\"tenantId\":\"b8027e8b-ce9b-4b4a-9967-01ebe0b95af7\",\"tenantName\":\"Citykinect\",\"applicationId\":\"5e543e8e-ae8a-4f75-964e-7e9ffe017cc8\",\"applicationName\":\"Dragino\",\"deviceProfileId\":\"f10acc99-ffda-486f-b76c-fe67d0d0a7d8\",\"deviceProfileName\":\"Dragino CS01-LB\",\"deviceName\":\"Dragino Current Sensor - AC Power\",\"devEui\":\"a840418d04592ec9\",\"tags\":{}},\"adr\":true,\"dr\":3,\"confirmed\":false,\"object\":{\"Bat_V\":3.312,\"DATALOG\":\"[5.99],[5.99],[0.00],[0.00],\"} ,\"rxInfo\":[{\"gatewayId\":\"647fdafffe0057e9\",\"uplinkId\":41075,\"time\":\"2024-10-21T22:18:02.974383993+00:00\",\"rssi\":-95,\"snr\":10.5,\"channel\":12,\"location\":{\"latitude\":48.44936,\"longitude\":-123.50419},\"context\":\"qiOKuw==\",\"metadata\":{\"region_config_id\":\"us915_1\",\"region_common_name\":\"US915\"},\"crcStatus\":\"CRC_OK\"}],\"txInfo\":{\"frequency\":904300000,\"modulation\":{\"lora\":{\"bandwidth\":125000,\"spreadingFactor\":7,\"codeRate\":\"CR_4_5\"}}},\"payload\":\"DPACVwJXAAAAAA==\"}",
    "group": "1729549083281"
  }
]

"object":{"Bat_V":3.312,"DATALOG":"[5.99],[5.99],[0.00],[0.00],"}

[LoRaWANChirpStack] payloadparser: [
  {
    "variable": "rx_0_gateway_id",
    "value": "647fdafffe0057e9",
    "serie": 1729549083312
  },
  {
    "variable": "rx_0_time",
    "value": "2024-10-21T22:18:02.974383993+00:00",
    "serie": 1729549083312
  },
  {
    "variable": "rx_0_rssi",
    "value": -95,
    "serie": 1729549083312
  },
  {
    "variable": "rx_0_lorasnr",
    "value": 10.5,
    "serie": 1729549083312
  },
  {
    "variable": "rx_0_channel",
    "value": 12,
    "serie": 1729549083312
  },
  {
    "variable": "rx_0_location",
    "value": "48.44936,-123.50419",
    "location": {
      "lat": 48.44936,
      "lng": -123.50419
    },
    "serie": 1729549083312
  },
  {
    "variable": "rx_0_context",
    "value": "aa238abb",
    "serie": 1729549083312
  },
  {
    "variable": "frequency",
    "value": 904300000,
    "serie": 1729549083312
  },
  {
    "variable": "bandwidth",
    "value": 125000,
    "serie": 1729549083312
  },
  {
    "variable": "spreading_factor",
    "value": 7,
    "serie": 1729549083312
  },
  {
    "variable": "code_rate",
    "value": "CR_4_5",
    "serie": 1729549083312
  },
  {
    "variable": "fCnt",
    "value": 118495,
    "serie": 1729549083312
  },
  {
    "variable": "fPort",
    "value": 7,
    "serie": 1729549083312
  },
  {
    "variable": "deduplicationId",
    "value": "64f102a3-bbf6-4154-a158-67192f2c4f23",
    "serie": 1729549083312
  },
  {
    "variable": "time",
    "value": "2024-10-21T22:18:02.974383993+00:00",
    "serie": 1729549083312
  },
  {
    "variable": "adr",
    "value": true,
    "serie": 1729549083312
  },
  {
    "variable": "dr",
    "value": 3,
    "serie": 1729549083312
  },
  {
    "variable": "confirmed",
    "value": false,
    "serie": 1729549083312
  },
  {
    "variable": "object",
    "serie": 1729549083312
  }, 
  {
    "variable": "payload",
    "value": "0cf00257025700000000",
    "serie": 1729549083312
  },
  {
    "variable": "application_id",
    "value": "5e543e8e-ae8a-4f75-964e-7e9ffe017cc8",
    "serie": 1729549083312
  },
  {
    "variable": "application_name",
    "value": "Dragino",
    "serie": 1729549083312
  },
  {
    "variable": "device_eui",
    "value": "a840418d04592ec9",
    "serie": 1729549083312
  },
  {
    "variable": "dev_addr",
    "value": "007ca714",
    "serie": 1729549083312
  }
]

{
"variable": "object",
"serie": 1729549083312
}

Copy link
Member

@vitorfdl vitorfdl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like object can be sent as customized payload from Chirpstack.

I'd rather prefer to parse the Object parameter with the toTagoFormat,

  if (chirpstack_payload.object) {
    vars_to_tago = vars_to_tago.concat(toTagoFormat(chirpstack_payload.object, serie));
    delete chirpstack_payload.object;
  }

Also, as you're updating this connector, also ensure to update the "serie" to "group"

@Freddyminu Freddyminu requested a review from vitorfdl October 24, 2024 14:05
@FabianoEger FabianoEger merged commit 57e79c9 into main Oct 24, 2024
12 checks passed
@FabianoEger FabianoEger deleted the fix/networks-lorawan-chirpstack branch October 24, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants