mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Remove deprecated YAML configuration from Skybell (#76940)
This commit is contained in:
parent
c3305caabe
commit
cbeaea98d1
@ -2,39 +2,22 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from aioskybell import Skybell
|
||||
from aioskybell.exceptions import SkybellAuthenticationException, SkybellException
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_USERNAME, Platform
|
||||
from homeassistant.components.repairs.issue_handler import async_create_issue
|
||||
from homeassistant.components.repairs.models import IssueSeverity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DEFAULT_CACHEDB, DOMAIN
|
||||
from .const import DOMAIN
|
||||
from .coordinator import SkybellDataUpdateCoordinator
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
vol.All(
|
||||
# Deprecated in Home Assistant 2022.6
|
||||
cv.deprecated(DOMAIN),
|
||||
{
|
||||
DOMAIN: vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_USERNAME): cv.string,
|
||||
vol.Required(CONF_PASSWORD): cv.string,
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
|
||||
PLATFORMS = [
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.CAMERA,
|
||||
@ -48,31 +31,17 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the SkyBell component."""
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
|
||||
entry_config = {}
|
||||
if DOMAIN not in config:
|
||||
return True
|
||||
for parameter, value in config[DOMAIN].items():
|
||||
if parameter == CONF_USERNAME:
|
||||
entry_config[CONF_EMAIL] = value
|
||||
else:
|
||||
entry_config[parameter] = value
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data=entry_config,
|
||||
)
|
||||
if DOMAIN in config:
|
||||
async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"removed_yaml",
|
||||
breaks_in_ha_version="2022.9.0",
|
||||
is_fixable=False,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="removed_yaml",
|
||||
)
|
||||
|
||||
# Clean up unused cache file since we are using an account specific name
|
||||
# Remove with import
|
||||
def clean_cache():
|
||||
"""Clean old cache filename."""
|
||||
if os.path.exists(hass.config.path(DEFAULT_CACHEDB)):
|
||||
os.remove(hass.config.path(DEFAULT_CACHEDB))
|
||||
|
||||
await hass.async_add_executor_job(clean_cache)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
@ -2,18 +2,14 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from aioskybell.helpers import const as CONST
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
PLATFORM_SCHEMA,
|
||||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
BinarySensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import DOMAIN
|
||||
@ -33,21 +29,11 @@ BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
||||
),
|
||||
)
|
||||
|
||||
# Deprecated in Home Assistant 2022.6
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Optional(CONF_ENTITY_NAMESPACE, default=DOMAIN): cv.string,
|
||||
vol.Required(CONF_MONITORED_CONDITIONS, default=[]): vol.All(
|
||||
cv.ensure_list, [vol.In(BINARY_SENSOR_TYPES)]
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
) -> None:
|
||||
"""Set up Skybell switch."""
|
||||
"""Set up Skybell binary sensor."""
|
||||
async_add_entities(
|
||||
SkybellBinarySensor(coordinator, sensor)
|
||||
for sensor in BINARY_SENSOR_TYPES
|
||||
|
@ -3,43 +3,19 @@ from __future__ import annotations
|
||||
|
||||
from aiohttp import web
|
||||
from haffmpeg.camera import CameraMjpeg
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.camera import (
|
||||
PLATFORM_SCHEMA,
|
||||
Camera,
|
||||
CameraEntityDescription,
|
||||
)
|
||||
from homeassistant.components.camera import Camera, CameraEntityDescription
|
||||
from homeassistant.components.ffmpeg import get_ffmpeg_manager
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_MONITORED_CONDITIONS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import async_aiohttp_proxy_stream
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import EntityDescription
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import (
|
||||
CONF_ACTIVITY_NAME,
|
||||
CONF_AVATAR_NAME,
|
||||
DOMAIN,
|
||||
IMAGE_ACTIVITY,
|
||||
IMAGE_AVATAR,
|
||||
)
|
||||
from .const import DOMAIN
|
||||
from .coordinator import SkybellDataUpdateCoordinator
|
||||
from .entity import SkybellEntity
|
||||
|
||||
# Deprecated in Home Assistant 2022.6
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Optional(CONF_MONITORED_CONDITIONS, default=[IMAGE_AVATAR]): vol.All(
|
||||
cv.ensure_list, [vol.In([IMAGE_AVATAR, IMAGE_ACTIVITY])]
|
||||
),
|
||||
vol.Optional(CONF_ACTIVITY_NAME): cv.string,
|
||||
vol.Optional(CONF_AVATAR_NAME): cv.string,
|
||||
}
|
||||
)
|
||||
|
||||
CAMERA_TYPES: tuple[CameraEntityDescription, ...] = (
|
||||
CameraEntityDescription(key="activity", name="Last activity"),
|
||||
CameraEntityDescription(key="avatar", name="Camera"),
|
||||
@ -49,7 +25,7 @@ CAMERA_TYPES: tuple[CameraEntityDescription, ...] = (
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
) -> None:
|
||||
"""Set up Skybell switch."""
|
||||
"""Set up Skybell camera."""
|
||||
entities = []
|
||||
for description in CAMERA_TYPES:
|
||||
for coordinator in hass.data[DOMAIN][entry.entry_id]:
|
||||
|
@ -10,7 +10,6 @@ from homeassistant import config_entries
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
@ -18,12 +17,6 @@ from .const import DOMAIN
|
||||
class SkybellFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Skybell."""
|
||||
|
||||
async def async_step_import(self, user_input: ConfigType) -> FlowResult:
|
||||
"""Import a config entry from configuration.yaml."""
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="already_configured")
|
||||
return await self.async_step_user(user_input)
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
|
@ -2,9 +2,6 @@
|
||||
import logging
|
||||
from typing import Final
|
||||
|
||||
CONF_ACTIVITY_NAME = "activity_name"
|
||||
CONF_AVATAR_NAME = "avatar_name"
|
||||
DEFAULT_CACHEDB = "./skybell_cache.pickle"
|
||||
DEFAULT_NAME = "SkyBell"
|
||||
DOMAIN: Final = "skybell"
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/skybell",
|
||||
"requirements": ["aioskybell==22.7.0"],
|
||||
"dependencies": ["ffmpeg"],
|
||||
"dependencies": ["ffmpeg", "repairs"],
|
||||
"codeowners": ["@tkdrob"],
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["aioskybell"]
|
||||
|
@ -7,18 +7,14 @@ from typing import Any
|
||||
|
||||
from aioskybell import SkybellDevice
|
||||
from aioskybell.helpers import const as CONST
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
PLATFORM_SCHEMA,
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
@ -95,18 +91,6 @@ SENSOR_TYPES: tuple[SkybellSensorEntityDescription, ...] = (
|
||||
),
|
||||
)
|
||||
|
||||
MONITORED_CONDITIONS = SENSOR_TYPES
|
||||
|
||||
# Deprecated in Home Assistant 2022.6
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Optional(CONF_ENTITY_NAMESPACE, default=DOMAIN): cv.string,
|
||||
vol.Required(CONF_MONITORED_CONDITIONS, default=[]): vol.All(
|
||||
cv.ensure_list, [vol.In(MONITORED_CONDITIONS)]
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
|
@ -17,5 +17,11 @@
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]",
|
||||
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
|
||||
}
|
||||
},
|
||||
"issues": {
|
||||
"removed_yaml": {
|
||||
"title": "The Skybell YAML configuration has been removed",
|
||||
"description": "Configuring Skybell using YAML has been removed.\n\nYour existing YAML configuration is not used by Home Assistant.\n\nRemove the YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,17 +3,9 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, cast
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.switch import (
|
||||
PLATFORM_SCHEMA,
|
||||
SwitchEntity,
|
||||
SwitchEntityDescription,
|
||||
)
|
||||
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN
|
||||
@ -34,16 +26,6 @@ SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
|
||||
),
|
||||
)
|
||||
|
||||
# Deprecated in Home Assistant 2022.6
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Optional(CONF_ENTITY_NAMESPACE, default=DOMAIN): cv.string,
|
||||
vol.Required(CONF_MONITORED_CONDITIONS, default=[]): vol.All(
|
||||
cv.ensure_list, [vol.In(SWITCH_TYPES)]
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
|
@ -17,5 +17,11 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"issues": {
|
||||
"removed_yaml": {
|
||||
"title": "The Skybell YAML configuration has been removed",
|
||||
"description": "Configuring Skybell using YAML has been removed.\n\nYour existing YAML configuration is not used by Home Assistant.\n\nRemove the YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue."
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
||||
from aioskybell import exceptions
|
||||
|
||||
from homeassistant.components.skybell.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
@ -99,35 +99,3 @@ async def test_flow_user_unknown_error(hass: HomeAssistant) -> None:
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
async def test_flow_import(hass: HomeAssistant) -> None:
|
||||
"""Test import step."""
|
||||
with _patch_skybell(), _patch_skybell_devices(), _patch_setup_entry(), _patch_setup():
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_IMPORT}
|
||||
)
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input=CONF_CONFIG_FLOW,
|
||||
)
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "user"
|
||||
assert result["data"] == CONF_CONFIG_FLOW
|
||||
|
||||
|
||||
async def test_flow_import_already_configured(hass: HomeAssistant) -> None:
|
||||
"""Test import step already configured."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN, unique_id="123456789012345678901234", data=CONF_CONFIG_FLOW
|
||||
)
|
||||
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with _patch_skybell():
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
)
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
Loading…
x
Reference in New Issue
Block a user