Skip to content

Commit

Permalink
fix(webhook): Fix deprecated has.components.webhook
Browse files Browse the repository at this point in the history
Fixes #258
  • Loading branch information
zachowj committed Apr 7, 2024
1 parent be694f2 commit 24270d7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions custom_components/nodered/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
InvalidDeviceAutomationConfig,
)
from homeassistant.components.device_automation.trigger import TRIGGER_SCHEMA
from homeassistant.components.webhook import SUPPORTED_METHODS
from homeassistant.components.webhook import (
async_register as webhook_async_register,
async_unregister as webhook_async_unregister,
SUPPORTED_METHODS,
)
from homeassistant.components.websocket_api import (
async_register_command,
async_response,
Expand Down Expand Up @@ -55,6 +59,7 @@
from homeassistant.helpers.typing import HomeAssistantType
import voluptuous as vol


from .const import (
CONF_ATTRIBUTES,
CONF_COMPONENT,
Expand Down Expand Up @@ -271,7 +276,7 @@ async def handle_webhook(hass, id, request):
def remove_webhook() -> None:
"""Remove webhook command."""
try:
hass.components.webhook.async_unregister(webhook_id)
webhook_async_unregister(hass, webhook_id)

except ValueError:
pass
Expand All @@ -280,7 +285,8 @@ def remove_webhook() -> None:
connection.send_message(result_message(msg[CONF_ID]))

try:
hass.components.webhook.async_register(
webhook_async_register(
hass,
DOMAIN,
msg[CONF_NAME],
webhook_id,
Expand Down

1 comment on commit 24270d7

@bernardesarthur
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank’s a lot!

Please sign in to comment.