custom-components / pyscript

Pyscript adds rich Python scripting to HASS
Apache License 2.0
873 stars 46 forks source link

Webhook Trigger #592

Closed contagon closed 3 months ago

contagon commented 6 months ago

This PR closes #353 and adds a new webhook trigger defined as,

@webhook_trigger(webhook_id, str_expr=None, local_only=True, methods={"POST", "PUT"}, kwargs=None)
def foo(payload):
    pass

When looking into this, I was hoping that webhooks trigger events, but they unfortunately don't leading to this solution. I've been using this for about a week and it seems to be working stably. I've added a few things to the tests to make sure things at least run. I'm not sure how to actually call a webhook in a test, but happy to do it if there is a way.

I also added some documentation that hopefully covers everything.

Let me know if any changes or tweaks are needed!

craigbarratt commented 3 months ago

Awesome - thanks for the PR. Sorry about the delay in following up.