1 """Pushover platform for notify component."""
3 from __future__
import annotations
8 from pushover_complete
import BadAPIRequestError, PushoverAPI
15 BaseNotificationService,
36 _LOGGER = logging.getLogger(__name__)
42 discovery_info: DiscoveryInfoType |
None =
None,
43 ) -> PushoverNotificationService |
None:
44 """Get the Pushover notification service."""
45 if discovery_info
is None:
47 pushover_api: PushoverAPI = hass.data[DOMAIN][discovery_info[
"entry_id"]]
49 hass, pushover_api, discovery_info[CONF_USER_KEY]
54 """Implement the notification service for Pushover."""
57 self, hass: HomeAssistant, pushover: PushoverAPI, user_key: str
59 """Initialize the service."""
65 """Send a message to a user."""
68 title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
69 data =
dict(kwargs.get(ATTR_DATA)
or {})
70 url = data.get(ATTR_URL)
71 url_title = data.get(ATTR_URL_TITLE)
72 priority = data.get(ATTR_PRIORITY)
73 retry = data.get(ATTR_RETRY)
74 expire = data.get(ATTR_EXPIRE)
75 callback_url = data.get(ATTR_CALLBACK_URL)
76 timestamp = data.get(ATTR_TIMESTAMP)
77 sound = data.get(ATTR_SOUND)
78 html = 1
if data.get(ATTR_HTML,
False)
else 0
81 if (image := data.get(ATTR_ATTACHMENT))
is not None:
83 if self.
_hass_hass.config.is_allowed_path(data[ATTR_ATTACHMENT]):
87 file_handle =
open(data[ATTR_ATTACHMENT],
"rb")
90 except OSError
as ex_val:
95 _LOGGER.error(
"Path is not whitelisted")
103 ",".join(kwargs.get(ATTR_TARGET, [])),
116 except BadAPIRequestError
as err:
None __init__(self, HomeAssistant hass, PushoverAPI pushover, str user_key)
None send_message(self, str message="", **Any kwargs)
None open(self, **Any kwargs)
PushoverNotificationService|None async_get_service(HomeAssistant hass, ConfigType config, DiscoveryInfoType|None discovery_info=None)