Skip to content

Webhooks

WeSpeakEnglish edited this page Sep 25, 2026 · 1 revision

Webhooks

polluSensWeb can send parsed readings to any HTTP endpoint — your own server, Home Assistant, Node-RED, InfluxDB gateways, sensor.community-style APIs, or a test service like webhook.site.

Enable

  1. Tick Enable Webhook Sending in the Webhook card.
  2. Enter the Webhook URL.
  3. Choose the HTTP method: GET, POST or PUT (GET sends no body).
  4. Set the interval in seconds. 0 = send on every valid packet.
  5. Click Test Send Webhook Now to check it.

ℹ️ How requests are routed: browsers block most cross-origin requests, so webhooks are sent through a CORS proxy (PROXY_URL in pollusensweb.js, by default https://pollutants.eu/proxy/proxy.php). Your readings and headers pass through that proxy. If that matters to you, run your own proxy — see Self-Hosting and Local Use. Rate limiting is active; a 429 error means you should increase the interval.

Placeholders

The same template engine processes headers and body.

Placeholder Replaced with
{{ts}} Current timestamp (ISO 8601)
{{field:<signal name>}} Value of one signal
{{#fields}} … {{/fields}} Loop over all signals (body only), using {{key}} and {{value}} inside

The signal name is the name shown in the chart signal list without the unit. For PM2.5 x0.4 calibrated [μg/m³], use {{field:PM2.5 x0.4 calibrated}}.

Placeholders for fields that don't exist are replaced with null.

Headers

Add headers with + Add header.

Key Value Result
X-PM25 {{field:PM2.5}} X-PM25: 12.3
X-TIME {{ts}} X-TIME: 2025-12-09T12:34:56Z
Content-Type application/json Content-Type: application/json

Body examples

All signals

{
  "software_version": "polluSensWeb 1.0",
  "timestamp": "{{ts}}",
  "sensordatavalues": [
  {{#fields}}
    { "value_type": "{{key}}", "value": "{{value}}" }
  {{/fields}}
  ]
}

For a packet with PM1: 1.5, PM2.5: 12.3, PM10: 20.1 this becomes:

{
  "software_version": "polluSensWeb 1.0",
  "timestamp": "2025-12-09T12:34:56.789Z",
  "sensordatavalues": [
    { "value_type": "PM1", "value": 1.5 },
    { "value_type": "PM2.5", "value": 12.3 },
    { "value_type": "PM10", "value": 20.1 }
  ]
}

Selected signals

{
  "pm25": {{field:PM2.5}},
  "pm10": {{field:PM10}},
  "time": "{{ts}}"
}

Resulting request:

POST https://webhook.site/xxxxxx
X-PM25: 12.3
X-Time: 2025-12-09T12:34:56Z
Content-Type: application/json

{ "pm25": 12.3, "pm10": 20.1, "time": "2025-12-09T12:34:56Z" }

Tips

  • Test with https://webhook.site first to see exactly what is sent.
  • Avoid interval 0 with fast sensors unless your endpoint can handle one request per packet.
  • Webhooks are the only feature that needs a network connection after the page has loaded.

Clone this wiki locally