I’ve setup a StatPing which has webhook notification functionality. I can successfully trigger a webhook in HA but finding it hard to use the json from the payload in my messages. Here is the payload and my code:
Payload:
{
"id": "{{.Service.Id}}",
"online": true
}
Automation:
- id: '1593508230036'
alias: Statping Test
description: ''
trigger:
- platform: webhook
webhook_id: ID12345
condition: []
action:
- data_template:
message: '{{ trigger.json.id }} is {{ trigger.json.online}}'
title: Test
service: persistent_notification.create
Error in HA:
Error executing script. Unexpected error for call_service at pos 1: Error rendering data template: UndefinedError: 'dict object' has no attribute 'json'
I’ver followed the templating guide which states the use of trigger.json and using data_template but still get the above error.
Ok so it looks like whatever Statping is sending its not JSON formatted as I’ve tested in Node-Red (thanks to @Villhellm) and the following flow works: