Import persistent notification part 1 (#63898)
This commit is contained in:
parent
65deaa1daf
commit
8d6e2ae354
5 changed files with 25 additions and 15 deletions
|
@ -16,8 +16,12 @@ import voluptuous as vol
|
|||
import yarl
|
||||
|
||||
from . import config as conf_util, config_entries, core, loader
|
||||
from .components import http
|
||||
from .const import REQUIRED_NEXT_PYTHON_HA_RELEASE, REQUIRED_NEXT_PYTHON_VER
|
||||
from .components import http, persistent_notification
|
||||
from .const import (
|
||||
REQUIRED_NEXT_PYTHON_HA_RELEASE,
|
||||
REQUIRED_NEXT_PYTHON_VER,
|
||||
SIGNAL_BOOTSTRAP_INTEGRATONS,
|
||||
)
|
||||
from .exceptions import HomeAssistantError
|
||||
from .helpers import area_registry, device_registry, entity_registry
|
||||
from .helpers.dispatcher import async_dispatcher_send
|
||||
|
@ -46,7 +50,6 @@ DATA_LOGGING = "logging"
|
|||
|
||||
LOG_SLOW_STARTUP_INTERVAL = 60
|
||||
SLOW_STARTUP_CHECK_INTERVAL = 1
|
||||
SIGNAL_BOOTSTRAP_INTEGRATONS = "bootstrap_integrations"
|
||||
|
||||
STAGE_1_TIMEOUT = 120
|
||||
STAGE_2_TIMEOUT = 300
|
||||
|
@ -252,8 +255,8 @@ async def async_from_config_dict(
|
|||
f"{'.'.join(str(x) for x in REQUIRED_NEXT_PYTHON_VER[:2])}."
|
||||
)
|
||||
_LOGGER.warning(msg)
|
||||
hass.components.persistent_notification.async_create(
|
||||
msg, "Python version", "python_version"
|
||||
persistent_notification.async_create(
|
||||
hass, msg, "Python version", "python_version"
|
||||
)
|
||||
|
||||
return hass
|
||||
|
|
|
@ -9,8 +9,12 @@ from typing import Any
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.auth.permissions.const import CAT_ENTITIES, POLICY_READ
|
||||
from homeassistant.bootstrap import SIGNAL_BOOTSTRAP_INTEGRATONS
|
||||
from homeassistant.const import EVENT_STATE_CHANGED, EVENT_TIME_CHANGED, MATCH_ALL
|
||||
from homeassistant.const import (
|
||||
EVENT_STATE_CHANGED,
|
||||
EVENT_TIME_CHANGED,
|
||||
MATCH_ALL,
|
||||
SIGNAL_BOOTSTRAP_INTEGRATONS,
|
||||
)
|
||||
from homeassistant.core import Context, Event, HomeAssistant, callback
|
||||
from homeassistant.exceptions import (
|
||||
HomeAssistantError,
|
||||
|
|
|
@ -14,6 +14,7 @@ import weakref
|
|||
|
||||
from . import data_entry_flow, loader
|
||||
from .backports.enum import StrEnum
|
||||
from .components import persistent_notification
|
||||
from .const import EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STOP, Platform
|
||||
from .core import CALLBACK_TYPE, CoreState, Event, HomeAssistant, callback
|
||||
from .exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady, HomeAssistantError
|
||||
|
@ -657,9 +658,7 @@ class ConfigEntriesFlowManager(data_entry_flow.FlowManager):
|
|||
|
||||
# Remove notification if no other discovery config entries in progress
|
||||
if not self._async_has_other_discovery_flows(flow.flow_id):
|
||||
self.hass.components.persistent_notification.async_dismiss(
|
||||
DISCOVERY_NOTIFICATION_ID
|
||||
)
|
||||
persistent_notification.async_dismiss(self.hass, DISCOVERY_NOTIFICATION_ID)
|
||||
|
||||
if result["type"] != data_entry_flow.RESULT_TYPE_CREATE_ENTRY:
|
||||
return result
|
||||
|
@ -757,7 +756,8 @@ class ConfigEntriesFlowManager(data_entry_flow.FlowManager):
|
|||
# Create notification.
|
||||
if source in DISCOVERY_SOURCES:
|
||||
self.hass.bus.async_fire(EVENT_FLOW_DISCOVERED)
|
||||
self.hass.components.persistent_notification.async_create(
|
||||
persistent_notification.async_create(
|
||||
self.hass,
|
||||
title="New devices discovered",
|
||||
message=(
|
||||
"We have discovered new devices on your network. "
|
||||
|
@ -766,7 +766,8 @@ class ConfigEntriesFlowManager(data_entry_flow.FlowManager):
|
|||
notification_id=DISCOVERY_NOTIFICATION_ID,
|
||||
)
|
||||
elif source == SOURCE_REAUTH:
|
||||
self.hass.components.persistent_notification.async_create(
|
||||
persistent_notification.async_create(
|
||||
self.hass,
|
||||
title="Integration requires reconfiguration",
|
||||
message=(
|
||||
"At least one of your integrations requires reconfiguration to "
|
||||
|
@ -1382,8 +1383,8 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
|||
)
|
||||
if ent["flow_id"] != self.flow_id
|
||||
):
|
||||
self.hass.components.persistent_notification.async_dismiss(
|
||||
RECONFIGURE_NOTIFICATION_ID
|
||||
persistent_notification.async_dismiss(
|
||||
self.hass, RECONFIGURE_NOTIFICATION_ID
|
||||
)
|
||||
|
||||
return super().async_abort(
|
||||
|
|
|
@ -765,3 +765,5 @@ CAST_APP_ID_HOMEASSISTANT_LOVELACE: Final = "A078F6B0"
|
|||
|
||||
# User used by Supervisor
|
||||
HASSIO_USER_NAME = "Supervisor"
|
||||
|
||||
SIGNAL_BOOTSTRAP_INTEGRATONS = "bootstrap_integrations"
|
||||
|
|
|
@ -8,8 +8,8 @@ from unittest.mock import Mock, patch
|
|||
import pytest
|
||||
|
||||
from homeassistant import bootstrap, core, runner
|
||||
from homeassistant.bootstrap import SIGNAL_BOOTSTRAP_INTEGRATONS
|
||||
import homeassistant.config as config_util
|
||||
from homeassistant.const import SIGNAL_BOOTSTRAP_INTEGRATONS
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue