mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Add Warning in the issue registry if a HTTPS webhook is used for Nuki (#90718)
feat(nuki): create issue when https webhook URL was created
This commit is contained in:
parent
0d6177dbdb
commit
c43dc37713
@ -26,7 +26,11 @@ from homeassistant.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.core import Event, HomeAssistant
|
from homeassistant.core import Event, HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import (
|
||||||
|
device_registry as dr,
|
||||||
|
entity_registry as er,
|
||||||
|
issue_registry as ir,
|
||||||
|
)
|
||||||
from homeassistant.helpers.network import get_url
|
from homeassistant.helpers.network import get_url
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
@ -152,17 +156,36 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
hass, allow_cloud=False, allow_external=False, allow_ip=True, require_ssl=False
|
hass, allow_cloud=False, allow_external=False, allow_ip=True, require_ssl=False
|
||||||
)
|
)
|
||||||
url = f"{hass_url}{webhook_url}"
|
url = f"{hass_url}{webhook_url}"
|
||||||
try:
|
|
||||||
async with async_timeout.timeout(10):
|
if hass_url.startswith("https"):
|
||||||
await hass.async_add_executor_job(
|
ir.async_create_issue(
|
||||||
_register_webhook, bridge, entry.entry_id, url
|
hass,
|
||||||
)
|
DOMAIN,
|
||||||
except InvalidCredentialsException as err:
|
"https_webhook",
|
||||||
webhook.async_unregister(hass, entry.entry_id)
|
is_fixable=False,
|
||||||
raise ConfigEntryNotReady(f"Invalid credentials for Bridge: {err}") from err
|
severity=ir.IssueSeverity.WARNING,
|
||||||
except RequestException as err:
|
translation_key="https_webhook",
|
||||||
webhook.async_unregister(hass, entry.entry_id)
|
translation_placeholders={
|
||||||
raise ConfigEntryNotReady(f"Error communicating with Bridge: {err}") from err
|
"base_url": hass_url,
|
||||||
|
"network_link": "https://my.home-assistant.io/redirect/network/",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
ir.async_delete_issue(hass, DOMAIN, "https_webhook")
|
||||||
|
|
||||||
|
try:
|
||||||
|
async with async_timeout.timeout(10):
|
||||||
|
await hass.async_add_executor_job(
|
||||||
|
_register_webhook, bridge, entry.entry_id, url
|
||||||
|
)
|
||||||
|
except InvalidCredentialsException as err:
|
||||||
|
webhook.async_unregister(hass, entry.entry_id)
|
||||||
|
raise ConfigEntryNotReady(f"Invalid credentials for Bridge: {err}") from err
|
||||||
|
except RequestException as err:
|
||||||
|
webhook.async_unregister(hass, entry.entry_id)
|
||||||
|
raise ConfigEntryNotReady(
|
||||||
|
f"Error communicating with Bridge: {err}"
|
||||||
|
) from err
|
||||||
|
|
||||||
async def _stop_nuki(_: Event):
|
async def _stop_nuki(_: Event):
|
||||||
"""Stop and remove the Nuki webhook."""
|
"""Stop and remove the Nuki webhook."""
|
||||||
|
@ -25,5 +25,11 @@
|
|||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
||||||
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
|
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"issues": {
|
||||||
|
"https_webhook": {
|
||||||
|
"title": "Nuki webhook URL uses HTTPS (SSL)",
|
||||||
|
"description": "The Nuki bridge can not push events to an HTTPS address (SSL), please configure a (local) HTTP address under \"Home Assistant URL\" in the [network settings]({network_link}). The current (local) address is: `{base_url}`, a valid address could, for example, be `http://192.168.1.10:8123` where `192.168.1.10` is the IP of the Home Assistant device"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user