I am trying to send a notification with HA about states of my 3d print jobs through a webhook. I host my own Obico server and its able to send webhooks to HA. I can get the webhook notifications, but I cant figure out how to grab the actual text I want out of the JSON to pass through to the notification I am getting on my cell phone with an HA automation.
Hey there. What are you trying to grab? I just set this up and it works great.
Basically in Obico:
Enable the webhook notification
Place the URL for the webhook in HA
Select the events you want
In HA:
Make a new automation with webhook as the condition (that’s how I get the unique URL)
Use condition or if you want to filter multiple use if then in action (just my approach)
In my case I leave condition alone and then in action use and if-then block. You could do multiple. Here is an example of my working code, of course you can do whatever you want with this, not just a notify:
alias: "Webhook: Obico Endpoint"
description: ""
trigger:
- platform: webhook
allowed_methods:
- POST
- PUT
local_only: true
webhook_id: "-1BzZNalr3CeNsOrEd"
condition: []
action:
- service: notify.notify
data:
message: Webhook Val {{ trigger.json.event.type }}
- if:
- condition: template
value_template: "{{ 'PrintStarted' in trigger.json.event.type }}"
then:
- service: notify.notify
data:
message: "Test Notify If print start "
mode: single
In this example you can see my condition is handled in an if-then block and I use the template so basically it checks if the word PrintStarted is the event. You can pull other data too, for example the printer name would be: trigger.json.printer.name
For the other event types Obico can send and the subsequent structure you can take a peak at the notificaciones backend code. Thanks to Obico for being awesome and open source.
Interesting take on it. I wasn’t just looking for a trigger for a notification. I was passing the actual webhook text through to my notification. And in truth, it works now. I’m not sure why it wasn’t working when I posted this issue.
Gotcha. If you just want printer status and states not the actual “detection” data from Obico then you might consider the moonraker plugin directly (if you use moonraker and Klipper).
It’s insanely quick and passes all the metrics even the GCode preview. It handles creation of all the entities and everything. Just drop in the IP. That’s how I do those and have a great dash with everything. There are even templates on here for it. I then just use Obico webhook for the failure alert into HA.