From babb3d10a1cc113522e43a75563301676dc1accc Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Fri, 5 Aug 2022 10:59:43 +0200 Subject: [PATCH] Deprecate the Deutsche Bahn (#76286) --- .../components/deutsche_bahn/manifest.json | 1 + .../components/deutsche_bahn/sensor.py | 17 ++++++++++++++++- .../components/deutsche_bahn/strings.json | 8 ++++++++ .../deutsche_bahn/translations/en.json | 8 ++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 homeassistant/components/deutsche_bahn/strings.json create mode 100644 homeassistant/components/deutsche_bahn/translations/en.json diff --git a/homeassistant/components/deutsche_bahn/manifest.json b/homeassistant/components/deutsche_bahn/manifest.json index 1eeb2241db5..dd69a940de0 100644 --- a/homeassistant/components/deutsche_bahn/manifest.json +++ b/homeassistant/components/deutsche_bahn/manifest.json @@ -3,6 +3,7 @@ "name": "Deutsche Bahn", "documentation": "https://www.home-assistant.io/integrations/deutsche_bahn", "requirements": ["schiene==0.23"], + "dependencies": ["repairs"], "codeowners": [], "iot_class": "cloud_polling", "loggers": ["schiene"] diff --git a/homeassistant/components/deutsche_bahn/sensor.py b/homeassistant/components/deutsche_bahn/sensor.py index 6c784fa9a89..07c330fd402 100644 --- a/homeassistant/components/deutsche_bahn/sensor.py +++ b/homeassistant/components/deutsche_bahn/sensor.py @@ -2,10 +2,12 @@ from __future__ import annotations from datetime import timedelta +import logging import schiene import voluptuous as vol +from homeassistant.components.repairs import IssueSeverity, create_issue from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_OFFSET from homeassistant.core import HomeAssistant @@ -33,6 +35,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( } ) +_LOGGER = logging.getLogger(__name__) + def setup_platform( hass: HomeAssistant, @@ -45,7 +49,18 @@ def setup_platform( destination = config[CONF_DESTINATION] offset = config[CONF_OFFSET] only_direct = config[CONF_ONLY_DIRECT] - + create_issue( + hass, + "deutsche_bahn", + "pending_removal", + breaks_in_ha_version="2022.11.0", + is_fixable=False, + severity=IssueSeverity.WARNING, + translation_key="pending_removal", + ) + _LOGGER.warning( + "The Deutsche Bahn sensor component is deprecated and will be removed in Home Assistant 2022.11" + ) add_entities([DeutscheBahnSensor(start, destination, offset, only_direct)], True) diff --git a/homeassistant/components/deutsche_bahn/strings.json b/homeassistant/components/deutsche_bahn/strings.json new file mode 100644 index 00000000000..c88668862da --- /dev/null +++ b/homeassistant/components/deutsche_bahn/strings.json @@ -0,0 +1,8 @@ +{ + "issues": { + "pending_removal": { + "title": "The Deutsche Bahn integration is being removed", + "description": "The Deutsche Bahn integration is pending removal from Home Assistant and will no longer be available as of Home Assistant 2022.11.\n\nThe integration is being removed, because it relies on webscraping, which is not allowed.\n\nRemove the Deutsche Bahn YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue." + } + } +} diff --git a/homeassistant/components/deutsche_bahn/translations/en.json b/homeassistant/components/deutsche_bahn/translations/en.json new file mode 100644 index 00000000000..0ad1f14d1cc --- /dev/null +++ b/homeassistant/components/deutsche_bahn/translations/en.json @@ -0,0 +1,8 @@ +{ + "issues": { + "pending_removal": { + "description": "The Deutsche Bahn integration is pending removal from Home Assistant and will no longer be available as of Home Assistant 2022.11.\n\nThe integration is being removed, because it relies on webscraping, which is not allowed.\n\nRemove the Deutsche Bahn YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue.", + "title": "The Deutsche Bahn integration is being removed" + } + } +} \ No newline at end of file