From 24270d76122e22f4b1ed191e67e66faa3fd9e47b Mon Sep 17 00:00:00 2001 From: Jason <37859597+zachowj@users.noreply.github.com> Date: Sun, 7 Apr 2024 14:25:25 -0700 Subject: [PATCH] fix(webhook): Fix deprecated has.components.webhook Fixes #258 --- custom_components/nodered/websocket.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/custom_components/nodered/websocket.py b/custom_components/nodered/websocket.py index 073a22d..abd7f35 100644 --- a/custom_components/nodered/websocket.py +++ b/custom_components/nodered/websocket.py @@ -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, @@ -55,6 +59,7 @@ from homeassistant.helpers.typing import HomeAssistantType import voluptuous as vol + from .const import ( CONF_ATTRIBUTES, CONF_COMPONENT, @@ -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 @@ -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,