-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Call Data Log platform. Mailboxes no longer require media #16579
Conversation
@@ -21,8 +20,7 @@ | |||
SIGNAL_MESSAGE_UPDATE = 'asterisk_mbox.message_updated' | |||
|
|||
|
|||
@asyncio.coroutine | |||
def async_get_handler(hass, config, async_add_entities, discovery_info=None): | |||
async def async_get_handler(hass, config, async_add_entities, discovery_info=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
DOMAIN = "asterisk_cdr" | ||
|
||
|
||
async def async_get_handler(hass, config, async_add_devices, discovery_info=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (82 > 79 characters)
|
||
DEPENDENCIES = ['asterisk_mbox'] | ||
_LOGGER = logging.getLogger(__name__) | ||
DOMAIN = "asterisk_cdr" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't call it DOMAIN as platforms don't have domains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok to merge when variable renamed.
Thanks, should be better now |
|
||
async_dispatcher_connect( | ||
self.hass, SIGNAL_MESSAGE_REQUEST, self._request_messages) | ||
async_dispatcher_connect( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must be called from within the event loop but it's called from setup
ie from a worker thread. Change to use the sync version.
platform.async_get_handler(hass, p_config, discovery_info) | ||
elif hasattr(platform, 'get_handler'): | ||
mailbox = yield from hass.async_add_job( | ||
mailbox = await hass.async_add_job( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use hass.async_add_executor_job
.
Asterisk CDR interface. | ||
|
||
For more details about this platform, please refer to the documentation at | ||
https://home-assistant.io/components/mailbox.asteriskvm/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The url is wrong.
|
||
from homeassistant.core import callback | ||
from homeassistant.components.asterisk_mbox import SIGNAL_CDR_UPDATE | ||
from homeassistant.components.asterisk_mbox import DOMAIN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This platform belongs to the mailbox domain. Import the asterix_mbox domain as another name.
from homeassistant.components.asterisk_mbox import DOMAIN as ASTERIX_MBOX_DOMAIN
008e69a
to
31b0f97
Compare
@MartinHjelmare Thanks for the review. Moving those async calls to sync uncovered a real race condition. Is there any way to detect async calls made from the wrong thread to help prevent these types of errors? I believe I have resolved all of your concerns. |
@@ -4,7 +4,6 @@ | |||
For more details about this platform, please refer to the documentation at | |||
https://home-assistant.io/components/mailbox.asteriskvm/ | |||
""" | |||
import asyncio | |||
import logging | |||
|
|||
from homeassistant.components.asterisk_mbox import DOMAIN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please import this as another name too.
@@ -18,8 +17,7 @@ | |||
DOMAIN = "DemoMailbox" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename the constant. The string is ok.
Not sure how to debug that. Maybe by timing callbacks? |
Sorry, I wasn't clear. I meant that changing to using the sync versions uncovered a timing race which I have already fixed. I was just wondering in general about checkers to help find these types of issues before I submit patches |
e94d67e
to
644144c
Compare
Yes, that was what I was answering. |
644144c
to
3a2a972
Compare
3a2a972
to
2f80578
Compare
Thanks, hopefully I've addressed your concerns now. Please let me know if you see anything else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I'll let @balloob merge since this depends on a frontend PR.
Description:
This patch adds the asterisk_cdr mailbox platform to view call activity. It also makes it possible to dynamically create mailbox platforms (needed in case CDR isn't supplied by the server). Additionally, mailboxes without media are now supported, as are read-only messages, making the mailbox platform more generic. Lastly all asycio.coroutines have been migrated to async/await.
This pull request requires a matching frontend change
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#6264
Pull request in home-assistant-polymer for frontend updates: home-assistant/frontend#1660
Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
.coveragerc
.