mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Avoid import homeassistant.const as a module (#85991)
This commit is contained in:
parent
9f0bed0f0c
commit
9205020fa4
@ -26,7 +26,6 @@ from aioesphomeapi import (
|
||||
from awesomeversion import AwesomeVersion
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import const
|
||||
from homeassistant.components import tag, zeroconf
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
@ -36,6 +35,7 @@ from homeassistant.const import (
|
||||
CONF_PASSWORD,
|
||||
CONF_PORT,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
__version__ as ha_version,
|
||||
)
|
||||
from homeassistant.core import Event, HomeAssistant, ServiceCall, State, callback
|
||||
from homeassistant.exceptions import TemplateError
|
||||
@ -122,7 +122,7 @@ async def async_setup_entry( # noqa: C901
|
||||
host,
|
||||
port,
|
||||
password,
|
||||
client_info=f"Home Assistant {const.__version__}",
|
||||
client_info=f"Home Assistant {ha_version}",
|
||||
zeroconf_instance=zeroconf_instance,
|
||||
noise_psk=noise_psk,
|
||||
)
|
||||
|
@ -9,7 +9,7 @@ import subprocess
|
||||
from icmplib import async_multiping
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import const, util
|
||||
from homeassistant import util
|
||||
from homeassistant.components.device_tracker import (
|
||||
CONF_SCAN_INTERVAL,
|
||||
PLATFORM_SCHEMA as BASE_PLATFORM_SCHEMA,
|
||||
@ -17,6 +17,7 @@ from homeassistant.components.device_tracker import (
|
||||
AsyncSeeCallback,
|
||||
SourceType,
|
||||
)
|
||||
from homeassistant.const import CONF_HOSTS
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.event import async_track_point_in_utc_time
|
||||
@ -34,7 +35,7 @@ CONCURRENT_PING_LIMIT = 6
|
||||
|
||||
PLATFORM_SCHEMA = BASE_PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(const.CONF_HOSTS): {cv.slug: cv.string},
|
||||
vol.Required(CONF_HOSTS): {cv.slug: cv.string},
|
||||
vol.Optional(CONF_PING_COUNT, default=1): cv.positive_int,
|
||||
}
|
||||
)
|
||||
@ -87,7 +88,7 @@ async def async_setup_scanner(
|
||||
"""Set up the Host objects and return the update function."""
|
||||
|
||||
privileged = hass.data[DOMAIN][PING_PRIVS]
|
||||
ip_to_dev_id = {ip: dev_id for (dev_id, ip) in config[const.CONF_HOSTS].items()}
|
||||
ip_to_dev_id = {ip: dev_id for (dev_id, ip) in config[CONF_HOSTS].items()}
|
||||
interval = config.get(
|
||||
CONF_SCAN_INTERVAL,
|
||||
timedelta(seconds=len(ip_to_dev_id) * config[CONF_PING_COUNT]) + SCAN_INTERVAL,
|
||||
@ -101,7 +102,7 @@ async def async_setup_scanner(
|
||||
if privileged is None:
|
||||
hosts = [
|
||||
HostSubProcess(ip, dev_id, hass, config, privileged)
|
||||
for (dev_id, ip) in config[const.CONF_HOSTS].items()
|
||||
for (dev_id, ip) in config[CONF_HOSTS].items()
|
||||
]
|
||||
|
||||
async def async_update(now):
|
||||
|
@ -5,7 +5,8 @@ from oauthlib.oauth2 import AccessDeniedError, MissingTokenError
|
||||
from ring_doorbell import Auth
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, const, core, exceptions
|
||||
from homeassistant import config_entries, core, exceptions
|
||||
from homeassistant.const import __version__ as ha_version
|
||||
|
||||
from . import DOMAIN
|
||||
|
||||
@ -15,7 +16,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||
async def validate_input(hass: core.HomeAssistant, data):
|
||||
"""Validate the user input allows us to connect."""
|
||||
|
||||
auth = Auth(f"HomeAssistant/{const.__version__}")
|
||||
auth = Auth(f"HomeAssistant/{ha_version}")
|
||||
|
||||
try:
|
||||
token = await hass.async_add_executor_job(
|
||||
|
@ -7,8 +7,8 @@ import voluptuous as vol
|
||||
from zhaquirks import setup as setup_quirks
|
||||
from zigpy.config import CONF_DEVICE, CONF_DEVICE_PATH
|
||||
|
||||
from homeassistant import const as ha_const
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_TYPE, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
@ -39,7 +39,7 @@ from .core.const import (
|
||||
)
|
||||
from .core.discovery import GROUP_PROBE
|
||||
|
||||
DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema({vol.Optional(ha_const.CONF_TYPE): cv.string})
|
||||
DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema({vol.Optional(CONF_TYPE): cv.string})
|
||||
ZHA_CONFIG_SCHEMA = {
|
||||
vol.Optional(CONF_BAUDRATE): cv.positive_int,
|
||||
vol.Optional(CONF_DATABASE): cv.string,
|
||||
@ -128,7 +128,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
||||
await zha_gateway.shutdown()
|
||||
|
||||
zha_data[DATA_ZHA_SHUTDOWN_TASK] = hass.bus.async_listen_once(
|
||||
ha_const.EVENT_HOMEASSISTANT_STOP, async_zha_shutdown
|
||||
EVENT_HOMEASSISTANT_STOP, async_zha_shutdown
|
||||
)
|
||||
|
||||
await zha_gateway.async_initialize_devices_and_entities()
|
||||
|
Loading…
x
Reference in New Issue
Block a user