Fix PEP257 issues
This commit is contained in:
parent
cf7c2c492a
commit
652f059d6a
19 changed files with 86 additions and 131 deletions
|
@ -45,7 +45,7 @@ def send_message(hass, message, title=None):
|
||||||
|
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
"""Sets up notify services."""
|
"""Setup the notify services."""
|
||||||
success = False
|
success = False
|
||||||
|
|
||||||
descriptions = load_yaml_config_file(
|
descriptions = load_yaml_config_file(
|
||||||
|
@ -91,11 +91,11 @@ def setup(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class BaseNotificationService(object):
|
class BaseNotificationService(object):
|
||||||
"""Provides an ABC for notification services."""
|
"""An abstract class for notification services."""
|
||||||
|
|
||||||
def send_message(self, message, **kwargs):
|
def send_message(self, message, **kwargs):
|
||||||
"""
|
"""Send a message.
|
||||||
Send a message.
|
|
||||||
kwargs can contain ATTR_TITLE to specify a title.
|
kwargs can contain ATTR_TITLE to specify a title.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.command_line
|
Support for command line notification services.
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
command_line notification service.
|
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/notify.command_line/
|
https://home-assistant.io/components/notify.command_line/
|
||||||
|
@ -17,7 +15,6 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
"""Get the Command Line notification service."""
|
"""Get the Command Line notification service."""
|
||||||
|
|
||||||
if not validate_config({DOMAIN: config},
|
if not validate_config({DOMAIN: config},
|
||||||
{DOMAIN: ['command']},
|
{DOMAIN: ['command']},
|
||||||
_LOGGER):
|
_LOGGER):
|
||||||
|
@ -30,14 +27,14 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class CommandLineNotificationService(BaseNotificationService):
|
class CommandLineNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for the Command Line service. """
|
"""Implement the notification service for the Command Line service."""
|
||||||
|
|
||||||
def __init__(self, command):
|
def __init__(self, command):
|
||||||
|
"""Initialize the service."""
|
||||||
self.command = command
|
self.command = command
|
||||||
|
|
||||||
def send_message(self, message="", **kwargs):
|
def send_message(self, message="", **kwargs):
|
||||||
""" Send a message to a command_line. """
|
"""Send a message to a command line."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen(self.command, universal_newlines=True,
|
proc = subprocess.Popen(self.command, universal_newlines=True,
|
||||||
stdin=subprocess.PIPE, shell=True)
|
stdin=subprocess.PIPE, shell=True)
|
||||||
|
|
|
@ -16,13 +16,13 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class DemoNotificationService(BaseNotificationService):
|
class DemoNotificationService(BaseNotificationService):
|
||||||
"""Implements demo notification service."""
|
"""Implement demo notification service."""
|
||||||
|
|
||||||
def __init__(self, hass):
|
def __init__(self, hass):
|
||||||
|
"""Initialize the service."""
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
|
|
||||||
def send_message(self, message="", **kwargs):
|
def send_message(self, message="", **kwargs):
|
||||||
"""Send a message to a user."""
|
"""Send a message to a user."""
|
||||||
|
|
||||||
title = kwargs.get(ATTR_TITLE)
|
title = kwargs.get(ATTR_TITLE)
|
||||||
|
|
||||||
self.hass.bus.fire(EVENT_NOTIFY, {"title": title, "message": message})
|
self.hass.bus.fire(EVENT_NOTIFY, {"title": title, "message": message})
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.file
|
Support for file notification.
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
File notification service.
|
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/notify.file/
|
https://home-assistant.io/components/notify.file/
|
||||||
|
@ -19,7 +17,6 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
"""Get the file notification service."""
|
"""Get the file notification service."""
|
||||||
|
|
||||||
if not validate_config({DOMAIN: config},
|
if not validate_config({DOMAIN: config},
|
||||||
{DOMAIN: ['filename',
|
{DOMAIN: ['filename',
|
||||||
'timestamp']},
|
'timestamp']},
|
||||||
|
@ -34,15 +31,15 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class FileNotificationService(BaseNotificationService):
|
class FileNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for the File service. """
|
"""Implement the notification service for the File service."""
|
||||||
|
|
||||||
def __init__(self, hass, filename, add_timestamp):
|
def __init__(self, hass, filename, add_timestamp):
|
||||||
|
"""Initialize the service."""
|
||||||
self.filepath = os.path.join(hass.config.config_dir, filename)
|
self.filepath = os.path.join(hass.config.config_dir, filename)
|
||||||
self.add_timestamp = add_timestamp
|
self.add_timestamp = add_timestamp
|
||||||
|
|
||||||
def send_message(self, message="", **kwargs):
|
def send_message(self, message="", **kwargs):
|
||||||
"""Send a message to a file."""
|
"""Send a message to a file."""
|
||||||
|
|
||||||
with open(self.filepath, 'a') as file:
|
with open(self.filepath, 'a') as file:
|
||||||
if os.stat(self.filepath).st_size == 0:
|
if os.stat(self.filepath).st_size == 0:
|
||||||
title = '{} notifications (Log started: {})\n{}\n'.format(
|
title = '{} notifications (Log started: {})\n{}\n'.format(
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.free_mobile
|
Support for thr Free Mobile SMS platform.
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Free Mobile SMS platform for notify component.
|
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/notify.free_mobile/
|
https://home-assistant.io/components/notify.free_mobile/
|
||||||
|
@ -18,7 +16,6 @@ REQUIREMENTS = ['freesms==0.1.0']
|
||||||
|
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
"""Get the Free Mobile SMS notification service."""
|
"""Get the Free Mobile SMS notification service."""
|
||||||
|
|
||||||
if not validate_config({DOMAIN: config},
|
if not validate_config({DOMAIN: config},
|
||||||
{DOMAIN: [CONF_USERNAME,
|
{DOMAIN: [CONF_USERNAME,
|
||||||
CONF_ACCESS_TOKEN]},
|
CONF_ACCESS_TOKEN]},
|
||||||
|
@ -31,9 +28,10 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class FreeSMSNotificationService(BaseNotificationService):
|
class FreeSMSNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for the Free Mobile SMS service. """
|
"""Implement a notification service for the Free Mobile SMS service."""
|
||||||
|
|
||||||
def __init__(self, username, access_token):
|
def __init__(self, username, access_token):
|
||||||
|
"""Initialize the service."""
|
||||||
from freesms import FreeClient
|
from freesms import FreeClient
|
||||||
self.free_client = FreeClient(username, access_token)
|
self.free_client = FreeClient(username, access_token)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.googlevoice
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Google Voice SMS platform for notify component.
|
Google Voice SMS platform for notify component.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -21,7 +19,6 @@ REQUIREMENTS = ['https://github.com/w1ll1am23/pygooglevoice-sms/archive/'
|
||||||
|
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
"""Get the Google Voice SMS notification service."""
|
"""Get the Google Voice SMS notification service."""
|
||||||
|
|
||||||
if not validate_config({DOMAIN: config},
|
if not validate_config({DOMAIN: config},
|
||||||
{DOMAIN: [CONF_USERNAME,
|
{DOMAIN: [CONF_USERNAME,
|
||||||
CONF_PASSWORD]},
|
CONF_PASSWORD]},
|
||||||
|
@ -34,9 +31,10 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class GoogleVoiceSMSNotificationService(BaseNotificationService):
|
class GoogleVoiceSMSNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for the Google Voice SMS service. """
|
"""Implement the notification service for the Google Voice SMS service."""
|
||||||
|
|
||||||
def __init__(self, username, password):
|
def __init__(self, username, password):
|
||||||
|
"""Initialize the service."""
|
||||||
from googlevoicesms import Voice
|
from googlevoicesms import Voice
|
||||||
self.voice = Voice()
|
self.voice = Voice()
|
||||||
self.username = username
|
self.username = username
|
||||||
|
@ -44,7 +42,6 @@ class GoogleVoiceSMSNotificationService(BaseNotificationService):
|
||||||
|
|
||||||
def send_message(self, message="", **kwargs):
|
def send_message(self, message="", **kwargs):
|
||||||
"""Send SMS to specified target user cell."""
|
"""Send SMS to specified target user cell."""
|
||||||
|
|
||||||
targets = kwargs.get(ATTR_TARGET)
|
targets = kwargs.get(ATTR_TARGET)
|
||||||
|
|
||||||
if not targets:
|
if not targets:
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.instapush
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Instapush notification service.
|
Instapush notification service.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -22,7 +20,6 @@ _RESOURCE = 'https://api.instapush.im/v1/'
|
||||||
|
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
"""Get the instapush notification service."""
|
"""Get the instapush notification service."""
|
||||||
|
|
||||||
if not validate_config({DOMAIN: config},
|
if not validate_config({DOMAIN: config},
|
||||||
{DOMAIN: [CONF_API_KEY,
|
{DOMAIN: [CONF_API_KEY,
|
||||||
'app_secret',
|
'app_secret',
|
||||||
|
@ -58,9 +55,10 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class InstapushNotificationService(BaseNotificationService):
|
class InstapushNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for Instapush. """
|
"""Implement the notification service for Instapush."""
|
||||||
|
|
||||||
def __init__(self, api_key, app_secret, event, tracker):
|
def __init__(self, api_key, app_secret, event, tracker):
|
||||||
|
"""Initialize the service."""
|
||||||
self._api_key = api_key
|
self._api_key = api_key
|
||||||
self._app_secret = app_secret
|
self._app_secret = app_secret
|
||||||
self._event = event
|
self._event = event
|
||||||
|
@ -72,9 +70,7 @@ class InstapushNotificationService(BaseNotificationService):
|
||||||
|
|
||||||
def send_message(self, message="", **kwargs):
|
def send_message(self, message="", **kwargs):
|
||||||
"""Send a message to a user."""
|
"""Send a message to a user."""
|
||||||
|
|
||||||
title = kwargs.get(ATTR_TITLE)
|
title = kwargs.get(ATTR_TITLE)
|
||||||
|
|
||||||
data = {"event": self._event,
|
data = {"event": self._event,
|
||||||
"trackers": {self._tracker: title + " : " + message}}
|
"trackers": {self._tracker: title + " : " + message}}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.nma
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
NMA (Notify My Android) notification service.
|
NMA (Notify My Android) notification service.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -22,7 +20,6 @@ _RESOURCE = 'https://www.notifymyandroid.com/publicapi/'
|
||||||
|
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
"""Get the NMA notification service."""
|
"""Get the NMA notification service."""
|
||||||
|
|
||||||
if not validate_config({DOMAIN: config},
|
if not validate_config({DOMAIN: config},
|
||||||
{DOMAIN: [CONF_API_KEY]},
|
{DOMAIN: [CONF_API_KEY]},
|
||||||
_LOGGER):
|
_LOGGER):
|
||||||
|
@ -41,14 +38,14 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class NmaNotificationService(BaseNotificationService):
|
class NmaNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for NMA. """
|
"""Implement the notification service for NMA."""
|
||||||
|
|
||||||
def __init__(self, api_key):
|
def __init__(self, api_key):
|
||||||
|
"""Initialize the service."""
|
||||||
self._api_key = api_key
|
self._api_key = api_key
|
||||||
|
|
||||||
def send_message(self, message="", **kwargs):
|
def send_message(self, message="", **kwargs):
|
||||||
"""Send a message to a user."""
|
"""Send a message to a user."""
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"apikey": self._api_key,
|
"apikey": self._api_key,
|
||||||
"application": 'home-assistant',
|
"application": 'home-assistant',
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.pushbullet
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
PushBullet platform for notify component.
|
PushBullet platform for notify component.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -39,16 +37,16 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class PushBulletNotificationService(BaseNotificationService):
|
class PushBulletNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for Pushbullet. """
|
"""Implement the notification service for Pushbullet."""
|
||||||
|
|
||||||
def __init__(self, pb):
|
def __init__(self, pb):
|
||||||
|
"""Initialize the service."""
|
||||||
self.pushbullet = pb
|
self.pushbullet = pb
|
||||||
self.pbtargets = {}
|
self.pbtargets = {}
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
"""
|
"""Refresh devices, contacts, etc.
|
||||||
Refresh devices, contacts, etc
|
|
||||||
|
|
||||||
pbtargets stores all targets available from this pushbullet instance
|
pbtargets stores all targets available from this pushbullet instance
|
||||||
into a dict. These are PB objects!. It sacrifices a bit of memory
|
into a dict. These are PB objects!. It sacrifices a bit of memory
|
||||||
|
@ -67,8 +65,8 @@ class PushBulletNotificationService(BaseNotificationService):
|
||||||
}
|
}
|
||||||
|
|
||||||
def send_message(self, message=None, **kwargs):
|
def send_message(self, message=None, **kwargs):
|
||||||
"""
|
"""Send a message to a specified target.
|
||||||
Send a message to a specified target.
|
|
||||||
If no target specified, a 'normal' push will be sent to all devices
|
If no target specified, a 'normal' push will be sent to all devices
|
||||||
linked to the PB account.
|
linked to the PB account.
|
||||||
Email is special, these are assumed to always exist. We use a special
|
Email is special, these are assumed to always exist. We use a special
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.pushetta
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Pushetta platform for notify component.
|
Pushetta platform for notify component.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -20,7 +18,6 @@ REQUIREMENTS = ['pushetta==1.0.15']
|
||||||
|
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
"""Get the Pushetta notification service."""
|
"""Get the Pushetta notification service."""
|
||||||
|
|
||||||
from pushetta import Pushetta, exceptions
|
from pushetta import Pushetta, exceptions
|
||||||
|
|
||||||
if not validate_config({DOMAIN: config},
|
if not validate_config({DOMAIN: config},
|
||||||
|
@ -44,20 +41,17 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class PushettaNotificationService(BaseNotificationService):
|
class PushettaNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for Pushetta. """
|
"""Implement the notification service for Pushetta."""
|
||||||
|
|
||||||
def __init__(self, api_key, channel_name):
|
def __init__(self, api_key, channel_name):
|
||||||
|
"""Initialize the service."""
|
||||||
from pushetta import Pushetta
|
from pushetta import Pushetta
|
||||||
|
|
||||||
self._api_key = api_key
|
self._api_key = api_key
|
||||||
self._channel_name = channel_name
|
self._channel_name = channel_name
|
||||||
self.pushetta = Pushetta(self._api_key)
|
self.pushetta = Pushetta(self._api_key)
|
||||||
|
|
||||||
def send_message(self, message="", **kwargs):
|
def send_message(self, message="", **kwargs):
|
||||||
"""Send a message to a user."""
|
"""Send a message to a user."""
|
||||||
|
|
||||||
title = kwargs.get(ATTR_TITLE)
|
title = kwargs.get(ATTR_TITLE)
|
||||||
|
|
||||||
self.pushetta.pushMessage(self._channel_name,
|
self.pushetta.pushMessage(self._channel_name,
|
||||||
"{} {}".format(title, message))
|
"{} {}".format(title, message))
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.pushover
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Pushover platform for notify component.
|
Pushover platform for notify component.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -19,8 +17,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
# pylint: disable=unused-variable
|
# pylint: disable=unused-variable
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
""" Get the pushover notification service. """
|
"""Get the Pushover notification service."""
|
||||||
|
|
||||||
if not validate_config({DOMAIN: config},
|
if not validate_config({DOMAIN: config},
|
||||||
{DOMAIN: ['user_key', CONF_API_KEY]},
|
{DOMAIN: ['user_key', CONF_API_KEY]},
|
||||||
_LOGGER):
|
_LOGGER):
|
||||||
|
@ -40,9 +37,10 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class PushoverNotificationService(BaseNotificationService):
|
class PushoverNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for Pushover. """
|
"""Implement the notification service for Pushover."""
|
||||||
|
|
||||||
def __init__(self, user_key, api_token):
|
def __init__(self, user_key, api_token):
|
||||||
|
"""Initialize the service."""
|
||||||
from pushover import Client
|
from pushover import Client
|
||||||
self._user_key = user_key
|
self._user_key = user_key
|
||||||
self._api_token = api_token
|
self._api_token = api_token
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.rest
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
REST platform for notify component.
|
REST platform for notify component.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -24,7 +22,6 @@ DEFAULT_TARGET_PARAM_NAME = None
|
||||||
|
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
"""Get the REST notification service."""
|
"""Get the REST notification service."""
|
||||||
|
|
||||||
if not validate_config({DOMAIN: config},
|
if not validate_config({DOMAIN: config},
|
||||||
{DOMAIN: ['resource', ]},
|
{DOMAIN: ['resource', ]},
|
||||||
_LOGGER):
|
_LOGGER):
|
||||||
|
@ -45,10 +42,11 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods, too-many-arguments
|
# pylint: disable=too-few-public-methods, too-many-arguments
|
||||||
class RestNotificationService(BaseNotificationService):
|
class RestNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for REST. """
|
"""Implement the notification service for REST."""
|
||||||
|
|
||||||
def __init__(self, resource, method, message_param_name,
|
def __init__(self, resource, method, message_param_name,
|
||||||
title_param_name, target_param_name):
|
title_param_name, target_param_name):
|
||||||
|
"""Initialize the service."""
|
||||||
self._resource = resource
|
self._resource = resource
|
||||||
self._method = method.upper()
|
self._method = method.upper()
|
||||||
self._message_param_name = message_param_name
|
self._message_param_name = message_param_name
|
||||||
|
@ -57,7 +55,6 @@ class RestNotificationService(BaseNotificationService):
|
||||||
|
|
||||||
def send_message(self, message="", **kwargs):
|
def send_message(self, message="", **kwargs):
|
||||||
"""Send a message to a user."""
|
"""Send a message to a user."""
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
self._message_param_name: message
|
self._message_param_name: message
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.sendgrid
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
SendGrid notification service.
|
SendGrid notification service.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -17,7 +15,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
""" Get the SendGrid notification service """
|
"""Get the SendGrid notification service."""
|
||||||
if not validate_config({DOMAIN: config},
|
if not validate_config({DOMAIN: config},
|
||||||
{DOMAIN: ['api_key', 'sender', 'recipient']},
|
{DOMAIN: ['api_key', 'sender', 'recipient']},
|
||||||
_LOGGER):
|
_LOGGER):
|
||||||
|
@ -31,9 +29,10 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class SendgridNotificationService(BaseNotificationService):
|
class SendgridNotificationService(BaseNotificationService):
|
||||||
""" Implements the notification service for email via Sendgrid. """
|
"""Implement the notification service for email via Sendgrid."""
|
||||||
|
|
||||||
def __init__(self, api_key, sender, recipient):
|
def __init__(self, api_key, sender, recipient):
|
||||||
|
"""Initialize the service."""
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
self.sender = sender
|
self.sender = sender
|
||||||
self.recipient = recipient
|
self.recipient = recipient
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.slack
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Slack platform for notify component.
|
Slack platform for notify component.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -18,7 +16,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
# pylint: disable=unused-variable
|
# pylint: disable=unused-variable
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
""" Get the slack notification service. """
|
"""Get the Slack notification service."""
|
||||||
import slacker
|
import slacker
|
||||||
|
|
||||||
if not validate_config({DOMAIN: config},
|
if not validate_config({DOMAIN: config},
|
||||||
|
@ -39,11 +37,11 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class SlackNotificationService(BaseNotificationService):
|
class SlackNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for Slack. """
|
"""Implement the notification service for Slack."""
|
||||||
|
|
||||||
def __init__(self, default_channel, api_token):
|
def __init__(self, default_channel, api_token):
|
||||||
|
"""Initialize the service."""
|
||||||
from slacker import Slacker
|
from slacker import Slacker
|
||||||
|
|
||||||
self._default_channel = default_channel
|
self._default_channel = default_channel
|
||||||
self._api_token = api_token
|
self._api_token = api_token
|
||||||
self.slack = Slacker(self._api_token)
|
self.slack = Slacker(self._api_token)
|
||||||
|
@ -54,7 +52,6 @@ class SlackNotificationService(BaseNotificationService):
|
||||||
import slacker
|
import slacker
|
||||||
|
|
||||||
channel = kwargs.get('channel', self._default_channel)
|
channel = kwargs.get('channel', self._default_channel)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.slack.chat.post_message(channel, message)
|
self.slack.chat.post_message(channel, message)
|
||||||
except slacker.Error:
|
except slacker.Error:
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.smtp
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Mail (SMTP) notification service.
|
Mail (SMTP) notification service.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -19,7 +17,6 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
"""Get the mail notification service."""
|
"""Get the mail notification service."""
|
||||||
|
|
||||||
if not validate_config({DOMAIN: config},
|
if not validate_config({DOMAIN: config},
|
||||||
{DOMAIN: ['recipient']},
|
{DOMAIN: ['recipient']},
|
||||||
_LOGGER):
|
_LOGGER):
|
||||||
|
@ -74,11 +71,12 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods, too-many-instance-attributes
|
# pylint: disable=too-few-public-methods, too-many-instance-attributes
|
||||||
class MailNotificationService(BaseNotificationService):
|
class MailNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for E-Mail messages. """
|
"""Implement the notification service for E-Mail messages."""
|
||||||
|
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
def __init__(self, server, port, sender, starttls, username,
|
def __init__(self, server, port, sender, starttls, username,
|
||||||
password, recipient, debug):
|
password, recipient, debug):
|
||||||
|
"""Initialize the service."""
|
||||||
self._server = server
|
self._server = server
|
||||||
self._port = port
|
self._port = port
|
||||||
self._sender = sender
|
self._sender = sender
|
||||||
|
@ -90,8 +88,7 @@ class MailNotificationService(BaseNotificationService):
|
||||||
self.tries = 2
|
self.tries = 2
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
""" Connect/Authenticate to SMTP Server """
|
"""Connect/authenticate to SMTP Server."""
|
||||||
|
|
||||||
mail = smtplib.SMTP(self._server, self._port, timeout=5)
|
mail = smtplib.SMTP(self._server, self._port, timeout=5)
|
||||||
mail.set_debuglevel(self.debug)
|
mail.set_debuglevel(self.debug)
|
||||||
mail.ehlo_or_helo_if_needed()
|
mail.ehlo_or_helo_if_needed()
|
||||||
|
@ -104,7 +101,6 @@ class MailNotificationService(BaseNotificationService):
|
||||||
|
|
||||||
def send_message(self, message="", **kwargs):
|
def send_message(self, message="", **kwargs):
|
||||||
"""Send a message to a user."""
|
"""Send a message to a user."""
|
||||||
|
|
||||||
mail = self.connect()
|
mail = self.connect()
|
||||||
subject = kwargs.get(ATTR_TITLE)
|
subject = kwargs.get(ATTR_TITLE)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.syslog
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Syslog notification service.
|
Syslog notification service.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -69,10 +67,11 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class SyslogNotificationService(BaseNotificationService):
|
class SyslogNotificationService(BaseNotificationService):
|
||||||
""" Implements syslog notification service. """
|
"""Implement the syslog notification service."""
|
||||||
|
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
def __init__(self, facility, option, priority):
|
def __init__(self, facility, option, priority):
|
||||||
|
"""Initialize the service."""
|
||||||
self._facility = facility
|
self._facility = facility
|
||||||
self._option = option
|
self._option = option
|
||||||
self._priority = priority
|
self._priority = priority
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.telegram
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Telegram platform for notify component.
|
Telegram platform for notify component.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -41,9 +39,10 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class TelegramNotificationService(BaseNotificationService):
|
class TelegramNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for Telegram. """
|
"""Implement the notification service for Telegram."""
|
||||||
|
|
||||||
def __init__(self, api_key, chat_id):
|
def __init__(self, api_key, chat_id):
|
||||||
|
"""Initialize the service."""
|
||||||
import telegram
|
import telegram
|
||||||
|
|
||||||
self._api_key = api_key
|
self._api_key = api_key
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.twitter
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Twitter platform for notify component.
|
Twitter platform for notify component.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -22,7 +20,6 @@ CONF_ACCESS_TOKEN_SECRET = "access_token_secret"
|
||||||
|
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
"""Get the Twitter notification service."""
|
"""Get the Twitter notification service."""
|
||||||
|
|
||||||
if not validate_config({DOMAIN: config},
|
if not validate_config({DOMAIN: config},
|
||||||
{DOMAIN: [CONF_CONSUMER_KEY, CONF_CONSUMER_SECRET,
|
{DOMAIN: [CONF_CONSUMER_KEY, CONF_CONSUMER_SECRET,
|
||||||
CONF_ACCESS_TOKEN,
|
CONF_ACCESS_TOKEN,
|
||||||
|
@ -38,10 +35,11 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class TwitterNotificationService(BaseNotificationService):
|
class TwitterNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for the Twitter service. """
|
"""Implement notification service for the Twitter service."""
|
||||||
|
|
||||||
def __init__(self, consumer_key, consumer_secret, access_token_key,
|
def __init__(self, consumer_key, consumer_secret, access_token_key,
|
||||||
access_token_secret):
|
access_token_secret):
|
||||||
|
"""Initialize the service."""
|
||||||
from TwitterAPI import TwitterAPI
|
from TwitterAPI import TwitterAPI
|
||||||
self.api = TwitterAPI(consumer_key, consumer_secret, access_token_key,
|
self.api = TwitterAPI(consumer_key, consumer_secret, access_token_key,
|
||||||
access_token_secret)
|
access_token_secret)
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.notify.xmpp
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Jabber (XMPP) notification service.
|
Jabber (XMPP) notification service.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -19,7 +17,6 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
"""Get the Jabber (XMPP) notification service."""
|
"""Get the Jabber (XMPP) notification service."""
|
||||||
|
|
||||||
if not validate_config({DOMAIN: config},
|
if not validate_config({DOMAIN: config},
|
||||||
{DOMAIN: ['sender', 'password', 'recipient']},
|
{DOMAIN: ['sender', 'password', 'recipient']},
|
||||||
_LOGGER):
|
_LOGGER):
|
||||||
|
@ -32,16 +29,16 @@ def get_service(hass, config):
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class XmppNotificationService(BaseNotificationService):
|
class XmppNotificationService(BaseNotificationService):
|
||||||
""" Implements notification service for Jabber (XMPP). """
|
"""Implement the notification service for Jabber (XMPP)."""
|
||||||
|
|
||||||
def __init__(self, sender, password, recipient):
|
def __init__(self, sender, password, recipient):
|
||||||
|
"""Initialize the service."""
|
||||||
self._sender = sender
|
self._sender = sender
|
||||||
self._password = password
|
self._password = password
|
||||||
self._recipient = recipient
|
self._recipient = recipient
|
||||||
|
|
||||||
def send_message(self, message="", **kwargs):
|
def send_message(self, message="", **kwargs):
|
||||||
"""Send a message to a user."""
|
"""Send a message to a user."""
|
||||||
|
|
||||||
title = kwargs.get(ATTR_TITLE)
|
title = kwargs.get(ATTR_TITLE)
|
||||||
data = "{}: {}".format(title, message) if title else message
|
data = "{}: {}".format(title, message) if title else message
|
||||||
|
|
||||||
|
@ -57,6 +54,7 @@ def send_message(sender, password, recipient, message):
|
||||||
"""Service for sending Jabber (XMPP) messages."""
|
"""Service for sending Jabber (XMPP) messages."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
"""Initialize the Jabber Bot."""
|
||||||
super(SendNotificationBot, self).__init__(sender, password)
|
super(SendNotificationBot, self).__init__(sender, password)
|
||||||
|
|
||||||
logging.basicConfig(level=logging.ERROR)
|
logging.basicConfig(level=logging.ERROR)
|
||||||
|
@ -69,7 +67,7 @@ def send_message(sender, password, recipient, message):
|
||||||
self.process()
|
self.process()
|
||||||
|
|
||||||
def start(self, event):
|
def start(self, event):
|
||||||
""" Starts the communication and sends the message. """
|
"""Start the communication and sends the message."""
|
||||||
self.send_presence()
|
self.send_presence()
|
||||||
self.get_roster()
|
self.get_roster()
|
||||||
self.send_message(mto=recipient, mbody=message, mtype='chat')
|
self.send_message(mto=recipient, mbody=message, mtype='chat')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue