) from openpeerpower.helpers.aiohttp_client import async_get_clientsession import openpeerpower.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) DEFAULT_PORT = 8080 DEFAULT_PROXY_SSL = False DEFAULT_TIMEOUT = 5 PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_HOST): cv.string, vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port, vol.Optional(CONF_PROXY_SSL, default=DEFAULT_PROXY_SSL): cv.boolean, vol.Inclusive(CONF_USERNAME, "auth"): cv.string, vol.Inclusive(CONF_PASSWORD, "auth"): cv.string, }) ATTR_DISPLAYTIME = "displaytime" async def async_get_service(opp, config, discovery_info=None): """Return the notify service.""" url = f"{config.get(CONF_HOST)}:{config.get(CONF_PORT)}" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD)
from openpeerpower.components.notify import ( ATTR_DATA, ATTR_TITLE, ATTR_TITLE_DEFAULT, PLATFORM_SCHEMA, BaseNotificationService, ) from openpeerpower.const import CONF_URL import openpeerpower.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) ATTR_FILE_URL = "image_url" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_URL): cv.url}) def get_service(opp, config, discovery_info=None): """Get the Microsoft Teams notification service.""" webhook_url = config.get(CONF_URL) try: return MSTeamsNotificationService(webhook_url) except RuntimeError as err: _LOGGER.exception("Error in creating a new Microsoft Teams message: %s", err) return None class MSTeamsNotificationService(BaseNotificationService):
PLATFORM_SCHEMA, BaseNotificationService, ) from openpeerpower.const import CONF_TOKEN import openpeerpower.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) ATTR_EMBED = "embed" ATTR_EMBED_AUTHOR = "author" ATTR_EMBED_FIELDS = "fields" ATTR_EMBED_FOOTER = "footer" ATTR_EMBED_THUMBNAIL = "thumbnail" ATTR_IMAGES = "images" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_TOKEN): cv.string}) def get_service(opp, config, discovery_info=None): """Get the Discord notification service.""" token = config[CONF_TOKEN] return DiscordNotificationService(opp, token) class DiscordNotificationService(BaseNotificationService): """Implement the notification service for Discord.""" def __init__(self, opp, token): """Initialize the service.""" self.token = token self.opp = opp
from . import DOMAIN as TELEGRAM_DOMAIN, PLATFORMS _LOGGER = logging.getLogger(__name__) DOMAIN = "telegram_bot" ATTR_KEYBOARD = "keyboard" ATTR_INLINE_KEYBOARD = "inline_keyboard" ATTR_PHOTO = "photo" ATTR_VIDEO = "video" ATTR_VOICE = "voice" ATTR_DOCUMENT = "document" CONF_CHAT_ID = "chat_id" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( {vol.Required(CONF_CHAT_ID): vol.Coerce(int)}) def get_service(opp, config, discovery_info=None): """Get the Telegram notification service.""" setup_reload_service(opp, TELEGRAM_DOMAIN, PLATFORMS) chat_id = config.get(CONF_CHAT_ID) return TelegramNotificationService(opp, chat_id) class TelegramNotificationService(BaseNotificationService): """Implement the notification service for Telegram.""" def __init__(self, opp, chat_id): """Initialize the service.""" self._chat_id = chat_id
PLATFORM_SCHEMA, BaseNotificationService, ) from openpeerpower.const import CONF_EVENT, CONF_PASSWORD import openpeerpower.helpers.config_validation as cv ATTR_ENCRYPTED = "encrypted" CONF_DEVICE_KEY = "device_key" CONF_SALT = "salt" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_DEVICE_KEY): cv.string, vol.Optional(CONF_EVENT): cv.string, vol.Inclusive(CONF_PASSWORD, ATTR_ENCRYPTED): cv.string, vol.Inclusive(CONF_SALT, ATTR_ENCRYPTED): cv.string, }) def get_service(opp, config, discovery_info=None): """Get the Simplepush notification service.""" return SimplePushNotificationService(config) class SimplePushNotificationService(BaseNotificationService): """Implementation of the notification service for Simplepush.""" def __init__(self, config): """Initialize the Simplepush notification service."""
from .const import ( ATTR_ADDRESS, ATTR_CHANNEL, ATTR_INTERFACE, ATTR_PARAM, ATTR_VALUE, DOMAIN, SERVICE_SET_DEVICE_VALUE, ) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(ATTR_ADDRESS): vol.All(cv.string, vol.Upper), vol.Required(ATTR_CHANNEL): vol.Coerce(int), vol.Required(ATTR_PARAM): vol.All(cv.string, vol.Upper), vol.Required(ATTR_VALUE): cv.match_all, vol.Optional(ATTR_INTERFACE): cv.string, } ) def get_service(opp, config, discovery_info=None): """Get the Homematic notification service.""" data = { ATTR_ADDRESS: config[ATTR_ADDRESS], ATTR_CHANNEL: config[ATTR_CHANNEL], ATTR_PARAM: config[ATTR_PARAM], ATTR_VALUE: config[ATTR_VALUE], } if ATTR_INTERFACE in config:
ATTR_DATA, PLATFORM_SCHEMA, BaseNotificationService, ) from openpeerpower.const import CONF_HOST, CONF_PORT import openpeerpower.helpers.config_validation as cv ATTR_METHOD = "method" ATTR_METHOD_DEFAULT = "speak" ATTR_METHOD_ALLOWED = ["speak", "alarm"] DEFAULT_PORT = 1035 PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_HOST): cv.string, vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port, }) _LOGGER = logging.getLogger(__name__) def get_service(opp, config, discovery_info=None): """Get the Lannouncer notification service.""" host = config.get(CONF_HOST) port = config.get(CONF_PORT) return LannouncerNotificationService(opp, host, port) class LannouncerNotificationService(BaseNotificationService):
DEFAULT_PORT = 587 DEFAULT_TIMEOUT = 5 DEFAULT_DEBUG = False DEFAULT_ENCRYPTION = "starttls" ENCRYPTION_OPTIONS = ["tls", "starttls", "none"] # pylint: disable=no-value-for-parameter PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_RECIPIENT): vol.All(cv.ensure_list, [vol.Email()]), vol.Required(CONF_SENDER): vol.Email(), vol.Optional(CONF_SERVER, default=DEFAULT_HOST): cv.string, vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port, vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int, vol.Optional(CONF_ENCRYPTION, default=DEFAULT_ENCRYPTION): vol.In( ENCRYPTION_OPTIONS ), vol.Optional(CONF_USERNAME): cv.string, vol.Optional(CONF_PASSWORD): cv.string, vol.Optional(CONF_SENDER_NAME): cv.string, vol.Optional(CONF_DEBUG, default=DEFAULT_DEBUG): cv.boolean, } ) def get_service(opp, config, discovery_info=None): """Get the mail notification service.""" setup_reload_service(opp, DOMAIN, PLATFORMS) mail_service = MailNotificationService( config.get(CONF_SERVER), config.get(CONF_PORT),
import openpeerpower.helpers.config_validation as cv CONF_CONNECTION_STRING = "connection_string" CONF_QUEUE_NAME = "queue" CONF_TOPIC_NAME = "topic" ATTR_ASB_MESSAGE = "message" ATTR_ASB_TITLE = "title" ATTR_ASB_TARGET = "target" PLATFORM_SCHEMA = vol.All( cv.has_at_least_one_key(CONF_QUEUE_NAME, CONF_TOPIC_NAME), PLATFORM_SCHEMA.extend({ vol.Required(CONF_CONNECTION_STRING): cv.string, vol.Exclusive(CONF_QUEUE_NAME, "output", "Can only send to a queue or a topic."): cv.string, vol.Exclusive(CONF_TOPIC_NAME, "output", "Can only send to a queue or a topic."): cv.string, }), ) _LOGGER = logging.getLogger(__name__) def get_service(opp, config, discovery_info=None): """Get the notification service.""" connection_string = config[CONF_CONNECTION_STRING] queue_name = config.get(CONF_QUEUE_NAME) topic_name = config.get(CONF_TOPIC_NAME) # Library can do synchronous IO when creating the clients.
ATTR_ATTACHMENT = "attachment" ATTR_URL = "url" ATTR_URL_TITLE = "url_title" ATTR_PRIORITY = "priority" ATTR_RETRY = "retry" ATTR_SOUND = "sound" ATTR_HTML = "html" ATTR_CALLBACK_URL = "callback_url" ATTR_EXPIRE = "expire" ATTR_TIMESTAMP = "timestamp" CONF_USER_KEY = "user_key" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_USER_KEY): cv.string, vol.Required(CONF_API_KEY): cv.string }) def get_service(opp, config, discovery_info=None): """Get the Pushover notification service.""" return PushoverNotificationService(opp, config[CONF_USER_KEY], config[CONF_API_KEY]) class PushoverNotificationService(BaseNotificationService): """Implement the notification service for Pushover.""" def __init__(self, opp, user_key, api_token): """Initialize the service.""" self._opp = opp self._user_key = user_key
CONF_TLS = "tls" CONF_VERIFY = "verify" DEFAULT_CONTENT_TYPE = "application/octet-stream" DEFAULT_RESOURCE = "openpeerpower" XEP_0363_TIMEOUT = 10 PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_SENDER): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Required(CONF_RECIPIENT): vol.All(cv.ensure_list, [cv.string]), vol.Optional(CONF_RESOURCE, default=DEFAULT_RESOURCE): cv.string, vol.Optional(CONF_ROOM, default=""): cv.string, vol.Optional(CONF_TLS, default=True): cv.boolean, vol.Optional(CONF_VERIFY, default=True): cv.boolean, }) async def async_get_service(opp, config, discovery_info=None): """Get the Jabber (XMPP) notification service.""" return XmppNotificationService( config.get(CONF_SENDER), config.get(CONF_RESOURCE), config.get(CONF_PASSWORD),
"""Support for SMS notification services.""" import logging import gammu # pylint: disable=import-error, no-member import voluptuous as vol from openpeerpower.components.notify import PLATFORM_SCHEMA, BaseNotificationService from openpeerpower.const import CONF_NAME, CONF_RECIPIENT import openpeerpower.helpers.config_validation as cv from .const import DOMAIN _LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_RECIPIENT): cv.string, vol.Optional(CONF_NAME): cv.string }) def get_service(opp, config, discovery_info=None): """Get the SMS notification service.""" gateway = opp.data[DOMAIN] number = config[CONF_RECIPIENT] return SMSNotificationService(gateway, number) class SMSNotificationService(BaseNotificationService): """Implement the notification service for SMS.""" def __init__(self, gateway, number): """Initialize the service.""" self.gateway = gateway
SYSLOG_PRIORITY = { 5: "LOG_EMERG", 4: "LOG_ALERT", 3: "LOG_CRIT", 2: "LOG_ERR", 1: "LOG_WARNING", 0: "LOG_NOTICE", -1: "LOG_INFO", -2: "LOG_DEBUG", } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_FACILITY, default="syslog"): vol.In(SYSLOG_FACILITY.keys()), vol.Optional(CONF_OPTION, default="pid"): vol.In(SYSLOG_OPTION.keys()), vol.Optional(CONF_PRIORITY, default=-1): vol.In(SYSLOG_PRIORITY.keys()), }) def get_service(opp, config, discovery_info=None): """Get the syslog notification service.""" facility = getattr(syslog, SYSLOG_FACILITY[config.get(CONF_FACILITY)]) option = getattr(syslog, SYSLOG_OPTION[config.get(CONF_OPTION)]) priority = getattr(syslog, SYSLOG_PRIORITY[config.get(CONF_PRIORITY)]) return SyslogNotificationService(facility, option, priority)
ATTR_MESSAGE, DOMAIN, PLATFORM_SCHEMA, BaseNotificationService, ) from openpeerpower.const import ATTR_SERVICE import openpeerpower.helpers.config_validation as cv # mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs CONF_SERVICES = "services" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_SERVICES): vol.All( cv.ensure_list, [{vol.Required(ATTR_SERVICE): cv.slug, vol.Optional(ATTR_DATA): dict}], ) } ) def update(input_dict, update_source): """Deep update a dictionary. Async friendly. """ for key, val in update_source.items(): if isinstance(val, Mapping): recurse = update(input_dict.get(key, {}), val) input_dict[key] = recurse else:
import voluptuous as vol from openpeerpower.components.notify import PLATFORM_SCHEMA, BaseNotificationService from openpeerpower.const import CONF_COMMAND, CONF_NAME import openpeerpower.helpers.config_validation as cv from openpeerpower.util.process import kill_subprocess from .const import CONF_COMMAND_TIMEOUT, DEFAULT_TIMEOUT _LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_COMMAND): cv.string, vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_COMMAND_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int, }) def get_service(opp, config, discovery_info=None): """Get the Command Line notification service.""" command = config[CONF_COMMAND] timeout = config[CONF_COMMAND_TIMEOUT] return CommandLineNotificationService(command, timeout) class CommandLineNotificationService(BaseNotificationService): """Implement the notification service for the Command Line service."""
DEFAULT_MESSAGE_PARAM_NAME = "message" DEFAULT_METHOD = "GET" DEFAULT_VERIFY_SSL = True PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_RESOURCE): cv.url, vol.Optional( CONF_MESSAGE_PARAMETER_NAME, default=DEFAULT_MESSAGE_PARAM_NAME ): cv.string, vol.Optional(CONF_METHOD, default=DEFAULT_METHOD): vol.In( ["POST", "GET", "POST_JSON"] ), vol.Optional(CONF_HEADERS): vol.Schema({cv.string: cv.string}), vol.Optional(CONF_PARAMS): vol.Schema({cv.string: cv.string}), vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_TARGET_PARAMETER_NAME): cv.string, vol.Optional(CONF_TITLE_PARAMETER_NAME): cv.string, vol.Optional(CONF_DATA): vol.All(dict, cv.template_complex), vol.Optional(CONF_DATA_TEMPLATE): vol.All(dict, cv.template_complex), vol.Optional(CONF_AUTHENTICATION): vol.In( [HTTP_BASIC_AUTHENTICATION, HTTP_DIGEST_AUTHENTICATION] ), vol.Optional(CONF_PASSWORD): cv.string, vol.Optional(CONF_USERNAME): cv.string, vol.Optional(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL): cv.boolean, } ) _LOGGER = logging.getLogger(__name__)
) from openpeerpower.const import ( CONF_PASSWORD, CONF_ROOM, CONF_URL, CONF_USERNAME, HTTP_OK, ) import openpeerpower.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) # pylint: disable=no-value-for-parameter PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_URL): vol.Url(), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Required(CONF_ROOM): cv.string, }) def get_service(opp, config, discovery_info=None): """Return the notify service.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) url = config.get(CONF_URL) room = config.get(CONF_ROOM) try: return RocketChatNotificationService(url, username, password, room)
from openpeerpower.components.notify import PLATFORM_SCHEMA, BaseNotificationService from openpeerpower.const import CONF_ACCESS_TOKEN, CONF_CLIENT_ID, CONF_CLIENT_SECRET import openpeerpower.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) CONF_BASE_URL = "base_url" DEFAULT_URL = "https://mastodon.social" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_ACCESS_TOKEN): cv.string, vol.Required(CONF_CLIENT_ID): cv.string, vol.Required(CONF_CLIENT_SECRET): cv.string, vol.Optional(CONF_BASE_URL, default=DEFAULT_URL): cv.string, }) def get_service(opp, config, discovery_info=None): """Get the Mastodon notification service.""" client_id = config.get(CONF_CLIENT_ID) client_secret = config.get(CONF_CLIENT_SECRET) access_token = config.get(CONF_ACCESS_TOKEN) base_url = config.get(CONF_BASE_URL) try: mastodon = Mastodon(
import voluptuous as vol from openpeerpower.components.notify import ( ATTR_TARGET, PLATFORM_SCHEMA, BaseNotificationService, ) from openpeerpower.components.twilio import DATA_TWILIO import openpeerpower.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) CONF_FROM_NUMBER = "from_number" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_FROM_NUMBER): vol.All(cv.string, vol.Match(r"^\+?[1-9]\d{1,14}$")) }) def get_service(opp, config, discovery_info=None): """Get the Twilio Call notification service.""" return TwilioCallNotificationService(opp.data[DATA_TWILIO], config[CONF_FROM_NUMBER]) class TwilioCallNotificationService(BaseNotificationService): """Implement the notification service for the Twilio Call service.""" def __init__(self, twilio_client, from_number): """Initialize the service.""" self.client = twilio_client self.from_number = from_number
_LOGGER = logging.getLogger(__name__) AVAILABLE_PRIORITIES = ["info", "warning", "critical"] AVAILABLE_ICON_TYPES = ["none", "info", "alert"] CONF_CYCLES = "cycles" CONF_LIFETIME = "lifetime" CONF_PRIORITY = "priority" CONF_ICON_TYPE = "icon_type" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_ICON, default="a7956"): cv.string, vol.Optional(CONF_LIFETIME, default=10): cv.positive_int, vol.Optional(CONF_CYCLES, default=1): cv.positive_int, vol.Optional(CONF_PRIORITY, default="warning"): vol.In(AVAILABLE_PRIORITIES), vol.Optional(CONF_ICON_TYPE, default="info"): vol.In(AVAILABLE_ICON_TYPES), }) def get_service(opp, config, discovery_info=None): """Get the LaMetric notification service.""" hlmn = opp.data.get(LAMETRIC_DOMAIN) return LaMetricNotificationService( hlmn, config[CONF_ICON], config[CONF_LIFETIME] * 1000, config[CONF_CYCLES],
from openpeerpower.helpers.event import track_state_change from .const import DOMAIN APNS_DEVICES = "apns.yaml" CONF_CERTFILE = "cert_file" CONF_TOPIC = "topic" CONF_SANDBOX = "sandbox" ATTR_PUSH_ID = "push_id" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_PLATFORM): "apns", vol.Required(CONF_NAME): cv.string, vol.Required(CONF_CERTFILE): cv.isfile, vol.Required(CONF_TOPIC): cv.string, vol.Optional(CONF_SANDBOX, default=False): cv.boolean, } ) REGISTER_SERVICE_SCHEMA = vol.Schema( {vol.Required(ATTR_PUSH_ID): cv.string, vol.Optional(ATTR_NAME): cv.string} ) def get_service(opp, config, discovery_info=None): """Return push service.""" name = config[CONF_NAME] cert_file = config[CONF_CERTFILE] topic = config[CONF_TOPIC]
"indigo": "#303F9F", "green": "#4CAF50", "red": "#F44336", "cyan": "#00BCD4", "teal": "#009688", "amber": "#FFC107", "pink": "#E91E63", } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_HOST): cv.string, vol.Optional(CONF_DURATION, default=DEFAULT_DURATION): vol.Coerce(int), vol.Optional(CONF_FONTSIZE, default=DEFAULT_FONTSIZE): vol.In(FONTSIZES.keys()), vol.Optional(CONF_POSITION, default=DEFAULT_POSITION): vol.In(POSITIONS.keys()), vol.Optional(CONF_TRANSPARENCY, default=DEFAULT_TRANSPARENCY): vol.In( TRANSPARENCIES.keys() ), vol.Optional(CONF_COLOR, default=DEFAULT_COLOR): vol.In(COLORS.keys()), vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): vol.Coerce(int), vol.Optional(CONF_INTERRUPT, default=DEFAULT_INTERRUPT): cv.boolean, } ) def get_service(opp, config, discovery_info=None): """Get the Notifications for Android TV notification service.""" remoteip = config.get(CONF_HOST) duration = config.get(CONF_DURATION) fontsize = config.get(CONF_FONTSIZE) position = config.get(CONF_POSITION) transparency = config.get(CONF_TRANSPARENCY)
PLATFORM_SCHEMA, BaseNotificationService, ) from openpeerpower.const import CONF_API_KEY, CONF_DEVICE_ID import openpeerpower.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) CONF_DEVICE_IDS = "device_ids" CONF_DEVICE_NAMES = "device_names" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_API_KEY): cv.string, vol.Optional(CONF_DEVICE_ID): cv.string, vol.Optional(CONF_DEVICE_IDS): cv.string, vol.Optional(CONF_DEVICE_NAMES): cv.string, }) def get_service(opp, config, discovery_info=None): """Get the Join notification service.""" api_key = config.get(CONF_API_KEY) device_id = config.get(CONF_DEVICE_ID) device_ids = config.get(CONF_DEVICE_IDS) device_names = config.get(CONF_DEVICE_NAMES) if api_key and not get_devices(api_key): _LOGGER.error("Error connecting to Join. Check the API key") return False
ATTR_TARGET, ATTR_TITLE, ATTR_TITLE_DEFAULT, PLATFORM_SCHEMA, BaseNotificationService, ) from openpeerpower.const import CONF_URL import openpeerpower.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) CONF_FILE = "config" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Optional(CONF_URL): vol.All(cv.ensure_list, [str]), vol.Optional(CONF_FILE): cv.string, } ) def get_service(opp, config, discovery_info=None): """Get the Apprise notification service.""" # Create our Apprise Instance (reference our asset) a_obj = apprise.Apprise() if config.get(CONF_FILE): # Sourced from a Configuration File a_config = apprise.AppriseConfig() if not a_config.add(config[CONF_FILE]): _LOGGER.error("Invalid Apprise config url provided") return None
ATTR_URLTITLE = "urltitle" ATTR_TIME2LIVE = "time2live" ATTR_PRIORITY = "priority" ATTR_RETRY = "retry" ATTR_EXPIRE = "expire" ATTR_ANSWER = "answer" ATTR_PICTURE1 = "picture1" # Attributes contained in picture1 ATTR_PICTURE1_URL = "url" ATTR_PICTURE1_PATH = "path" ATTR_PICTURE1_USERNAME = "******" ATTR_PICTURE1_PASSWORD = "******" ATTR_PICTURE1_AUTH = "auth" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_DEVICE_KEY): cv.string}) def get_service(opp, config, discovery_info=None): """Get the Pushsafer.com notification service.""" return PushsaferNotificationService( config.get(CONF_DEVICE_KEY), opp.config.is_allowed_path ) class PushsaferNotificationService(BaseNotificationService): """Implementation of the notification service for Pushsafer.com.""" def __init__(self, private_key, is_allowed_path): """Initialize the service.""" self._private_key = private_key
) from openpeerpower.const import CONF_API_KEY, CONF_DOMAIN, CONF_RECIPIENT, CONF_SENDER from . import CONF_SANDBOX, DOMAIN as MAILGUN_DOMAIN _LOGGER = logging.getLogger(__name__) # Images to attach to notification ATTR_IMAGES = "images" DEFAULT_SANDBOX = False # pylint: disable=no-value-for-parameter PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_RECIPIENT): vol.Email(), vol.Optional(CONF_SENDER): vol.Email() }) def get_service(opp, config, discovery_info=None): """Get the Mailgun notification service.""" data = opp.data[MAILGUN_DOMAIN] mailgun_service = MailgunNotificationService( data.get(CONF_DOMAIN), data.get(CONF_SANDBOX), data.get(CONF_API_KEY), config.get(CONF_SENDER), config.get(CONF_RECIPIENT), ) if mailgun_service.connection_is_valid():
_LOGGER = logging.getLogger(__name__) CONF_APP_NAME = "app_name" CONF_APP_ICON = "app_icon" CONF_HOSTNAME = "hostname" DEFAULT_APP_NAME = "OpenPeerPower" DEFAULT_HOST = "localhost" DEFAULT_PORT = 23053 PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_APP_NAME, default=DEFAULT_APP_NAME): cv.string, vol.Optional(CONF_APP_ICON): vol.Url, vol.Optional(CONF_HOSTNAME, default=DEFAULT_HOST): cv.string, vol.Optional(CONF_PASSWORD): cv.string, vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port, }) def get_service(opp, config, discovery_info=None): """Get the GNTP notification service.""" _LOGGER.warning( "The GNTP (Growl) integration has been deprecated and is going to be " "removed in Open Peer Power Core 2021.6. The Growl project has retired" ) logging.getLogger("gntp").setLevel(logging.ERROR)
import requests import voluptuous as vol from openpeerpower.components.notify import ( ATTR_DATA, PLATFORM_SCHEMA, BaseNotificationService, ) from openpeerpower.const import CONF_RESOURCE, CONF_VERIFY_SSL, HTTP_CREATED, HTTP_OK import openpeerpower.helpers.config_validation as cv ATTR_FILE_URL = "file_url" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_RESOURCE): cv.url, vol.Optional(CONF_VERIFY_SSL, default=True): cv.boolean, }) _LOGGER = logging.getLogger(__name__) def get_service(opp, config, discovery_info=None): """Get the Synology Chat notification service.""" resource = config.get(CONF_RESOURCE) verify_ssl = config.get(CONF_VERIFY_SSL) return SynologyChatNotificationService(resource, verify_ssl) class SynologyChatNotificationService(BaseNotificationService):
PLATFORM_SCHEMA, BaseNotificationService, ) from openpeerpower.components.twilio import DATA_TWILIO import openpeerpower.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) CONF_FROM_NUMBER = "from_number" ATTR_MEDIAURL = "media_url" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_FROM_NUMBER): vol.All( cv.string, vol.Match(r"^\+?[1-9]\d{1,14}$|" r"^(?=.{1,11}$)[a-zA-Z0-9\s]*" r"[a-zA-Z][a-zA-Z0-9\s]*$" r"^(?:[a-zA-Z]+)\:?\+?[1-9]\d{1,14}$|"), ) }) def get_service(opp, config, discovery_info=None): """Get the Twilio SMS notification service.""" return TwilioSMSNotificationService(opp.data[DATA_TWILIO], config[CONF_FROM_NUMBER]) class TwilioSMSNotificationService(BaseNotificationService): """Implement the notification service for the Twilio SMS service.""" def __init__(self, twilio_client, from_number):
from openpeerpower.helpers.event import async_track_point_in_time _LOGGER = logging.getLogger(__name__) CONF_CONSUMER_KEY = "consumer_key" CONF_CONSUMER_SECRET = "consumer_secret" CONF_ACCESS_TOKEN_SECRET = "access_token_secret" ATTR_MEDIA = "media" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_ACCESS_TOKEN): cv.string, vol.Required(CONF_ACCESS_TOKEN_SECRET): cv.string, vol.Required(CONF_CONSUMER_KEY): cv.string, vol.Required(CONF_CONSUMER_SECRET): cv.string, vol.Optional(CONF_USERNAME): cv.string, }) def get_service(opp, config, discovery_info=None): """Get the Twitter notification service.""" return TwitterNotificationService( opp, config[CONF_CONSUMER_KEY], config[CONF_CONSUMER_SECRET], config[CONF_ACCESS_TOKEN], config[CONF_ACCESS_TOKEN_SECRET],