Deprecate simulated integration (#122166)
This commit is contained in:
parent
e50802aca3
commit
f5f9480b5a
3 changed files with 37 additions and 4 deletions
|
@ -14,6 +14,7 @@ from homeassistant.components.sensor import (
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_NAME
|
from homeassistant.const import CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers import issue_registry as ir
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
@ -38,6 +39,8 @@ DEFAULT_SEED = 999
|
||||||
DEFAULT_UNIT = "value"
|
DEFAULT_UNIT = "value"
|
||||||
DEFAULT_RELATIVE_TO_EPOCH = True
|
DEFAULT_RELATIVE_TO_EPOCH = True
|
||||||
|
|
||||||
|
DOMAIN = "simulated"
|
||||||
|
|
||||||
PLATFORM_SCHEMA = SENSOR_PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = SENSOR_PLATFORM_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
vol.Optional(CONF_AMP, default=DEFAULT_AMP): vol.Coerce(float),
|
vol.Optional(CONF_AMP, default=DEFAULT_AMP): vol.Coerce(float),
|
||||||
|
@ -55,13 +58,27 @@ PLATFORM_SCHEMA = SENSOR_PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(
|
async def async_setup_platform(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the simulated sensor."""
|
"""Set up the simulated sensor."""
|
||||||
|
# Simulated has been deprecated and will be removed in 2025.1
|
||||||
|
|
||||||
|
ir.async_create_issue(
|
||||||
|
hass,
|
||||||
|
DOMAIN,
|
||||||
|
DOMAIN,
|
||||||
|
breaks_in_ha_version="2025.1.0",
|
||||||
|
is_fixable=False,
|
||||||
|
severity=ir.IssueSeverity.WARNING,
|
||||||
|
translation_key="simulated_deprecation",
|
||||||
|
translation_placeholders={"integration": DOMAIN},
|
||||||
|
learn_more_url="https://www.home-assistant.io/integrations/simulated",
|
||||||
|
)
|
||||||
|
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
unit = config.get(CONF_UNIT)
|
unit = config.get(CONF_UNIT)
|
||||||
amp = config.get(CONF_AMP)
|
amp = config.get(CONF_AMP)
|
||||||
|
@ -75,7 +92,7 @@ def setup_platform(
|
||||||
sensor = SimulatedSensor(
|
sensor = SimulatedSensor(
|
||||||
name, unit, amp, mean, period, phase, fwhm, seed, relative_to_epoch
|
name, unit, amp, mean, period, phase, fwhm, seed, relative_to_epoch
|
||||||
)
|
)
|
||||||
add_entities([sensor], True)
|
async_add_entities([sensor], True)
|
||||||
|
|
||||||
|
|
||||||
class SimulatedSensor(SensorEntity):
|
class SimulatedSensor(SensorEntity):
|
||||||
|
|
8
homeassistant/components/simulated/strings.json
Normal file
8
homeassistant/components/simulated/strings.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"issues": {
|
||||||
|
"simulated_deprecation": {
|
||||||
|
"description": "The {integration} integration is deprecated",
|
||||||
|
"title": "The {integration} integration has been deprecated and will be removed in 2025.1. Please remove the {integration} from your configuration.yaml settings and restart Home Assistant to fix this issue."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,13 +16,17 @@ from homeassistant.components.simulated.sensor import (
|
||||||
DEFAULT_PHASE,
|
DEFAULT_PHASE,
|
||||||
DEFAULT_RELATIVE_TO_EPOCH,
|
DEFAULT_RELATIVE_TO_EPOCH,
|
||||||
DEFAULT_SEED,
|
DEFAULT_SEED,
|
||||||
|
DOMAIN,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_FRIENDLY_NAME
|
from homeassistant.const import CONF_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers import issue_registry as ir
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
|
|
||||||
async def test_simulated_sensor_default_config(hass: HomeAssistant) -> None:
|
async def test_simulated_sensor_default_config(
|
||||||
|
hass: HomeAssistant, issue_registry: ir.IssueRegistry
|
||||||
|
) -> None:
|
||||||
"""Test default config."""
|
"""Test default config."""
|
||||||
config = {"sensor": {"platform": "simulated"}}
|
config = {"sensor": {"platform": "simulated"}}
|
||||||
assert await async_setup_component(hass, "sensor", config)
|
assert await async_setup_component(hass, "sensor", config)
|
||||||
|
@ -40,3 +44,7 @@ async def test_simulated_sensor_default_config(hass: HomeAssistant) -> None:
|
||||||
assert state.attributes.get(CONF_FWHM) == DEFAULT_FWHM
|
assert state.attributes.get(CONF_FWHM) == DEFAULT_FWHM
|
||||||
assert state.attributes.get(CONF_SEED) == DEFAULT_SEED
|
assert state.attributes.get(CONF_SEED) == DEFAULT_SEED
|
||||||
assert state.attributes.get(CONF_RELATIVE_TO_EPOCH) == DEFAULT_RELATIVE_TO_EPOCH
|
assert state.attributes.get(CONF_RELATIVE_TO_EPOCH) == DEFAULT_RELATIVE_TO_EPOCH
|
||||||
|
|
||||||
|
issue = issue_registry.async_get_issue(DOMAIN, DOMAIN)
|
||||||
|
assert issue.issue_id == DOMAIN
|
||||||
|
assert issue.translation_key == "simulated_deprecation"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue