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