Skip to content
Snippets Groups Projects
Commit 1cae6e66 authored by Malte Franken's avatar Malte Franken Committed by cgtobi
Browse files

move imports to top-level (#27630)

parent b7023a96
No related branches found
No related tags found
No related merge requests found
"""Pushover platform for notify component."""
import logging
import requests
import voluptuous as vol
from pushover import InitError, Client, RequestError
from homeassistant.const import CONF_API_KEY
import homeassistant.helpers.config_validation as cv
......@@ -28,8 +30,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def get_service(hass, config, discovery_info=None):
"""Get the Pushover notification service."""
from pushover import InitError
try:
return PushoverNotificationService(
hass, config[CONF_USER_KEY], config[CONF_API_KEY]
......@@ -44,8 +44,6 @@ class PushoverNotificationService(BaseNotificationService):
def __init__(self, hass, user_key, api_token):
"""Initialize the service."""
from pushover import Client
self._hass = hass
self._user_key = user_key
self._api_token = api_token
......@@ -53,8 +51,6 @@ class PushoverNotificationService(BaseNotificationService):
def send_message(self, message="", **kwargs):
"""Send a message to a user."""
from pushover import RequestError
# Make a copy and use empty dict if necessary
data = dict(kwargs.get(ATTR_DATA) or {})
......@@ -65,8 +61,6 @@ class PushoverNotificationService(BaseNotificationService):
# If attachment is a URL, use requests to open it as a stream.
if data[ATTR_ATTACHMENT].startswith("http"):
try:
import requests
response = requests.get(
data[ATTR_ATTACHMENT], stream=True, timeout=5
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment