mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Remove deprecated asterisk_mbox integration (#123174)
This commit is contained in:
parent
ef237a8431
commit
42ab8d0445
@ -95,7 +95,6 @@ homeassistant.components.aruba.*
|
|||||||
homeassistant.components.arwn.*
|
homeassistant.components.arwn.*
|
||||||
homeassistant.components.aseko_pool_live.*
|
homeassistant.components.aseko_pool_live.*
|
||||||
homeassistant.components.assist_pipeline.*
|
homeassistant.components.assist_pipeline.*
|
||||||
homeassistant.components.asterisk_mbox.*
|
|
||||||
homeassistant.components.asuswrt.*
|
homeassistant.components.asuswrt.*
|
||||||
homeassistant.components.autarco.*
|
homeassistant.components.autarco.*
|
||||||
homeassistant.components.auth.*
|
homeassistant.components.auth.*
|
||||||
|
@ -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()
|
|
@ -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
|
|
@ -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"]
|
|
||||||
}
|
|
@ -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."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -502,12 +502,6 @@
|
|||||||
"config_flow": false,
|
"config_flow": false,
|
||||||
"iot_class": "local_push"
|
"iot_class": "local_push"
|
||||||
},
|
},
|
||||||
"asterisk_mbox": {
|
|
||||||
"name": "Asterisk Voicemail",
|
|
||||||
"integration_type": "hub",
|
|
||||||
"config_flow": false,
|
|
||||||
"iot_class": "local_push"
|
|
||||||
},
|
|
||||||
"asuswrt": {
|
"asuswrt": {
|
||||||
"name": "ASUSWRT",
|
"name": "ASUSWRT",
|
||||||
"integration_type": "hub",
|
"integration_type": "hub",
|
||||||
|
10
mypy.ini
10
mypy.ini
@ -705,16 +705,6 @@ disallow_untyped_defs = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = 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.*]
|
[mypy-homeassistant.components.asuswrt.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
@ -481,9 +481,6 @@ arris-tg2492lg==2.2.0
|
|||||||
# homeassistant.components.ampio
|
# homeassistant.components.ampio
|
||||||
asmog==0.0.6
|
asmog==0.0.6
|
||||||
|
|
||||||
# homeassistant.components.asterisk_mbox
|
|
||||||
asterisk_mbox==0.5.0
|
|
||||||
|
|
||||||
# homeassistant.components.dlna_dmr
|
# homeassistant.components.dlna_dmr
|
||||||
# homeassistant.components.dlna_dms
|
# homeassistant.components.dlna_dms
|
||||||
# homeassistant.components.samsungtv
|
# homeassistant.components.samsungtv
|
||||||
|
@ -445,9 +445,6 @@ aranet4==2.3.4
|
|||||||
# homeassistant.components.arcam_fmj
|
# homeassistant.components.arcam_fmj
|
||||||
arcam-fmj==1.5.2
|
arcam-fmj==1.5.2
|
||||||
|
|
||||||
# homeassistant.components.asterisk_mbox
|
|
||||||
asterisk_mbox==0.5.0
|
|
||||||
|
|
||||||
# homeassistant.components.dlna_dmr
|
# homeassistant.components.dlna_dmr
|
||||||
# homeassistant.components.dlna_dms
|
# homeassistant.components.dlna_dms
|
||||||
# homeassistant.components.samsungtv
|
# homeassistant.components.samsungtv
|
||||||
|
@ -179,9 +179,6 @@ TODO = {
|
|||||||
"aiocache": AwesomeVersion(
|
"aiocache": AwesomeVersion(
|
||||||
"0.12.2"
|
"0.12.2"
|
||||||
), # https://github.com/aio-libs/aiocache/blob/master/LICENSE all rights reserved?
|
), # 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(
|
"mficlient": AwesomeVersion(
|
||||||
"0.3.0"
|
"0.3.0"
|
||||||
), # No license https://github.com/kk7ds/mficlient/issues/4
|
), # No license https://github.com/kk7ds/mficlient/issues/4
|
||||||
|
@ -1 +0,0 @@
|
|||||||
"""Tests for the asterisk component."""
|
|
@ -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,
|
|
||||||
}
|
|
||||||
}
|
|
@ -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
|
|
Loading…
x
Reference in New Issue
Block a user