diff --git a/homeassistant/components/asterisk_mbox.py b/homeassistant/components/asterisk_mbox.py index f059d83b958566..0907e48b256ab9 100644 --- a/homeassistant/components/asterisk_mbox.py +++ b/homeassistant/components/asterisk_mbox.py @@ -13,7 +13,7 @@ from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv from homeassistant.helpers.dispatcher import ( - async_dispatcher_connect, async_dispatcher_send) + async_dispatcher_send, dispatcher_connect) REQUIREMENTS = ['asterisk_mbox==0.5.0'] @@ -55,19 +55,19 @@ class AsteriskData: def __init__(self, hass, host, port, password, config): """Init the Asterisk data object.""" from asterisk_mbox import Client as asteriskClient - self.hass = hass self.config = config - self.client = asteriskClient(host, port, password, self.handle_data) self.messages = None self.cdr = None - async_dispatcher_connect( + dispatcher_connect( self.hass, SIGNAL_MESSAGE_REQUEST, self._request_messages) - async_dispatcher_connect( + dispatcher_connect( self.hass, SIGNAL_CDR_REQUEST, self._request_cdr) - async_dispatcher_connect( + 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): diff --git a/homeassistant/components/mailbox/__init__.py b/homeassistant/components/mailbox/__init__.py index 71950d22f8dea0..2ed12b231649ac 100644 --- a/homeassistant/components/mailbox/__init__.py +++ b/homeassistant/components/mailbox/__init__.py @@ -64,7 +64,7 @@ async def async_setup_platform(p_type, p_config=None, discovery_info=None): mailbox = await \ platform.async_get_handler(hass, p_config, discovery_info) elif hasattr(platform, 'get_handler'): - mailbox = await hass.async_add_job( + mailbox = await hass.async_add_executor_job( platform.get_handler, hass, p_config, discovery_info) else: raise HomeAssistantError("Invalid mailbox platform.") diff --git a/homeassistant/components/mailbox/asterisk_cdr.py b/homeassistant/components/mailbox/asterisk_cdr.py index b27543a0fd5a68..ae0939c3da5d6a 100644 --- a/homeassistant/components/mailbox/asterisk_cdr.py +++ b/homeassistant/components/mailbox/asterisk_cdr.py @@ -2,7 +2,7 @@ Asterisk CDR interface. For more details about this platform, please refer to the documentation at -https://home-assistant.io/components/mailbox.asteriskvm/ +https://home-assistant.io/components/mailbox.asterisk_cdr/ """ import logging import hashlib @@ -10,7 +10,7 @@ from homeassistant.core import callback from homeassistant.components.asterisk_mbox import SIGNAL_CDR_UPDATE -from homeassistant.components.asterisk_mbox import DOMAIN +from homeassistant.components.asterisk_mbox import DOMAIN as ASTERISK_DOMAIN from homeassistant.components.mailbox import Mailbox from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -43,7 +43,7 @@ def _update_callback(self, msg): def _build_message(self): """Build message structure.""" cdr = [] - for entry in self.hass.data[DOMAIN].cdr: + for entry in self.hass.data[ASTERISK_DOMAIN].cdr: timestamp = datetime.datetime.strptime( entry['time'], "%Y-%m-%d %H:%M:%S").timestamp() info = {