Move imports to top for pushetta (#29332)
* Move imports to top for pushetta * Make Pushetta.exceptions import lowercase and snakecasepull/29344/head
parent
e9647f8814
commit
078e907178
homeassistant/components/pushetta
|
@ -1,17 +1,17 @@
|
|||
"""Pushetta platform for notify component."""
|
||||
import logging
|
||||
|
||||
from pushetta import Pushetta, exceptions as pushetta_exceptions
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_API_KEY
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
from homeassistant.components.notify import (
|
||||
ATTR_TITLE,
|
||||
ATTR_TITLE_DEFAULT,
|
||||
PLATFORM_SCHEMA,
|
||||
BaseNotificationService,
|
||||
)
|
||||
from homeassistant.const import CONF_API_KEY
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -44,7 +44,6 @@ class PushettaNotificationService(BaseNotificationService):
|
|||
|
||||
def __init__(self, api_key, channel_name, send_test_msg):
|
||||
"""Initialize the service."""
|
||||
from pushetta import Pushetta
|
||||
|
||||
self._api_key = api_key
|
||||
self._channel_name = channel_name
|
||||
|
@ -56,15 +55,14 @@ class PushettaNotificationService(BaseNotificationService):
|
|||
|
||||
def send_message(self, message="", **kwargs):
|
||||
"""Send a message to a user."""
|
||||
from pushetta import exceptions
|
||||
|
||||
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
|
||||
|
||||
try:
|
||||
self.pushetta.pushMessage(self._channel_name, f"{title} {message}")
|
||||
except exceptions.TokenValidationError:
|
||||
except pushetta_exceptions.TokenValidationError:
|
||||
_LOGGER.error("Please check your access token")
|
||||
self.is_valid = False
|
||||
except exceptions.ChannelNotFoundError:
|
||||
except pushetta_exceptions.ChannelNotFoundError:
|
||||
_LOGGER.error("Channel '%s' not found", self._channel_name)
|
||||
self.is_valid = False
|
||||
|
|
Loading…
Reference in New Issue