diff --git a/homeassistant/components/simulated/sensor.py b/homeassistant/components/simulated/sensor.py index b4180ba300deff99d14ff8801c2cafe16b38e87b..22ce4bd7cea78af817026116383be7f41c64fb0f 100644 --- a/homeassistant/components/simulated/sensor.py +++ b/homeassistant/components/simulated/sensor.py @@ -14,6 +14,7 @@ from homeassistant.components.sensor import ( ) from homeassistant.const import CONF_NAME from homeassistant.core import HomeAssistant +from homeassistant.helpers import issue_registry as ir import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType @@ -38,6 +39,8 @@ DEFAULT_SEED = 999 DEFAULT_UNIT = "value" DEFAULT_RELATIVE_TO_EPOCH = True +DOMAIN = "simulated" + PLATFORM_SCHEMA = SENSOR_PLATFORM_SCHEMA.extend( { 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, config: ConfigType, - add_entities: AddEntitiesCallback, + async_add_entities: AddEntitiesCallback, discovery_info: DiscoveryInfoType | None = None, ) -> None: """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) unit = config.get(CONF_UNIT) amp = config.get(CONF_AMP) @@ -75,7 +92,7 @@ def setup_platform( sensor = SimulatedSensor( name, unit, amp, mean, period, phase, fwhm, seed, relative_to_epoch ) - add_entities([sensor], True) + async_add_entities([sensor], True) class SimulatedSensor(SensorEntity): diff --git a/homeassistant/components/simulated/strings.json b/homeassistant/components/simulated/strings.json new file mode 100644 index 0000000000000000000000000000000000000000..d25a84f48a54f4f57fa557c386be6317d92da413 --- /dev/null +++ b/homeassistant/components/simulated/strings.json @@ -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." + } + } +} diff --git a/tests/components/simulated/test_sensor.py b/tests/components/simulated/test_sensor.py index d32eca8c66eb89eff61f84afff22403d44a109da..b167147367ae26ebe7b40875c56e7518a18bde41 100644 --- a/tests/components/simulated/test_sensor.py +++ b/tests/components/simulated/test_sensor.py @@ -16,13 +16,17 @@ from homeassistant.components.simulated.sensor import ( DEFAULT_PHASE, DEFAULT_RELATIVE_TO_EPOCH, DEFAULT_SEED, + DOMAIN, ) from homeassistant.const import CONF_FRIENDLY_NAME from homeassistant.core import HomeAssistant +from homeassistant.helpers import issue_registry as ir 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.""" config = {"sensor": {"platform": "simulated"}} 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_SEED) == DEFAULT_SEED 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"