hass-core/homeassistant/components/dovado/notify.py
Fabian Affolter 127c55e0c1
Update file header (#21023)
* Update file header

* Update file header

* Update file header

* Update file header

* Update file header

* Fix lint issues
2019-02-13 21:21:14 +01:00

33 lines
1,014 B
Python

"""Support for SMS notifications from the Dovado router."""
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)