I could successfully create a trigger-based sensor where the trigger is a webhook. Here’s how it looks like (almost the same as the documentation example).
configuration.yaml:
# ...
template: !include templates.yaml
# ...
templates.yaml:
triggers:
- trigger: webhook
webhook_id: my-super-secret-webhook-1
sensor:
- name: "Webhook Temperature 1"
unique_id: "webhook_temperature_1"
state: "{{ trigger.json.temperature }}"
unit_of_measurement: °C
That works, but now I’d like to register a different webhook which would set the value of a different sensor. I’d guess it would be something like this:
triggers:
- trigger: webhook
webhook_id: my-super-secret-webhook-1
- trigger: webhook
webhook_id: my-super-secret-webhook-2
sensor:
- name: "Webhook Temperature 1"
unique_id: "webhook_temperature_1"
state: "{{ trigger.json.temperature }}"
unit_of_measurement: °C
- name: "Webhook Temperature 2"
unique_id: "webhook_temperature_2"
state: "{{ trigger.json.temperature }}"
unit_of_measurement: °C
but then clearly I’ll need a way to identify those webhooks, so first sensor would set its state using JSON data from the first webhook, and second sensor would use the data from second webhook.
At the moment if I send the following request:
$ curl -X POST \
-H "Content-Type: application/json" \
-d '{"temperature":5}' \
https://MY-HOME-ASSISTANT.HOST:8123/api/webhook/my-super-secret-webhook-1 # or my-super-secret-webhook-2
then both sensors get updated:
And I could not figure that out - how can I use not just trigger.json.temperature but a different TRIGGER-ID-OR-SOMETHING.json.temperature for every sensor?
I reckon, I could use one common webhook for setting the states of all of my theoretical 9000+ sensors, by making it so that instead of a “direct” temperature value I’d have a dictionary, and every sensor would look for its own key and keep the previous state if JSON data does not contain that key. So that’s one workaround.
Alternatively, I’d be fine with doing this via automations instead of trigger-based sensors, as different automations can be triggered by different webhooks, which is great, but for the love of god I couldn’t find how can one set the state of a template sensor from an automation.
The Home Assistant version that I am using at the moment is 2025.5.3.
