mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Split out dovado to a component and sensor platform (#20339)
* Split out dovado to a component and sensor platform * Lint * Address code review comments (#20339) * Switch to using a notify platform for dovado SMS (#20339) * Optimizing imports * Remove return on `setup_platform`. * Clean up unneeded constants
This commit is contained in:
committed by
Martin Hjelmare
parent
d82e5ecbb0
commit
7368c623d4
38
homeassistant/components/dovado/notify.py
Normal file
38
homeassistant/components/dovado/notify.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""
|
||||
Support for SMS notifications from the Dovado router.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/notify.dovado/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.dovado import DOMAIN as DOVADO_DOMAIN
|
||||
from homeassistant.components.notify import BaseNotificationService, \
|
||||
ATTR_TARGET
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEPENDENCIES = ['dovado']
|
||||
|
||||
|
||||
def get_service(hass, config, discovery_info=None):
|
||||
"""Get the Dovado Router SMS notification service."""
|
||||
return DovadoSMSNotificationService(hass.data[DOVADO_DOMAIN].client)
|
||||
|
||||
|
||||
class DovadoSMSNotificationService(BaseNotificationService):
|
||||
"""Implement the notification service for the Dovado SMS component."""
|
||||
|
||||
def __init__(self, client):
|
||||
"""Initialize the service."""
|
||||
self._client = client
|
||||
|
||||
def send_message(self, message, **kwargs):
|
||||
"""Send SMS to the specified target phone number."""
|
||||
target = kwargs.get(ATTR_TARGET)
|
||||
|
||||
if not target:
|
||||
_LOGGER.error("One target is required")
|
||||
return
|
||||
|
||||
self._client.send_sms(target, message)
|
||||
Reference in New Issue
Block a user