Webhook Template issue with Pushover

I’ve followed this guide - Webhooks Tutorial - Push notifications with Pushover

{
  "token": "",
  "user": "",
  "title": "Temperature Update",
  "message": "The temperature is currently {{{temperature}}}."
}


However my data temperature is blank in my message received.

I see it being published in console, but it’s not showing up in the Pushover message

Have you inserted the token and key correctly?
Can you post the console screenshot too?

I believe so. Pushover is sending messages every 5 minutes based on the Particle publish, but the temperature is not coming through.

Here’s a screenshot of the console.

And here’s the full webhook:

{
    "event": "temperature",
    "deviceID": "deviceID",
    "url": "https://api.pushover.net/1/messages.json",
    "requestType": "POST",
    "noDefaults": true,
    "rejectUnauthorized": true,
    "form": {
        "token": "token",
        "user": "userid",
        "title": "Temperature Update",
        "message": "The temperature is currently {{{temperature}}}."
    }
}

When I try to send the Pushover message as just “{{{temperature}}}”, it fails to send a push notification with this error:

{"message":"cannot be blank","errors":["message cannot be blank"],"status":0

It seems that Pushover is not receiving Particle’s information of ‘temperature’.

Your events don’t hold a {{{temperature}}} field.
You can only use that when your data entry in the event is a JSON string in itself containing a key/value pair with the key "temperature".
With an event like yours you’d use the entire data entry via {{{PARTICLE_EVENT_VALUE}}}

However, instead of sending three events in the same second, I’d wrap all three of your readings into a single JSON even.

So it would look something like this?

{
    "event": "temperature",
    "deviceID": "ID",
    "url": "https://api.pushover.net/1/messages.json",
    "requestType": "POST",
    "noDefaults": true,
    "rejectUnauthorized": true,
    "json": {
        "name": "{{PARTICLE_EVENT_NAME}}",
        "value": "{{PARTICLE_EVENT_VALUE}}"
    }
}

Sorry, I’m new and trying to dive into this head first but having trouble understanding the syntax of the JSON data and how it can pull the Particle events.

That depends on the format your target server requires.
I’m not familiar with the requirements of Pushover, but for your original webhook you’d change this

"message": "The temperature is currently {{{temperature}}}."

to this

"message": "The temperature is currently {{{PARTICLE_EVENT_VALUE}}}."

And in order to unify your three events (Particle.publish() calls) into a single JSON event, you’d do something like this

  char data[96];
  snprintf(data, sizeof(data)
          , "{\"temperature\": %.2f, \"batState\": %.1f, \"batSoC\": %.1f}"
          , temp
          , batState
          , batSoC
          );
  Particle.publish("temperature", data, PRIVATE);

(assuming variables temp, batState & batSoC are all float or double)

This way you could keep your original webhook definition with {{{temperature}}} (the key inside the data entry, not the event name - hence I’d rename the event to something more general like pushover and trigger the webhook on that).

To test what’s actually being received on the remote side, you could first direct that webhook to some service like requestbin.com which lets you see what your target server will see. Once that satisfies the demands you can finally target your original server.

The {{{PARTICLE_EVENT_VALUE}}} edit worked for me! Thank you.

If I’m understanding you correctly, a JSON event will allow me to have more data and do more with it?

Yes, you can have multiple data points in a single event - what you want to do with that is up to you :wink: