1 """Prowl notification service."""
3 from __future__
import annotations
6 from http
import HTTPStatus
9 import voluptuous
as vol
15 PLATFORM_SCHEMA
as NOTIFY_PLATFORM_SCHEMA,
16 BaseNotificationService,
24 _LOGGER = logging.getLogger(__name__)
25 _RESOURCE =
"https://api.prowlapp.com/publicapi/"
27 PLATFORM_SCHEMA = NOTIFY_PLATFORM_SCHEMA.extend({vol.Required(CONF_API_KEY): cv.string})
33 discovery_info: DiscoveryInfoType |
None =
None,
34 ) -> ProwlNotificationService:
35 """Get the Prowl notification service."""
40 """Implement the notification service for Prowl."""
43 """Initialize the service."""
48 """Send the message to the user."""
51 url = f
"{_RESOURCE}add"
52 data = kwargs.get(ATTR_DATA)
55 "application":
"Home-Assistant",
56 "event": kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT),
57 "description": message,
58 "priority": data[
"priority"]
if data
and "priority" in data
else 0,
60 if data
and data.get(
"url"):
61 payload[
"url"] = data[
"url"]
63 _LOGGER.debug(
"Attempting call Prowl service at %s", url)
67 async
with asyncio.timeout(10):
68 response = await session.post(url, data=payload)
69 result = await response.text()
71 if response.status != HTTPStatus.OK
or "error" in result:
73 "Prowl service returned http status %d, response %s",
78 _LOGGER.error(
"Timeout accessing Prowl at %s", url)
def async_send_message(self, message, **kwargs)
def __init__(self, hass, api_key)
ProwlNotificationService async_get_service(HomeAssistant hass, ConfigType config, DiscoveryInfoType|None discovery_info=None)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)