diff --git a/CODEOWNERS b/CODEOWNERS index bf805f67abc8..faa802636cb8 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1155,7 +1155,6 @@ CLAUDE.md @home-assistant/core /tests/components/motionmount/ @laiho-vogels /homeassistant/components/mqtt/ @emontnemery @jbouwh @bdraco /tests/components/mqtt/ @emontnemery @jbouwh @bdraco -/homeassistant/components/msteams/ @peroyvind /homeassistant/components/mta/ @OnFreund /tests/components/mta/ @OnFreund /homeassistant/components/mullvad/ @meichthys diff --git a/homeassistant/brands/microsoft.json b/homeassistant/brands/microsoft.json index c3931bb0f2d6..bfdf62cc2769 100644 --- a/homeassistant/brands/microsoft.json +++ b/homeassistant/brands/microsoft.json @@ -11,7 +11,6 @@ "microsoft_face_identify", "microsoft_face", "microsoft", - "msteams", "onedrive", "onedrive_for_business", "xbox" diff --git a/homeassistant/components/msteams/manifest.json b/homeassistant/components/msteams/manifest.json index 3ded77c2176b..8eeb0fcaf543 100644 --- a/homeassistant/components/msteams/manifest.json +++ b/homeassistant/components/msteams/manifest.json @@ -1,10 +1,8 @@ { "domain": "msteams", "name": "Microsoft Teams", - "codeowners": ["@peroyvind"], + "codeowners": [], "documentation": "https://www.home-assistant.io/integrations/msteams", "iot_class": "cloud_push", - "loggers": ["pymsteams"], - "quality_scale": "legacy", - "requirements": ["pymsteams==0.1.12"] + "quality_scale": "legacy" } diff --git a/homeassistant/components/msteams/notify.py b/homeassistant/components/msteams/notify.py index 4f7b9ba0abcd..623f856ba0c6 100644 --- a/homeassistant/components/msteams/notify.py +++ b/homeassistant/components/msteams/notify.py @@ -1,75 +1,32 @@ """Microsoft Teams platform for notify component.""" -import logging -from typing import Any - -import pymsteams import voluptuous as vol -from homeassistant.components.notify import ( - ATTR_DATA, - ATTR_TITLE, - ATTR_TITLE_DEFAULT, - PLATFORM_SCHEMA as NOTIFY_PLATFORM_SCHEMA, - BaseNotificationService, -) +from homeassistant.components.notify import PLATFORM_SCHEMA as NOTIFY_PLATFORM_SCHEMA from homeassistant.const import CONF_URL from homeassistant.core import HomeAssistant -from homeassistant.helpers import config_validation as cv +from homeassistant.helpers import config_validation as cv, issue_registry as ir from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -_LOGGER = logging.getLogger(__name__) - -ATTR_FILE_URL = "image_url" +DOMAIN = "msteams" PLATFORM_SCHEMA = NOTIFY_PLATFORM_SCHEMA.extend({vol.Required(CONF_URL): cv.url}) -def get_service( +async def async_get_service( hass: HomeAssistant, config: ConfigType, discovery_info: DiscoveryInfoType | None = None, -) -> MSTeamsNotificationService | None: +) -> None: """Get the Microsoft Teams notification service.""" - webhook_url = config.get(CONF_URL) - - try: - return MSTeamsNotificationService(webhook_url) - - except RuntimeError: - _LOGGER.exception("Error in creating a new Microsoft Teams message") - return None - - -class MSTeamsNotificationService(BaseNotificationService): - """Implement the notification service for Microsoft Teams.""" - - def __init__(self, webhook_url): - """Initialize the service.""" - self._webhook_url = webhook_url - - def send_message(self, message: str = "", **kwargs: Any) -> None: - """Send a message to the webhook.""" - - teams_message = pymsteams.connectorcard(self._webhook_url) - - title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT) - data = kwargs.get(ATTR_DATA) - - teams_message.title(title) - - teams_message.text(message) - - if data is not None and (file_url := data.get(ATTR_FILE_URL)) is not None: - if not file_url.startswith("http"): - _LOGGER.error("URL should start with http or https") - return - - message_section = pymsteams.cardsection() - message_section.addImage(file_url) - teams_message.addSection(message_section) - try: - teams_message.send() - # pylint: disable-next=home-assistant-action-swallowed-exception - except RuntimeError as err: - _LOGGER.error("Could not send notification. Error: %s", err) + ir.async_create_issue( + hass, + DOMAIN, + DOMAIN, + is_fixable=False, + severity=ir.IssueSeverity.ERROR, + translation_key="integration_removed", + translation_placeholders={ + CONF_URL: "https://devblogs.microsoft.com/microsoft365dev/retirement-of-office-365-connectors-within-microsoft-teams/" + }, + ) diff --git a/homeassistant/components/msteams/strings.json b/homeassistant/components/msteams/strings.json new file mode 100644 index 000000000000..4706b0a14b23 --- /dev/null +++ b/homeassistant/components/msteams/strings.json @@ -0,0 +1,8 @@ +{ + "issues": { + "integration_removed": { + "description": "The Microsoft Teams integration has been removed from Home Assistant.\n\nThe [Office 365 Connectors]({url}) used by this integration to send messages to Microsoft Teams have been discontinued by Microsoft and are no longer supported.\n\nTo resolve this issue, remove the Microsoft Teams integration configuration from your `configuration.yaml` file and restart Home Assistant.\n\nOnce the configuration has been removed and Home Assistant has restarted, this issue will no longer be shown.", + "title": "Microsoft Teams integration has been removed" + } + } +} diff --git a/homeassistant/generated/integrations.json b/homeassistant/generated/integrations.json index 30bcacba51de..706ae755090c 100644 --- a/homeassistant/generated/integrations.json +++ b/homeassistant/generated/integrations.json @@ -4324,12 +4324,6 @@ "iot_class": "cloud_push", "name": "Microsoft Text-to-Speech (TTS)" }, - "msteams": { - "integration_type": "hub", - "config_flow": false, - "iot_class": "cloud_push", - "name": "Microsoft Teams" - }, "onedrive": { "integration_type": "service", "config_flow": true, @@ -4563,6 +4557,12 @@ } } }, + "msteams": { + "name": "Microsoft Teams", + "integration_type": "hub", + "config_flow": false, + "iot_class": "cloud_push" + }, "mta": { "name": "MTA New York City Transit", "integration_type": "service", diff --git a/requirements_all.txt b/requirements_all.txt index 4f309be227ad..ea73643f95b1 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2366,9 +2366,6 @@ pymodbus==3.11.2 # homeassistant.components.monoprice pymonoprice==0.5 -# homeassistant.components.msteams -pymsteams==0.1.12 - # homeassistant.components.mysensors pymysensors==0.26.0