diff --git a/.strict-typing b/.strict-typing index 169a361262c5e46a9d5054c20284ba2ad6b1afe3..1eec42ad209cf1b7fdd51adeb2a30820983b2fc4 100644 --- a/.strict-typing +++ b/.strict-typing @@ -95,7 +95,6 @@ homeassistant.components.aruba.* homeassistant.components.arwn.* homeassistant.components.aseko_pool_live.* homeassistant.components.assist_pipeline.* -homeassistant.components.asterisk_mbox.* homeassistant.components.asuswrt.* homeassistant.components.autarco.* homeassistant.components.auth.* diff --git a/homeassistant/components/asterisk_mbox/__init__.py b/homeassistant/components/asterisk_mbox/__init__.py deleted file mode 100644 index 3e3913b7d42bfbcb7653eeb71ff9b26659e38360..0000000000000000000000000000000000000000 --- a/homeassistant/components/asterisk_mbox/__init__.py +++ /dev/null @@ -1,153 +0,0 @@ -"""Support for Asterisk Voicemail interface.""" - -import logging -from typing import Any, cast - -from asterisk_mbox import Client as asteriskClient -from asterisk_mbox.commands import ( - CMD_MESSAGE_CDR, - CMD_MESSAGE_CDR_AVAILABLE, - CMD_MESSAGE_LIST, -) -import voluptuous as vol - -from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT -from homeassistant.core import HomeAssistant, callback -from homeassistant.helpers import discovery -import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.dispatcher import async_dispatcher_send, dispatcher_connect -from homeassistant.helpers.issue_registry import IssueSeverity, create_issue -from homeassistant.helpers.typing import ConfigType - -_LOGGER = logging.getLogger(__name__) - -DOMAIN = "asterisk_mbox" - -SIGNAL_DISCOVER_PLATFORM = "asterisk_mbox.discover_platform" -SIGNAL_MESSAGE_REQUEST = "asterisk_mbox.message_request" -SIGNAL_MESSAGE_UPDATE = "asterisk_mbox.message_updated" -SIGNAL_CDR_UPDATE = "asterisk_mbox.message_updated" -SIGNAL_CDR_REQUEST = "asterisk_mbox.message_request" - -CONFIG_SCHEMA = vol.Schema( - { - DOMAIN: vol.Schema( - { - vol.Required(CONF_HOST): cv.string, - vol.Required(CONF_PASSWORD): cv.string, - vol.Required(CONF_PORT): cv.port, - } - ) - }, - extra=vol.ALLOW_EXTRA, -) - - -def setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Set up for the Asterisk Voicemail box.""" - conf: dict[str, Any] = config[DOMAIN] - - host: str = conf[CONF_HOST] - port: int = conf[CONF_PORT] - password: str = conf[CONF_PASSWORD] - - hass.data[DOMAIN] = AsteriskData(hass, host, port, password, config) - create_issue( - hass, - DOMAIN, - "deprecated_integration", - breaks_in_ha_version="2024.9.0", - is_fixable=False, - issue_domain=DOMAIN, - severity=IssueSeverity.WARNING, - translation_key="deprecated_integration", - translation_placeholders={ - "domain": DOMAIN, - "integration_title": "Asterisk Voicemail", - "mailbox": "mailbox", - }, - ) - - return True - - -class AsteriskData: - """Store Asterisk mailbox data.""" - - def __init__( - self, - hass: HomeAssistant, - host: str, - port: int, - password: str, - config: dict[str, Any], - ) -> None: - """Init the Asterisk data object.""" - - self.hass = hass - self.config = config - self.messages: list[dict[str, Any]] | None = None - self.cdr: list[dict[str, Any]] | None = None - - dispatcher_connect(self.hass, SIGNAL_MESSAGE_REQUEST, self._request_messages) - dispatcher_connect(self.hass, SIGNAL_CDR_REQUEST, self._request_cdr) - dispatcher_connect(self.hass, SIGNAL_DISCOVER_PLATFORM, self._discover_platform) - # Only connect after signal connection to ensure we don't miss any - self.client = asteriskClient(host, port, password, self.handle_data) - - @callback - def _discover_platform(self, component: str) -> None: - _LOGGER.debug("Adding mailbox %s", component) - self.hass.async_create_task( - discovery.async_load_platform( - self.hass, "mailbox", component, {}, self.config - ) - ) - - @callback - def handle_data( - self, command: int, msg: list[dict[str, Any]] | dict[str, Any] - ) -> None: - """Handle changes to the mailbox.""" - - if command == CMD_MESSAGE_LIST: - msg = cast(list[dict[str, Any]], msg) - _LOGGER.debug("AsteriskVM sent updated message list: Len %d", len(msg)) - old_messages = self.messages - self.messages = sorted( - msg, key=lambda item: item["info"]["origtime"], reverse=True - ) - if not isinstance(old_messages, list): - async_dispatcher_send(self.hass, SIGNAL_DISCOVER_PLATFORM, DOMAIN) - async_dispatcher_send(self.hass, SIGNAL_MESSAGE_UPDATE, self.messages) - elif command == CMD_MESSAGE_CDR: - msg = cast(dict[str, Any], msg) - _LOGGER.debug( - "AsteriskVM sent updated CDR list: Len %d", len(msg.get("entries", [])) - ) - self.cdr = msg["entries"] - async_dispatcher_send(self.hass, SIGNAL_CDR_UPDATE, self.cdr) - elif command == CMD_MESSAGE_CDR_AVAILABLE: - if not isinstance(self.cdr, list): - _LOGGER.debug("AsteriskVM adding CDR platform") - self.cdr = [] - async_dispatcher_send( - self.hass, SIGNAL_DISCOVER_PLATFORM, "asterisk_cdr" - ) - async_dispatcher_send(self.hass, SIGNAL_CDR_REQUEST) - else: - _LOGGER.debug( - "AsteriskVM sent unknown message '%d' len: %d", command, len(msg) - ) - - @callback - def _request_messages(self) -> None: - """Handle changes to the mailbox.""" - _LOGGER.debug("Requesting message list") - self.client.messages() - - @callback - def _request_cdr(self) -> None: - """Handle changes to the CDR.""" - _LOGGER.debug("Requesting CDR list") - self.client.get_cdr() diff --git a/homeassistant/components/asterisk_mbox/mailbox.py b/homeassistant/components/asterisk_mbox/mailbox.py deleted file mode 100644 index 14d54596eea270dae13cceca4724f3a8440430a4..0000000000000000000000000000000000000000 --- a/homeassistant/components/asterisk_mbox/mailbox.py +++ /dev/null @@ -1,86 +0,0 @@ -"""Support for the Asterisk Voicemail interface.""" - -from __future__ import annotations - -from functools import partial -import logging -from typing import Any - -from asterisk_mbox import ServerError - -from homeassistant.components.mailbox import CONTENT_TYPE_MPEG, Mailbox, StreamError -from homeassistant.core import HomeAssistant, callback -from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType - -from . import DOMAIN as ASTERISK_DOMAIN, AsteriskData - -_LOGGER = logging.getLogger(__name__) - -SIGNAL_MESSAGE_REQUEST = "asterisk_mbox.message_request" -SIGNAL_MESSAGE_UPDATE = "asterisk_mbox.message_updated" - - -async def async_get_handler( - hass: HomeAssistant, - config: ConfigType, - discovery_info: DiscoveryInfoType | None = None, -) -> Mailbox: - """Set up the Asterix VM platform.""" - return AsteriskMailbox(hass, ASTERISK_DOMAIN) - - -class AsteriskMailbox(Mailbox): - """Asterisk VM Sensor.""" - - def __init__(self, hass: HomeAssistant, name: str) -> None: - """Initialize Asterisk mailbox.""" - super().__init__(hass, name) - async_dispatcher_connect( - self.hass, SIGNAL_MESSAGE_UPDATE, self._update_callback - ) - - @callback - def _update_callback(self, msg: str) -> None: - """Update the message count in HA, if needed.""" - self.async_update() - - @property - def media_type(self) -> str: - """Return the supported media type.""" - return CONTENT_TYPE_MPEG - - @property - def can_delete(self) -> bool: - """Return if messages can be deleted.""" - return True - - @property - def has_media(self) -> bool: - """Return if messages have attached media files.""" - return True - - async def async_get_media(self, msgid: str) -> bytes: - """Return the media blob for the msgid.""" - - data: AsteriskData = self.hass.data[ASTERISK_DOMAIN] - client = data.client - try: - return await self.hass.async_add_executor_job( - partial(client.mp3, msgid, sync=True) - ) - except ServerError as err: - raise StreamError(err) from err - - async def async_get_messages(self) -> list[dict[str, Any]]: - """Return a list of the current messages.""" - data: AsteriskData = self.hass.data[ASTERISK_DOMAIN] - return data.messages or [] - - async def async_delete(self, msgid: str) -> bool: - """Delete the specified messages.""" - data: AsteriskData = self.hass.data[ASTERISK_DOMAIN] - client = data.client - _LOGGER.info("Deleting: %s", msgid) - await self.hass.async_add_executor_job(client.delete, msgid) - return True diff --git a/homeassistant/components/asterisk_mbox/manifest.json b/homeassistant/components/asterisk_mbox/manifest.json deleted file mode 100644 index 8348e40ba6b9aae225059132b8fc4fa322317dc9..0000000000000000000000000000000000000000 --- a/homeassistant/components/asterisk_mbox/manifest.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "domain": "asterisk_mbox", - "name": "Asterisk Voicemail", - "codeowners": [], - "documentation": "https://www.home-assistant.io/integrations/asterisk_mbox", - "iot_class": "local_push", - "loggers": ["asterisk_mbox"], - "requirements": ["asterisk_mbox==0.5.0"] -} diff --git a/homeassistant/components/asterisk_mbox/strings.json b/homeassistant/components/asterisk_mbox/strings.json deleted file mode 100644 index fb6c0637a644b69a389b68ace7716ba9e52217e9..0000000000000000000000000000000000000000 --- a/homeassistant/components/asterisk_mbox/strings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "issues": { - "deprecated_integration": { - "title": "The {integration_title} is being removed", - "description": "{integration_title} is being removed as the `{mailbox}` platform is being removed and {integration_title} supports no other platforms. Remove the `{domain}` configuration from your configuration.yaml file and restart Home Assistant to fix this issue." - } - } -} diff --git a/homeassistant/generated/integrations.json b/homeassistant/generated/integrations.json index 55e7a89c6696082d6e8bcdc447938745c948561d..673e37b3c12deba610f50e2368b0a40708236647 100644 --- a/homeassistant/generated/integrations.json +++ b/homeassistant/generated/integrations.json @@ -502,12 +502,6 @@ "config_flow": false, "iot_class": "local_push" }, - "asterisk_mbox": { - "name": "Asterisk Voicemail", - "integration_type": "hub", - "config_flow": false, - "iot_class": "local_push" - }, "asuswrt": { "name": "ASUSWRT", "integration_type": "hub", diff --git a/mypy.ini b/mypy.ini index 67755595e69ee1be749ac311435a242a97cd0c42..c5478689702733806c968c521b1681295bb1aa15 100644 --- a/mypy.ini +++ b/mypy.ini @@ -705,16 +705,6 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true -[mypy-homeassistant.components.asterisk_mbox.*] -check_untyped_defs = true -disallow_incomplete_defs = true -disallow_subclassing_any = true -disallow_untyped_calls = true -disallow_untyped_decorators = true -disallow_untyped_defs = true -warn_return_any = true -warn_unreachable = true - [mypy-homeassistant.components.asuswrt.*] check_untyped_defs = true disallow_incomplete_defs = true diff --git a/requirements_all.txt b/requirements_all.txt index 2e49dfc914ff87f048251447fdadd336b680e8bf..f373c0fe7e39ac81d681c4fd190d79e8e3d8efa9 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -481,9 +481,6 @@ arris-tg2492lg==2.2.0 # homeassistant.components.ampio asmog==0.0.6 -# homeassistant.components.asterisk_mbox -asterisk_mbox==0.5.0 - # homeassistant.components.dlna_dmr # homeassistant.components.dlna_dms # homeassistant.components.samsungtv diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 63bdf5d3cc5fd6159099f1d291d146c944211e81..529232f7847353a99e722946932bdfb9912902a5 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -445,9 +445,6 @@ aranet4==2.3.4 # homeassistant.components.arcam_fmj arcam-fmj==1.5.2 -# homeassistant.components.asterisk_mbox -asterisk_mbox==0.5.0 - # homeassistant.components.dlna_dmr # homeassistant.components.dlna_dms # homeassistant.components.samsungtv diff --git a/script/licenses.py b/script/licenses.py index 281f440a02ea36053f536508eb6cc430ef8be9e1..e612b96794cb9b3f4f2ea43e82561e53a6a891a4 100644 --- a/script/licenses.py +++ b/script/licenses.py @@ -179,9 +179,6 @@ TODO = { "aiocache": AwesomeVersion( "0.12.2" ), # https://github.com/aio-libs/aiocache/blob/master/LICENSE all rights reserved? - "asterisk_mbox": AwesomeVersion( - "0.5.0" - ), # No license, integration is deprecated and scheduled for removal in 2024.9.0 "mficlient": AwesomeVersion( "0.3.0" ), # No license https://github.com/kk7ds/mficlient/issues/4 diff --git a/tests/components/asterisk_mbox/__init__.py b/tests/components/asterisk_mbox/__init__.py deleted file mode 100644 index 79e3675ad0776ad55688f4949ba493305557ff7a..0000000000000000000000000000000000000000 --- a/tests/components/asterisk_mbox/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Tests for the asterisk component.""" diff --git a/tests/components/asterisk_mbox/const.py b/tests/components/asterisk_mbox/const.py deleted file mode 100644 index 945c6b28d3022ee0a49eec3c28a11c43e9fd1373..0000000000000000000000000000000000000000 --- a/tests/components/asterisk_mbox/const.py +++ /dev/null @@ -1,12 +0,0 @@ -"""Asterisk tests constants.""" - -from homeassistant.components.asterisk_mbox import DOMAIN -from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT - -CONFIG = { - DOMAIN: { - CONF_HOST: "localhost", - CONF_PASSWORD: "password", - CONF_PORT: 1234, - } -} diff --git a/tests/components/asterisk_mbox/test_init.py b/tests/components/asterisk_mbox/test_init.py deleted file mode 100644 index d7567ea32863657624c617406edbe70e323fadf0..0000000000000000000000000000000000000000 --- a/tests/components/asterisk_mbox/test_init.py +++ /dev/null @@ -1,36 +0,0 @@ -"""Test mailbox.""" - -from collections.abc import Generator -from unittest.mock import Mock, patch - -import pytest - -from homeassistant.components.asterisk_mbox import DOMAIN -from homeassistant.core import HomeAssistant -from homeassistant.helpers import issue_registry as ir -from homeassistant.setup import async_setup_component - -from .const import CONFIG - - -@pytest.fixture -def client() -> Generator[Mock]: - """Mock client.""" - with patch( - "homeassistant.components.asterisk_mbox.asteriskClient", autospec=True - ) as client: - yield client - - -async def test_repair_issue_is_created( - hass: HomeAssistant, - issue_registry: ir.IssueRegistry, - client: Mock, -) -> None: - """Test repair issue is created.""" - assert await async_setup_component(hass, DOMAIN, CONFIG) - await hass.async_block_till_done() - assert ( - DOMAIN, - "deprecated_integration", - ) in issue_registry.issues