1 """Apprise platform for notify component."""
3 from __future__
import annotations
9 import voluptuous
as vol
15 PLATFORM_SCHEMA
as NOTIFY_PLATFORM_SCHEMA,
16 BaseNotificationService,
23 _LOGGER = logging.getLogger(__name__)
27 PLATFORM_SCHEMA = NOTIFY_PLATFORM_SCHEMA.extend(
29 vol.Optional(CONF_URL): vol.All(cv.ensure_list, [str]),
30 vol.Optional(CONF_FILE): cv.string,
38 discovery_info: DiscoveryInfoType |
None =
None,
39 ) -> AppriseNotificationService |
None:
40 """Get the Apprise notification service."""
42 a_obj = apprise.Apprise()
44 if config.get(CONF_FILE):
46 a_config = apprise.AppriseConfig()
47 if not a_config.add(config[CONF_FILE]):
48 _LOGGER.error(
"Invalid Apprise config url provided")
51 if not a_obj.add(a_config):
52 _LOGGER.error(
"Invalid Apprise config url provided")
56 if urls := config.get(CONF_URL):
58 if not a_obj.add(entry):
59 _LOGGER.error(
"One or more specified Apprise URL(s) are invalid")
66 """Implement the notification service for Apprise."""
68 def __init__(self, a_obj: apprise.Apprise) ->
None:
69 """Initialize the service."""
73 """Send a message to a specified target.
75 If no target/tags are specified, then services are notified as is
76 However, if any tags are specified, then they will be applied
77 to the notification causing filtering (if set up that way).
79 targets = kwargs.get(ATTR_TARGET)
80 title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
81 self.
appriseapprise.notify(body=message, title=title, tag=targets)
None __init__(self, apprise.Apprise a_obj)
None send_message(self, str message="", **Any kwargs)
AppriseNotificationService|None get_service(HomeAssistant hass, ConfigType config, DiscoveryInfoType|None discovery_info=None)