mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Rename HomeAssistantType —> HomeAssistant, integrations s* - t* (#49550)
This commit is contained in:
parent
c4c8c67a03
commit
2e084f260e
@ -1,9 +1,9 @@
|
|||||||
"""Solar-Log integration."""
|
"""Solar-Log integration."""
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Set up a config entry for solarlog."""
|
"""Set up a config entry for solarlog."""
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
hass.config_entries.async_forward_entry_setup(entry, "sensor")
|
hass.config_entries.async_forward_entry_setup(entry, "sensor")
|
||||||
|
@ -7,9 +7,9 @@ import voluptuous as vol
|
|||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
|
|
||||||
from .const import API, DOMAIN, HOST, PORT
|
from .const import API, DOMAIN, HOST, PORT
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ async def async_setup(hass, config):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Set up Soma from a config entry."""
|
"""Set up Soma from a config entry."""
|
||||||
hass.data[DOMAIN] = {}
|
hass.data[DOMAIN] = {}
|
||||||
hass.data[DOMAIN][API] = SomaApi(entry.data[HOST], entry.data[PORT])
|
hass.data[DOMAIN][API] = SomaApi(entry.data[HOST], entry.data[PORT])
|
||||||
@ -58,7 +58,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = all(
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
|
@ -10,14 +10,13 @@ import voluptuous as vol
|
|||||||
from homeassistant.components.somfy import config_flow
|
from homeassistant.components.somfy import config_flow
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, CONF_OPTIMISTIC
|
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, CONF_OPTIMISTIC
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import (
|
||||||
config_entry_oauth2_flow,
|
config_entry_oauth2_flow,
|
||||||
config_validation as cv,
|
config_validation as cv,
|
||||||
device_registry as dr,
|
device_registry as dr,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
DataUpdateCoordinator,
|
DataUpdateCoordinator,
|
||||||
@ -73,7 +72,7 @@ async def async_setup(hass, config):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Set up Somfy from a config entry."""
|
"""Set up Somfy from a config entry."""
|
||||||
# Backwards compat
|
# Backwards compat
|
||||||
if "auth_implementation" not in entry.data:
|
if "auth_implementation" not in entry.data:
|
||||||
@ -142,7 +141,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
hass.data[DOMAIN].pop(API, None)
|
hass.data[DOMAIN].pop(API, None)
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
|
@ -17,10 +17,10 @@ from homeassistant.const import (
|
|||||||
CONF_SSL,
|
CONF_SSL,
|
||||||
CONF_VERIFY_SSL,
|
CONF_VERIFY_SSL,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_IDENTIFIERS,
|
ATTR_IDENTIFIERS,
|
||||||
@ -41,7 +41,7 @@ SCAN_INTERVAL = timedelta(seconds=30)
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up Sonarr from a config entry."""
|
"""Set up Sonarr from a config entry."""
|
||||||
if not entry.options:
|
if not entry.options:
|
||||||
options = {
|
options = {
|
||||||
@ -89,7 +89,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = all(
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
@ -108,7 +108,7 @@ async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> boo
|
|||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
async def _async_update_listener(hass: HomeAssistantType, entry: ConfigEntry) -> None:
|
async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||||
"""Handle options update."""
|
"""Handle options update."""
|
||||||
await hass.config_entries.async_reload(entry.entry_id)
|
await hass.config_entries.async_reload(entry.entry_id)
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ from homeassistant.const import (
|
|||||||
CONF_SSL,
|
CONF_SSL,
|
||||||
CONF_VERIFY_SSL,
|
CONF_VERIFY_SSL,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_BASE_PATH,
|
CONF_BASE_PATH,
|
||||||
@ -35,7 +35,7 @@ from .const import (
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def validate_input(hass: HomeAssistantType, data: dict) -> dict[str, Any]:
|
async def validate_input(hass: HomeAssistant, data: dict) -> dict[str, Any]:
|
||||||
"""Validate the user input allows us to connect.
|
"""Validate the user input allows us to connect.
|
||||||
|
|
||||||
Data has the keys from DATA_SCHEMA with values provided by the user.
|
Data has the keys from DATA_SCHEMA with values provided by the user.
|
||||||
|
@ -10,8 +10,8 @@ from sonarr import Sonarr, SonarrConnectionError, SonarrError
|
|||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import DATA_GIGABYTES
|
from homeassistant.const import DATA_GIGABYTES
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from . import SonarrEntity
|
from . import SonarrEntity
|
||||||
@ -21,7 +21,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
entry: ConfigEntry,
|
entry: ConfigEntry,
|
||||||
async_add_entities: Callable[[list[Entity], bool], None],
|
async_add_entities: Callable[[list[Entity], bool], None],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -5,8 +5,8 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||||
from homeassistant.const import CONF_NAME
|
from homeassistant.const import CONF_NAME
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
|
|
||||||
from .const import CONF_ENDPOINT, DOMAIN
|
from .const import CONF_ENDPOINT, DOMAIN
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistantType, config: OrderedDict) -> bool:
|
async def async_setup(hass: HomeAssistant, config: OrderedDict) -> bool:
|
||||||
"""Set up songpal environment."""
|
"""Set up songpal environment."""
|
||||||
conf = config.get(DOMAIN)
|
conf = config.get(DOMAIN)
|
||||||
if conf is None:
|
if conf is None:
|
||||||
@ -36,7 +36,7 @@ async def async_setup(hass: HomeAssistantType, config: OrderedDict) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up songpal media player."""
|
"""Set up songpal media player."""
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
hass.config_entries.async_forward_entry_setup(entry, "media_player")
|
hass.config_entries.async_forward_entry_setup(entry, "media_player")
|
||||||
@ -44,6 +44,6 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Unload songpal media player."""
|
"""Unload songpal media player."""
|
||||||
return await hass.config_entries.async_forward_entry_unload(entry, "media_player")
|
return await hass.config_entries.async_forward_entry_unload(entry, "media_player")
|
||||||
|
@ -25,13 +25,13 @@ from homeassistant.components.media_player.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_NAME, EVENT_HOMEASSISTANT_STOP, STATE_OFF, STATE_ON
|
from homeassistant.const import CONF_NAME, EVENT_HOMEASSISTANT_STOP, STATE_OFF, STATE_ON
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import PlatformNotReady
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import (
|
||||||
config_validation as cv,
|
config_validation as cv,
|
||||||
device_registry as dr,
|
device_registry as dr,
|
||||||
entity_platform,
|
entity_platform,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
|
|
||||||
from .const import CONF_ENDPOINT, DOMAIN, SET_SOUND_SETTING
|
from .const import CONF_ENDPOINT, DOMAIN, SET_SOUND_SETTING
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ INITIAL_RETRY_DELAY = 10
|
|||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
hass: HomeAssistantType, config: dict, async_add_entities, discovery_info=None
|
hass: HomeAssistant, config: dict, async_add_entities, discovery_info=None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up from legacy configuration file. Obsolete."""
|
"""Set up from legacy configuration file. Obsolete."""
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
@ -62,7 +62,7 @@ async def async_setup_platform(
|
|||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities
|
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up songpal media player."""
|
"""Set up songpal media player."""
|
||||||
name = config_entry.data[CONF_NAME]
|
name = config_entry.data[CONF_NAME]
|
||||||
|
@ -15,9 +15,8 @@ from aiohttp.web_exceptions import (
|
|||||||
import attr
|
import attr
|
||||||
|
|
||||||
from homeassistant.components.http import HomeAssistantView
|
from homeassistant.components.http import HomeAssistantView
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import config_per_platform, discovery
|
from homeassistant.helpers import config_per_platform, discovery
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
from homeassistant.setup import async_prepare_setup_platform
|
from homeassistant.setup import async_prepare_setup_platform
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -35,7 +34,7 @@ from .const import (
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistantType, config):
|
async def async_setup(hass: HomeAssistant, config):
|
||||||
"""Set up STT."""
|
"""Set up STT."""
|
||||||
providers = {}
|
providers = {}
|
||||||
|
|
||||||
@ -104,7 +103,7 @@ class SpeechResult:
|
|||||||
class Provider(ABC):
|
class Provider(ABC):
|
||||||
"""Represent a single STT provider."""
|
"""Represent a single STT provider."""
|
||||||
|
|
||||||
hass: HomeAssistantType | None = None
|
hass: HomeAssistant | None = None
|
||||||
name: str | None = None
|
name: str | None = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -10,12 +10,12 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||||
from homeassistant.const import CONF_DEVICE_ID, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import CONF_DEVICE_ID, EVENT_HOMEASSISTANT_STOP
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.discovery import async_load_platform
|
from homeassistant.helpers.discovery import async_load_platform
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
from homeassistant.helpers.event import async_track_time_interval
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
from homeassistant.helpers.typing import EventType, HomeAssistantType
|
from homeassistant.helpers.typing import EventType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistantType, config: dict) -> bool:
|
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
||||||
"""Set up the switcher component."""
|
"""Set up the switcher component."""
|
||||||
phone_id = config[DOMAIN][CONF_PHONE_ID]
|
phone_id = config[DOMAIN][CONF_PHONE_ID]
|
||||||
device_id = config[DOMAIN][CONF_DEVICE_ID]
|
device_id = config[DOMAIN][CONF_DEVICE_ID]
|
||||||
|
@ -16,9 +16,10 @@ from aioswitcher.devices import SwitcherV2Device
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.switch import ATTR_CURRENT_POWER_W, SwitchEntity
|
from homeassistant.components.switch import ATTR_CURRENT_POWER_W, SwitchEntity
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.typing import HomeAssistantType, ServiceCallType
|
from homeassistant.helpers.typing import ServiceCallType
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
ATTR_AUTO_OFF_SET,
|
ATTR_AUTO_OFF_SET,
|
||||||
@ -53,7 +54,7 @@ SERVICE_TURN_ON_WITH_TIMER_SCHEMA = {
|
|||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
config: dict,
|
config: dict,
|
||||||
async_add_entities: Callable,
|
async_add_entities: Callable,
|
||||||
discovery_info: dict,
|
discovery_info: dict,
|
||||||
|
@ -8,16 +8,16 @@ from pysyncthru import SyncThru
|
|||||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_URL
|
from homeassistant.const import CONF_URL
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers import aiohttp_client, device_registry as dr
|
from homeassistant.helpers import aiohttp_client, device_registry as dr
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up config entry."""
|
"""Set up config entry."""
|
||||||
|
|
||||||
session = aiohttp_client.async_get_clientsession(hass)
|
session = aiohttp_client.async_get_clientsession(hass)
|
||||||
@ -53,7 +53,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Unload the config entry."""
|
"""Unload the config entry."""
|
||||||
await hass.config_entries.async_forward_entry_unload(entry, SENSOR_DOMAIN)
|
await hass.config_entries.async_forward_entry_unload(entry, SENSOR_DOMAIN)
|
||||||
hass.data[DOMAIN].pop(entry.entry_id, None)
|
hass.data[DOMAIN].pop(entry.entry_id, None)
|
||||||
|
@ -36,11 +36,10 @@ from homeassistant.const import (
|
|||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
CONF_VERIFY_SSL,
|
CONF_VERIFY_SSL,
|
||||||
)
|
)
|
||||||
from homeassistant.core import ServiceCall, callback
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers import entity_registry
|
from homeassistant.helpers import entity_registry
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
DataUpdateCoordinator,
|
DataUpdateCoordinator,
|
||||||
@ -119,7 +118,7 @@ async def async_setup(hass, config):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Set up Synology DSM sensors."""
|
"""Set up Synology DSM sensors."""
|
||||||
|
|
||||||
# Migrate old unique_id
|
# Migrate old unique_id
|
||||||
@ -294,7 +293,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload Synology DSM sensors."""
|
"""Unload Synology DSM sensors."""
|
||||||
unload_ok = all(
|
unload_ok = all(
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
@ -314,12 +313,12 @@ async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
|||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
async def _async_update_listener(hass: HomeAssistantType, entry: ConfigEntry):
|
async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Handle options update."""
|
"""Handle options update."""
|
||||||
await hass.config_entries.async_reload(entry.entry_id)
|
await hass.config_entries.async_reload(entry.entry_id)
|
||||||
|
|
||||||
|
|
||||||
async def _async_setup_services(hass: HomeAssistantType):
|
async def _async_setup_services(hass: HomeAssistant):
|
||||||
"""Service handler setup."""
|
"""Service handler setup."""
|
||||||
|
|
||||||
async def service_handler(call: ServiceCall):
|
async def service_handler(call: ServiceCall):
|
||||||
@ -358,7 +357,7 @@ async def _async_setup_services(hass: HomeAssistantType):
|
|||||||
class SynoApi:
|
class SynoApi:
|
||||||
"""Class to interface with Synology DSM API."""
|
"""Class to interface with Synology DSM API."""
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistantType, entry: ConfigEntry):
|
def __init__(self, hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Initialize the API wrapper class."""
|
"""Initialize the API wrapper class."""
|
||||||
self._hass = hass
|
self._hass = hass
|
||||||
self._entry = entry
|
self._entry = entry
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_DISKS
|
from homeassistant.const import CONF_DISKS
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from . import SynologyDSMBaseEntity, SynologyDSMDeviceEntity
|
from . import SynologyDSMBaseEntity, SynologyDSMDeviceEntity
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -18,7 +18,7 @@ from .const import (
|
|||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Synology NAS binary sensor."""
|
"""Set up the Synology NAS binary sensor."""
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ from synology_dsm.exceptions import (
|
|||||||
|
|
||||||
from homeassistant.components.camera import SUPPORT_STREAM, Camera
|
from homeassistant.components.camera import SUPPORT_STREAM, Camera
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
|
|
||||||
from . import SynoApi, SynologyDSMBaseEntity
|
from . import SynoApi, SynologyDSMBaseEntity
|
||||||
@ -30,7 +30,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Synology NAS cameras."""
|
"""Set up the Synology NAS cameras."""
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ from homeassistant.const import (
|
|||||||
PRECISION_TENTHS,
|
PRECISION_TENTHS,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.temperature import display_temp
|
from homeassistant.helpers.temperature import display_temp
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ from .const import (
|
|||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Synology NAS Sensor."""
|
"""Set up the Synology NAS Sensor."""
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ from synology_dsm.api.surveillance_station import SynoSurveillanceStation
|
|||||||
|
|
||||||
from homeassistant.components.switch import ToggleEntity
|
from homeassistant.components.switch import ToggleEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
|
|
||||||
from . import SynoApi, SynologyDSMBaseEntity
|
from . import SynoApi, SynologyDSMBaseEntity
|
||||||
@ -17,7 +17,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Synology NAS switch."""
|
"""Set up the Synology NAS switch."""
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ from homeassistant.exceptions import HomeAssistantError
|
|||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from .const import DOMAIN, TASMOTA_EVENT
|
from .const import DOMAIN, TASMOTA_EVENT
|
||||||
from .discovery import TASMOTA_DISCOVERY_ENTITY_UPDATED, clear_discovery_hash
|
from .discovery import TASMOTA_DISCOVERY_ENTITY_UPDATED, clear_discovery_hash
|
||||||
@ -82,7 +82,7 @@ class Trigger:
|
|||||||
|
|
||||||
device_id: str = attr.ib()
|
device_id: str = attr.ib()
|
||||||
discovery_hash: dict = attr.ib()
|
discovery_hash: dict = attr.ib()
|
||||||
hass: HomeAssistantType = attr.ib()
|
hass: HomeAssistant = attr.ib()
|
||||||
remove_update_signal: Callable[[], None] = attr.ib()
|
remove_update_signal: Callable[[], None] = attr.ib()
|
||||||
subtype: str = attr.ib()
|
subtype: str = attr.ib()
|
||||||
tasmota_trigger: TasmotaTrigger = attr.ib()
|
tasmota_trigger: TasmotaTrigger = attr.ib()
|
||||||
|
@ -12,9 +12,9 @@ from hatasmota.discovery import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
import homeassistant.components.sensor as sensor
|
import homeassistant.components.sensor as sensor
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
from homeassistant.helpers.entity_registry import async_entries_for_device
|
from homeassistant.helpers.entity_registry import async_entries_for_device
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
|
|
||||||
from .const import DOMAIN, PLATFORMS
|
from .const import DOMAIN, PLATFORMS
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ def set_discovery_hash(hass, discovery_hash):
|
|||||||
|
|
||||||
|
|
||||||
async def async_start(
|
async def async_start(
|
||||||
hass: HomeAssistantType, discovery_topic, config_entry, tasmota_mqtt, setup_device
|
hass: HomeAssistant, discovery_topic, config_entry, tasmota_mqtt, setup_device
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Start Tasmota device discovery."""
|
"""Start Tasmota device discovery."""
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ async def async_start(
|
|||||||
hass.data[TASMOTA_DISCOVERY_INSTANCE] = tasmota_discovery
|
hass.data[TASMOTA_DISCOVERY_INSTANCE] = tasmota_discovery
|
||||||
|
|
||||||
|
|
||||||
async def async_stop(hass: HomeAssistantType) -> bool:
|
async def async_stop(hass: HomeAssistant) -> bool:
|
||||||
"""Stop Tasmota device discovery."""
|
"""Stop Tasmota device discovery."""
|
||||||
hass.data.pop(ALREADY_DISCOVERED)
|
hass.data.pop(ALREADY_DISCOVERED)
|
||||||
tasmota_discovery = hass.data.pop(TASMOTA_DISCOVERY_INSTANCE)
|
tasmota_discovery = hass.data.pop(TASMOTA_DISCOVERY_INSTANCE)
|
||||||
|
@ -13,7 +13,7 @@ from homeassistant.const import (
|
|||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
SERVICE_RELOAD,
|
SERVICE_RELOAD,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import collection
|
from homeassistant.helpers import collection
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
@ -21,7 +21,7 @@ from homeassistant.helpers.event import async_track_point_in_utc_time
|
|||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
import homeassistant.helpers.service
|
import homeassistant.helpers.service
|
||||||
from homeassistant.helpers.storage import Store
|
from homeassistant.helpers.storage import Store
|
||||||
from homeassistant.helpers.typing import ConfigType, HomeAssistantType, ServiceCallType
|
from homeassistant.helpers.typing import ConfigType, ServiceCallType
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -100,7 +100,7 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
RELOAD_SERVICE_SCHEMA = vol.Schema({})
|
RELOAD_SERVICE_SCHEMA = vol.Schema({})
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up an input select."""
|
"""Set up an input select."""
|
||||||
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
||||||
id_manager = collection.IDManager()
|
id_manager = collection.IDManager()
|
||||||
|
@ -7,8 +7,7 @@ import logging
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.const import ATTR_ENTITY_ID
|
from homeassistant.const import ATTR_ENTITY_ID
|
||||||
from homeassistant.core import Context, State
|
from homeassistant.core import Context, HomeAssistant, State
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
ATTR_DURATION,
|
ATTR_DURATION,
|
||||||
@ -27,7 +26,7 @@ VALID_STATES = {STATUS_IDLE, STATUS_ACTIVE, STATUS_PAUSED}
|
|||||||
|
|
||||||
|
|
||||||
async def _async_reproduce_state(
|
async def _async_reproduce_state(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
state: State,
|
state: State,
|
||||||
*,
|
*,
|
||||||
context: Context | None = None,
|
context: Context | None = None,
|
||||||
@ -69,7 +68,7 @@ async def _async_reproduce_state(
|
|||||||
|
|
||||||
|
|
||||||
async def async_reproduce_states(
|
async def async_reproduce_states(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
states: Iterable[State],
|
states: Iterable[State],
|
||||||
*,
|
*,
|
||||||
context: Context | None = None,
|
context: Context | None = None,
|
||||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_DEFAULT_ENABLED,
|
ATTR_DEFAULT_ENABLED,
|
||||||
@ -26,7 +26,7 @@ from .models import (
|
|||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up a Toon binary sensor based on a config entry."""
|
"""Set up a Toon binary sensor based on a config entry."""
|
||||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
@ -24,7 +24,7 @@ from homeassistant.components.climate.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .const import DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, DOMAIN
|
from .const import DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, DOMAIN
|
||||||
from .helpers import toon_exception_handler
|
from .helpers import toon_exception_handler
|
||||||
@ -32,7 +32,7 @@ from .models import ToonDisplayDeviceEntity
|
|||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up a Toon binary sensors based on a config entry."""
|
"""Set up a Toon binary sensors based on a config entry."""
|
||||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
@ -10,7 +10,7 @@ from toonapi import (
|
|||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_DEFAULT_ENABLED,
|
ATTR_DEFAULT_ENABLED,
|
||||||
@ -28,7 +28,7 @@ from .models import ToonDisplayDeviceEntity, ToonEntity
|
|||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up a Toon switches based on a config entry."""
|
"""Set up a Toon switches based on a config entry."""
|
||||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
@ -18,7 +18,7 @@ from homeassistant.const import (
|
|||||||
CONF_VERIFY_SSL,
|
CONF_VERIFY_SSL,
|
||||||
CONTENT_TYPE_JSON,
|
CONTENT_TYPE_JSON,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from tests.common import MockConfigEntry, load_fixture
|
from tests.common import MockConfigEntry, load_fixture
|
||||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||||
@ -176,7 +176,7 @@ def mock_connection_server_error(
|
|||||||
|
|
||||||
|
|
||||||
async def setup_integration(
|
async def setup_integration(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
host: str = HOST,
|
host: str = HOST,
|
||||||
port: str = PORT,
|
port: str = PORT,
|
||||||
|
@ -10,12 +10,12 @@ from homeassistant.components.sonarr.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_SOURCE, CONF_VERIFY_SSL
|
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_SOURCE, CONF_VERIFY_SSL
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import (
|
from homeassistant.data_entry_flow import (
|
||||||
RESULT_TYPE_ABORT,
|
RESULT_TYPE_ABORT,
|
||||||
RESULT_TYPE_CREATE_ENTRY,
|
RESULT_TYPE_CREATE_ENTRY,
|
||||||
RESULT_TYPE_FORM,
|
RESULT_TYPE_FORM,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
|
|
||||||
from tests.components.sonarr import (
|
from tests.components.sonarr import (
|
||||||
HOST,
|
HOST,
|
||||||
@ -30,7 +30,7 @@ from tests.components.sonarr import (
|
|||||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||||
|
|
||||||
|
|
||||||
async def test_show_user_form(hass: HomeAssistantType) -> None:
|
async def test_show_user_form(hass: HomeAssistant) -> None:
|
||||||
"""Test that the user set up form is served."""
|
"""Test that the user set up form is served."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -42,7 +42,7 @@ async def test_show_user_form(hass: HomeAssistantType) -> None:
|
|||||||
|
|
||||||
|
|
||||||
async def test_cannot_connect(
|
async def test_cannot_connect(
|
||||||
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we show user form on connection error."""
|
"""Test we show user form on connection error."""
|
||||||
mock_connection_error(aioclient_mock)
|
mock_connection_error(aioclient_mock)
|
||||||
@ -60,7 +60,7 @@ async def test_cannot_connect(
|
|||||||
|
|
||||||
|
|
||||||
async def test_invalid_auth(
|
async def test_invalid_auth(
|
||||||
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we show user form on invalid auth."""
|
"""Test we show user form on invalid auth."""
|
||||||
mock_connection_invalid_auth(aioclient_mock)
|
mock_connection_invalid_auth(aioclient_mock)
|
||||||
@ -78,7 +78,7 @@ async def test_invalid_auth(
|
|||||||
|
|
||||||
|
|
||||||
async def test_unknown_error(
|
async def test_unknown_error(
|
||||||
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we show user form on unknown error."""
|
"""Test we show user form on unknown error."""
|
||||||
user_input = MOCK_USER_INPUT.copy()
|
user_input = MOCK_USER_INPUT.copy()
|
||||||
@ -97,7 +97,7 @@ async def test_unknown_error(
|
|||||||
|
|
||||||
|
|
||||||
async def test_full_reauth_flow_implementation(
|
async def test_full_reauth_flow_implementation(
|
||||||
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the manual reauth flow from start to finish."""
|
"""Test the manual reauth flow from start to finish."""
|
||||||
entry = await setup_integration(
|
entry = await setup_integration(
|
||||||
@ -137,7 +137,7 @@ async def test_full_reauth_flow_implementation(
|
|||||||
|
|
||||||
|
|
||||||
async def test_full_user_flow_implementation(
|
async def test_full_user_flow_implementation(
|
||||||
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the full manual user flow from start to finish."""
|
"""Test the full manual user flow from start to finish."""
|
||||||
mock_connection(aioclient_mock)
|
mock_connection(aioclient_mock)
|
||||||
@ -166,7 +166,7 @@ async def test_full_user_flow_implementation(
|
|||||||
|
|
||||||
|
|
||||||
async def test_full_user_flow_advanced_options(
|
async def test_full_user_flow_advanced_options(
|
||||||
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the full manual user flow with advanced options."""
|
"""Test the full manual user flow with advanced options."""
|
||||||
mock_connection(aioclient_mock)
|
mock_connection(aioclient_mock)
|
||||||
|
@ -12,8 +12,8 @@ from homeassistant.const import (
|
|||||||
DATA_GIGABYTES,
|
DATA_GIGABYTES,
|
||||||
STATE_UNAVAILABLE,
|
STATE_UNAVAILABLE,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from tests.common import async_fire_time_changed
|
from tests.common import async_fire_time_changed
|
||||||
@ -24,7 +24,7 @@ UPCOMING_ENTITY_ID = f"{SENSOR_DOMAIN}.sonarr_upcoming"
|
|||||||
|
|
||||||
|
|
||||||
async def test_sensors(
|
async def test_sensors(
|
||||||
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the creation and values of the sensors."""
|
"""Test the creation and values of the sensors."""
|
||||||
entry = await setup_integration(hass, aioclient_mock, skip_entry_setup=True)
|
entry = await setup_integration(hass, aioclient_mock, skip_entry_setup=True)
|
||||||
@ -104,7 +104,7 @@ async def test_sensors(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def test_disabled_by_default_sensors(
|
async def test_disabled_by_default_sensors(
|
||||||
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker, entity_id: str
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, entity_id: str
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the disabled by default sensors."""
|
"""Test the disabled by default sensors."""
|
||||||
await setup_integration(hass, aioclient_mock)
|
await setup_integration(hass, aioclient_mock)
|
||||||
@ -121,7 +121,7 @@ async def test_disabled_by_default_sensors(
|
|||||||
|
|
||||||
|
|
||||||
async def test_availability(
|
async def test_availability(
|
||||||
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test entity availability."""
|
"""Test entity availability."""
|
||||||
now = dt_util.utcnow()
|
now = dt_util.utcnow()
|
||||||
|
@ -19,11 +19,10 @@ from homeassistant.components.switcher_kis.switch import (
|
|||||||
SERVICE_TURN_ON_WITH_TIMER_NAME,
|
SERVICE_TURN_ON_WITH_TIMER_NAME,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_ENTITY_ID
|
from homeassistant.const import CONF_ENTITY_ID
|
||||||
from homeassistant.core import Context, callback
|
from homeassistant.core import Context, HomeAssistant, callback
|
||||||
from homeassistant.exceptions import UnknownUser
|
from homeassistant.exceptions import UnknownUser
|
||||||
from homeassistant.helpers.config_validation import time_period_str
|
from homeassistant.helpers.config_validation import time_period_str
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt
|
from homeassistant.util import dt
|
||||||
|
|
||||||
@ -47,21 +46,21 @@ from tests.common import MockUser, async_fire_time_changed
|
|||||||
|
|
||||||
|
|
||||||
async def test_failed_config(
|
async def test_failed_config(
|
||||||
hass: HomeAssistantType, mock_failed_bridge: Generator[None, Any, None]
|
hass: HomeAssistant, mock_failed_bridge: Generator[None, Any, None]
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test failed configuration."""
|
"""Test failed configuration."""
|
||||||
assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION) is False
|
assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION) is False
|
||||||
|
|
||||||
|
|
||||||
async def test_minimal_config(
|
async def test_minimal_config(
|
||||||
hass: HomeAssistantType, mock_bridge: Generator[None, Any, None]
|
hass: HomeAssistant, mock_bridge: Generator[None, Any, None]
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setup with configuration minimal entries."""
|
"""Test setup with configuration minimal entries."""
|
||||||
assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION)
|
assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION)
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_data_bucket(
|
async def test_discovery_data_bucket(
|
||||||
hass: HomeAssistantType, mock_bridge: Generator[None, Any, None]
|
hass: HomeAssistant, mock_bridge: Generator[None, Any, None]
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the event send with the updated device."""
|
"""Test the event send with the updated device."""
|
||||||
assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION)
|
assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION)
|
||||||
@ -82,7 +81,7 @@ async def test_discovery_data_bucket(
|
|||||||
|
|
||||||
|
|
||||||
async def test_set_auto_off_service(
|
async def test_set_auto_off_service(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
mock_bridge: Generator[None, Any, None],
|
mock_bridge: Generator[None, Any, None],
|
||||||
mock_api: Generator[None, Any, None],
|
mock_api: Generator[None, Any, None],
|
||||||
hass_owner_user: MockUser,
|
hass_owner_user: MockUser,
|
||||||
@ -130,7 +129,7 @@ async def test_set_auto_off_service(
|
|||||||
|
|
||||||
|
|
||||||
async def test_turn_on_with_timer_service(
|
async def test_turn_on_with_timer_service(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
mock_bridge: Generator[None, Any, None],
|
mock_bridge: Generator[None, Any, None],
|
||||||
mock_api: Generator[None, Any, None],
|
mock_api: Generator[None, Any, None],
|
||||||
hass_owner_user: MockUser,
|
hass_owner_user: MockUser,
|
||||||
@ -184,7 +183,7 @@ async def test_turn_on_with_timer_service(
|
|||||||
|
|
||||||
|
|
||||||
async def test_signal_dispatcher(
|
async def test_signal_dispatcher(
|
||||||
hass: HomeAssistantType, mock_bridge: Generator[None, Any, None]
|
hass: HomeAssistant, mock_bridge: Generator[None, Any, None]
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test signal dispatcher dispatching device updates every 4 seconds."""
|
"""Test signal dispatcher dispatching device updates every 4 seconds."""
|
||||||
assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION)
|
assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION)
|
||||||
|
@ -36,7 +36,7 @@ from homeassistant.const import (
|
|||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
CONF_VERIFY_SSL,
|
CONF_VERIFY_SSL,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .consts import (
|
from .consts import (
|
||||||
DEVICE_TOKEN,
|
DEVICE_TOKEN,
|
||||||
@ -114,7 +114,7 @@ def mock_controller_service_failed():
|
|||||||
yield service_mock
|
yield service_mock
|
||||||
|
|
||||||
|
|
||||||
async def test_user(hass: HomeAssistantType, service: MagicMock):
|
async def test_user(hass: HomeAssistant, service: MagicMock):
|
||||||
"""Test user config."""
|
"""Test user config."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=None
|
DOMAIN, context={"source": SOURCE_USER}, data=None
|
||||||
@ -177,7 +177,7 @@ async def test_user(hass: HomeAssistantType, service: MagicMock):
|
|||||||
assert result["data"].get(CONF_VOLUMES) is None
|
assert result["data"].get(CONF_VOLUMES) is None
|
||||||
|
|
||||||
|
|
||||||
async def test_user_2sa(hass: HomeAssistantType, service_2sa: MagicMock):
|
async def test_user_2sa(hass: HomeAssistant, service_2sa: MagicMock):
|
||||||
"""Test user with 2sa authentication config."""
|
"""Test user with 2sa authentication config."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -220,7 +220,7 @@ async def test_user_2sa(hass: HomeAssistantType, service_2sa: MagicMock):
|
|||||||
assert result["data"].get(CONF_VOLUMES) is None
|
assert result["data"].get(CONF_VOLUMES) is None
|
||||||
|
|
||||||
|
|
||||||
async def test_user_vdsm(hass: HomeAssistantType, service_vdsm: MagicMock):
|
async def test_user_vdsm(hass: HomeAssistant, service_vdsm: MagicMock):
|
||||||
"""Test user config."""
|
"""Test user config."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=None
|
DOMAIN, context={"source": SOURCE_USER}, data=None
|
||||||
@ -256,7 +256,7 @@ async def test_user_vdsm(hass: HomeAssistantType, service_vdsm: MagicMock):
|
|||||||
assert result["data"].get(CONF_VOLUMES) is None
|
assert result["data"].get(CONF_VOLUMES) is None
|
||||||
|
|
||||||
|
|
||||||
async def test_import(hass: HomeAssistantType, service: MagicMock):
|
async def test_import(hass: HomeAssistant, service: MagicMock):
|
||||||
"""Test import step."""
|
"""Test import step."""
|
||||||
# import with minimum setup
|
# import with minimum setup
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -309,7 +309,7 @@ async def test_import(hass: HomeAssistantType, service: MagicMock):
|
|||||||
assert result["data"][CONF_VOLUMES] == ["volume_1"]
|
assert result["data"][CONF_VOLUMES] == ["volume_1"]
|
||||||
|
|
||||||
|
|
||||||
async def test_abort_if_already_setup(hass: HomeAssistantType, service: MagicMock):
|
async def test_abort_if_already_setup(hass: HomeAssistant, service: MagicMock):
|
||||||
"""Test we abort if the account is already setup."""
|
"""Test we abort if the account is already setup."""
|
||||||
MockConfigEntry(
|
MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
@ -336,7 +336,7 @@ async def test_abort_if_already_setup(hass: HomeAssistantType, service: MagicMoc
|
|||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
async def test_login_failed(hass: HomeAssistantType, service: MagicMock):
|
async def test_login_failed(hass: HomeAssistant, service: MagicMock):
|
||||||
"""Test when we have errors during login."""
|
"""Test when we have errors during login."""
|
||||||
service.return_value.login = Mock(
|
service.return_value.login = Mock(
|
||||||
side_effect=(SynologyDSMLoginInvalidException(USERNAME))
|
side_effect=(SynologyDSMLoginInvalidException(USERNAME))
|
||||||
@ -351,7 +351,7 @@ async def test_login_failed(hass: HomeAssistantType, service: MagicMock):
|
|||||||
assert result["errors"] == {CONF_USERNAME: "invalid_auth"}
|
assert result["errors"] == {CONF_USERNAME: "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
async def test_connection_failed(hass: HomeAssistantType, service: MagicMock):
|
async def test_connection_failed(hass: HomeAssistant, service: MagicMock):
|
||||||
"""Test when we have errors during connection."""
|
"""Test when we have errors during connection."""
|
||||||
service.return_value.login = Mock(
|
service.return_value.login = Mock(
|
||||||
side_effect=SynologyDSMRequestException(IOError("arg"))
|
side_effect=SynologyDSMRequestException(IOError("arg"))
|
||||||
@ -367,7 +367,7 @@ async def test_connection_failed(hass: HomeAssistantType, service: MagicMock):
|
|||||||
assert result["errors"] == {CONF_HOST: "cannot_connect"}
|
assert result["errors"] == {CONF_HOST: "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
async def test_unknown_failed(hass: HomeAssistantType, service: MagicMock):
|
async def test_unknown_failed(hass: HomeAssistant, service: MagicMock):
|
||||||
"""Test when we have an unknown error."""
|
"""Test when we have an unknown error."""
|
||||||
service.return_value.login = Mock(side_effect=SynologyDSMException(None, None))
|
service.return_value.login = Mock(side_effect=SynologyDSMException(None, None))
|
||||||
|
|
||||||
@ -381,9 +381,7 @@ async def test_unknown_failed(hass: HomeAssistantType, service: MagicMock):
|
|||||||
assert result["errors"] == {"base": "unknown"}
|
assert result["errors"] == {"base": "unknown"}
|
||||||
|
|
||||||
|
|
||||||
async def test_missing_data_after_login(
|
async def test_missing_data_after_login(hass: HomeAssistant, service_failed: MagicMock):
|
||||||
hass: HomeAssistantType, service_failed: MagicMock
|
|
||||||
):
|
|
||||||
"""Test when we have errors during connection."""
|
"""Test when we have errors during connection."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -394,9 +392,7 @@ async def test_missing_data_after_login(
|
|||||||
assert result["errors"] == {"base": "missing_data"}
|
assert result["errors"] == {"base": "missing_data"}
|
||||||
|
|
||||||
|
|
||||||
async def test_form_ssdp_already_configured(
|
async def test_form_ssdp_already_configured(hass: HomeAssistant, service: MagicMock):
|
||||||
hass: HomeAssistantType, service: MagicMock
|
|
||||||
):
|
|
||||||
"""Test ssdp abort when the serial number is already configured."""
|
"""Test ssdp abort when the serial number is already configured."""
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
|
|
||||||
@ -423,7 +419,7 @@ async def test_form_ssdp_already_configured(
|
|||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
|
||||||
|
|
||||||
async def test_form_ssdp(hass: HomeAssistantType, service: MagicMock):
|
async def test_form_ssdp(hass: HomeAssistant, service: MagicMock):
|
||||||
"""Test we can setup from ssdp."""
|
"""Test we can setup from ssdp."""
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
|
|
||||||
@ -459,7 +455,7 @@ async def test_form_ssdp(hass: HomeAssistantType, service: MagicMock):
|
|||||||
assert result["data"].get(CONF_VOLUMES) is None
|
assert result["data"].get(CONF_VOLUMES) is None
|
||||||
|
|
||||||
|
|
||||||
async def test_options_flow(hass: HomeAssistantType, service: MagicMock):
|
async def test_options_flow(hass: HomeAssistant, service: MagicMock):
|
||||||
"""Test config flow options."""
|
"""Test config flow options."""
|
||||||
config_entry = MockConfigEntry(
|
config_entry = MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
|
@ -12,7 +12,7 @@ from homeassistant.const import (
|
|||||||
CONF_SSL,
|
CONF_SSL,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .consts import HOST, MACS, PASSWORD, PORT, USE_SSL, USERNAME
|
from .consts import HOST, MACS, PASSWORD, PORT, USE_SSL, USERNAME
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ from tests.common import MockConfigEntry
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.no_bypass_setup
|
@pytest.mark.no_bypass_setup
|
||||||
async def test_services_registered(hass: HomeAssistantType):
|
async def test_services_registered(hass: HomeAssistant):
|
||||||
"""Test if all services are registered."""
|
"""Test if all services are registered."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.synology_dsm.SynoApi.async_setup", return_value=True
|
"homeassistant.components.synology_dsm.SynoApi.async_setup", return_value=True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user