Webhook data missing quotes

When receiving Cayenne LPP formatted data, some quotes are missing:

json:
    - 'n': payload
      vs: fa8807ef4000c3500003e8026700eb03686e047327240502014006020000
    - 'n': LrrRSSI
      vs: '-109.0'

Compared with result of webhook.site:

[
  {
    "n": "payload",
    "vs": "fa8807ef4000c3500003e8026700eb03686e047327240502014006020000"
  },
  {
    "n": "LrrRSSI",
    "vs": "-109.0"
  },

This result in error messages when trying to use the data (it appears as a very long integer)

I tested it in the Template editor with the same result:

{% set my_test_json = {
  "vs": fa8807ef4000c3500003e8026700eb03686e047327240502014006020000
} %}

The value is {{ my_test_json.vs }} 

UndefinedError: 'fa8807ef4000c3500003e8026700eb03686e047327240502014006020000' is undefined

Adding the missing quotes get the expected result:

{% set my_test_json = {
  "vs": "fa8807ef4000c3500003e8026700eb03686e047327240502014006020000"
} %}

The value is {{ my_test_json.vs }} 

The value is fa8807ef4000c3500003e8026700eb03686e047327240502014006020000

What I’m doing wrong / how to get the quotes back?

Not sure what you’re asking.
What you show as “json” from “Cayenne LPP” is just not valid json.

How do you extract that value in your HA configuration?
What has “webhook.site” have to do with this?

Hi Chris,

The Cayenne LPP data is packed in a JSON message format by the telecom provider (KPN) De data is in the “vs” part. Most of the other data (such as Port, SubBand, Channel) i left out of the example.

“Webhook.site” is a testsite used to test the webhook data. ~It shows all kind of info.
There I see a correct JSON package from KPN.

My HA webhook config is:

platform: webhook
webhook_id: '-xxxxxxxxxxxxxxxxxxxxxxxx'
variables:
  payload: '{{trigger.json}}'

I have another webhook already in ‘production’ but this only has floats as a content. Without problems.

I don’t get it.
Who is sending the webhook with which data?

I (think I) understand you’re testing with “webhook.site” and it works, because your json is correct?
Or are you redirecting whatever is sending the webhook to “webhook.site”, in which case I don’t understand the question as the quotes are there and the json correct :thinking:

Bottom-line: where is the “json:” part (which is not proper json) in your OP coming from?

Hi Chris,

I managed yo get it working as supposed. I made an error using the Template editor.
The correct example is:

{% set my_test_json = 
  [
      {"bn":"urn:dev:DEVEUI:xxxxxxxxxxxxx:","bt":1.682457593E9},
      {"n":"payload","vs":"018807ef4000c3500003e8026700eb03686e047327240502014006020000"},
      {"n":"port","v":10.0},
      {"n":"FCntUp","v":4.0},
      {"n":"FCntDn","v":1.0},
      {"n":"LrrRSSI","vs":"-109.0"},
      {"n":"LrrSNR","vs":"0.0"},
      {"n":"LrrESP","vs":"-112.0103"},
      {"n":"DevLrrCnt","v":5.0},
      {"n":"SpFact","v":7.0},
      {"n":"SubBand","vs":"G2"},
      {"n":"Channel","vs":"LC6"},
      {"n":"ADRbit","v":0.0},
      {"n":"TIME_ORIGIN","vs":"THINGSENGINE"}
  ]
%}

payload: {{my_test_json[1].vs}} 
LrrRSSI: {{my_test_json[5].vs}} 
SubBand: {{my_test_json[10].vs}} 
Channel: {{my_test_json[11].vs}} 

Which gives me the following result:

payload: 018807ef4000c3500003e8026700eb03686e047327240502014006020000 
LrrRSSI: -109.0 
SubBand: G2 
Channel: LC6

I’ll test further with all the parts involved:

  • Arduino application sending Cayenne LoRa payload to
  • KPN telecom provider, sending Jason with the Cayenne payload to
  • Home Assistant interpreting the data

Chris, thanks for your help.