mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Remove worldclock config entry import (#134491)
This commit is contained in:
parent
a4708876a9
commit
657da47458
@ -83,10 +83,6 @@ CONFIG_FLOW = {
|
|||||||
schema=get_schema,
|
schema=get_schema,
|
||||||
validate_user_input=validate_duplicate,
|
validate_user_input=validate_duplicate,
|
||||||
),
|
),
|
||||||
"import": SchemaFlowFormStep(
|
|
||||||
schema=get_schema,
|
|
||||||
validate_user_input=validate_duplicate,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
OPTIONS_FLOW = {
|
OPTIONS_FLOW = {
|
||||||
"init": SchemaFlowFormStep(
|
"init": SchemaFlowFormStep(
|
||||||
|
@ -4,62 +4,15 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from datetime import tzinfo
|
from datetime import tzinfo
|
||||||
|
|
||||||
import voluptuous as vol
|
from homeassistant.components.sensor import SensorEntity
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.components.sensor import (
|
|
||||||
PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA,
|
|
||||||
SensorEntity,
|
|
||||||
)
|
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
|
||||||
from homeassistant.const import CONF_NAME, CONF_TIME_ZONE
|
from homeassistant.const import CONF_NAME, CONF_TIME_ZONE
|
||||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from .const import CONF_TIME_FORMAT, DEFAULT_NAME, DEFAULT_TIME_STR_FORMAT, DOMAIN
|
from .const import CONF_TIME_FORMAT, DOMAIN
|
||||||
|
|
||||||
PLATFORM_SCHEMA = SENSOR_PLATFORM_SCHEMA.extend(
|
|
||||||
{
|
|
||||||
vol.Required(CONF_TIME_ZONE): cv.time_zone,
|
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
|
||||||
vol.Optional(CONF_TIME_FORMAT, default=DEFAULT_TIME_STR_FORMAT): cv.string,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
config: ConfigType,
|
|
||||||
async_add_entities: AddEntitiesCallback,
|
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
|
||||||
) -> None:
|
|
||||||
"""Set up the World clock sensor."""
|
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_IMPORT},
|
|
||||||
data=config,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
async_create_issue(
|
|
||||||
hass,
|
|
||||||
HOMEASSISTANT_DOMAIN,
|
|
||||||
f"deprecated_yaml_{DOMAIN}",
|
|
||||||
breaks_in_ha_version="2025.2.0",
|
|
||||||
is_fixable=False,
|
|
||||||
issue_domain=DOMAIN,
|
|
||||||
severity=IssueSeverity.WARNING,
|
|
||||||
translation_key="deprecated_yaml",
|
|
||||||
translation_placeholders={
|
|
||||||
"domain": DOMAIN,
|
|
||||||
"integration_title": "Worldclock",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
|
@ -4,15 +4,9 @@ from datetime import tzinfo
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.worldclock.const import (
|
from homeassistant.components.worldclock.const import CONF_TIME_FORMAT, DEFAULT_NAME
|
||||||
CONF_TIME_FORMAT,
|
|
||||||
DEFAULT_NAME,
|
|
||||||
DOMAIN,
|
|
||||||
)
|
|
||||||
from homeassistant.const import CONF_NAME, CONF_TIME_ZONE
|
from homeassistant.const import CONF_NAME, CONF_TIME_ZONE
|
||||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import issue_registry as ir
|
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
@ -24,31 +18,6 @@ async def time_zone() -> tzinfo | None:
|
|||||||
return await dt_util.async_get_time_zone("America/New_York")
|
return await dt_util.async_get_time_zone("America/New_York")
|
||||||
|
|
||||||
|
|
||||||
async def test_time_imported_from_yaml(
|
|
||||||
hass: HomeAssistant, time_zone: tzinfo | None, issue_registry: ir.IssueRegistry
|
|
||||||
) -> None:
|
|
||||||
"""Test the time at a different location."""
|
|
||||||
config = {"sensor": {"platform": "worldclock", "time_zone": "America/New_York"}}
|
|
||||||
|
|
||||||
assert await async_setup_component(
|
|
||||||
hass,
|
|
||||||
"sensor",
|
|
||||||
config,
|
|
||||||
)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.worldclock_sensor")
|
|
||||||
assert state is not None
|
|
||||||
|
|
||||||
assert state.state == dt_util.now(time_zone=time_zone).strftime("%H:%M")
|
|
||||||
|
|
||||||
issue = issue_registry.async_get_issue(
|
|
||||||
HOMEASSISTANT_DOMAIN, f"deprecated_yaml_{DOMAIN}"
|
|
||||||
)
|
|
||||||
assert issue
|
|
||||||
assert issue.issue_domain == DOMAIN
|
|
||||||
|
|
||||||
|
|
||||||
async def test_time_from_config_entry(
|
async def test_time_from_config_entry(
|
||||||
hass: HomeAssistant, time_zone: tzinfo | None, loaded_entry: MockConfigEntry
|
hass: HomeAssistant, time_zone: tzinfo | None, loaded_entry: MockConfigEntry
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user