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 _LOGGER = logging.getLogger(__name__) 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
"""Warn user that GCM API config is deprecated.""" if value: _LOGGER.warning( "Configuring html5_push_notifications via the GCM api" " has been deprecated and will stop working after April 11," " 2019. Use the VAPID configuration instead. For instructions," " see https://www.openpeerpower.io/integrations/html5/" ) return value PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Optional(ATTR_GCM_SENDER_ID): vol.All(cv.string, gcm_api_deprecated), vol.Optional(ATTR_GCM_API_KEY): cv.string, vol.Optional(ATTR_VAPID_PUB_KEY): cv.string, vol.Optional(ATTR_VAPID_PRV_KEY): cv.string, vol.Optional(ATTR_VAPID_EMAIL): cv.string, } ) ATTR_SUBSCRIPTION = "subscription" ATTR_BROWSER = "browser" ATTR_ENDPOINT = "endpoint" ATTR_KEYS = "keys" ATTR_AUTH = "auth" ATTR_P256DH = "p256dh" ATTR_EXPIRATIONTIME = "expirationTime" ATTR_TAG = "tag"
from openpeerpower.components.notify import ( ATTR_DATA, ATTR_MESSAGE, ATTR_TARGET, PLATFORM_SCHEMA, BaseNotificationService, ) from .const import ( CONF_DEFAULT_CONVERSATIONS, DOMAIN, SERVICE_SEND_MESSAGE, TARGETS_SCHEMA, ) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( {vol.Required(CONF_DEFAULT_CONVERSATIONS): [TARGETS_SCHEMA]}) def get_service(opp, config, discovery_info=None): """Get the Hangouts notification service.""" return HangoutsNotificationService(config.get(CONF_DEFAULT_CONVERSATIONS)) class HangoutsNotificationService(BaseNotificationService): """Send Notifications to Hangouts conversations.""" def __init__(self, default_conversations): """Set up the notification service.""" self._default_conversations = default_conversations def send_message(self, message="", **kwargs): """Send the message to the Google Hangouts server."""
"""Support for SMS notification services.""" import logging import gammu # pylint: disable=import-error 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, SMS_GATEWAY _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.""" if SMS_GATEWAY not in opp.data[DOMAIN]: _LOGGER.error("SMS gateway not found, cannot initialize service") return gateway = opp.data[DOMAIN][SMS_GATEWAY] if discovery_info is None: number = config[CONF_RECIPIENT] else:
BaseNotificationService, ) import openpeerpower.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) CONF_SENDER_NR = "number" CONF_RECP_NR = "recipients" CONF_SIGNAL_CLI_REST_API = "url" ATTR_FILENAME = "attachment" ATTR_FILENAMES = "attachments" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_SENDER_NR): cv.string, vol.Required(CONF_SIGNAL_CLI_REST_API): cv.string, vol.Required(CONF_RECP_NR): vol.All(cv.ensure_list, [cv.string]), } ) def get_service(opp, config, discovery_info=None): """Get the SignalMessenger notification service.""" sender_nr = config[CONF_SENDER_NR] recp_nrs = config[CONF_RECP_NR] signal_cli_rest_api_url = config[CONF_SIGNAL_CLI_REST_API] signal_cli_rest_api = SignalCliRestApi(signal_cli_rest_api_url, sender_nr) return SignalNotificationService(recp_nrs, signal_cli_rest_api)
from openpeerpower.components.notify import ( ATTR_TITLE, ATTR_TITLE_DEFAULT, PLATFORM_SCHEMA, BaseNotificationService, ) from openpeerpower.const import CONF_FILENAME import openpeerpower.helpers.config_validation as cv import openpeerpower.util.dt as dt_util CONF_TIMESTAMP = "timestamp" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_FILENAME): cv.string, vol.Optional(CONF_TIMESTAMP, default=False): cv.boolean, }) def get_service(opp, config, discovery_info=None): """Get the file notification service.""" filename = config[CONF_FILENAME] timestamp = config[CONF_TIMESTAMP] return FileNotificationService(opp, filename, timestamp) class FileNotificationService(BaseNotificationService): """Implement the notification service for the File service.""" def __init__(self, opp, filename, add_timestamp):
import openpeerpower.helpers.config_validation as cv from . import ATTR_ENTITY_ID, ATTR_LANGUAGE, ATTR_MESSAGE, DOMAIN CONF_MEDIA_PLAYER = "media_player" CONF_TTS_SERVICE = "tts_service" # mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs _LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_NAME): cv.string, vol.Required(CONF_TTS_SERVICE): cv.entity_id, vol.Required(CONF_MEDIA_PLAYER): cv.entity_id, vol.Optional(ATTR_LANGUAGE): cv.string, }) async def async_get_service(opp, config, discovery_info=None): """Return the notify service.""" return TTSNotificationService(config) class TTSNotificationService(BaseNotificationService): """The TTS Notification Service.""" def __init__(self, config):
import voluptuous as vol from openpeerpower.components.notify import ( ATTR_DATA, ATTR_MESSAGE, ATTR_TARGET, PLATFORM_SCHEMA, BaseNotificationService, ) import openpeerpower.helpers.config_validation as cv from .const import DOMAIN, SERVICE_SEND_MESSAGE CONF_DEFAULT_ROOM = "default_room" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( {vol.Required(CONF_DEFAULT_ROOM): cv.string}) def get_service(opp, config, discovery_info=None): """Get the Matrix notification service.""" return MatrixNotificationService(config[CONF_DEFAULT_ROOM]) class MatrixNotificationService(BaseNotificationService): """Send notifications to a Matrix room.""" def __init__(self, default_room): """Set up the Matrix notification service.""" self._default_room = default_room def send_message(self, message="", **kwargs): """Send the message to the Matrix server."""
"""Flock platform for notify component.""" import asyncio import logging import async_timeout import voluptuous as vol from openpeerpower.components.notify import PLATFORM_SCHEMA, BaseNotificationService from openpeerpower.const import CONF_ACCESS_TOKEN, HTTP_OK from openpeerpower.helpers.aiohttp_client import async_get_clientsession import openpeerpower.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) _RESOURCE = "https://api.flock.com/hooks/sendMessage/" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( {vol.Required(CONF_ACCESS_TOKEN): cv.string}) async def async_get_service(opp, config, discovery_info=None): """Get the Flock notification service.""" access_token = config.get(CONF_ACCESS_TOKEN) url = f"{_RESOURCE}{access_token}" session = async_get_clientsession(opp) return FlockNotificationService(url, session) class FlockNotificationService(BaseNotificationService): """Implement the notification service for Flock.""" def __init__(self, url, session): """Initialize the Flock notification service."""