Move imports to top for pushetta ()

* Move imports to top for pushetta

* Make Pushetta.exceptions import lowercase and snakecase
pull/29344/head
springstan 2019-12-03 12:23:41 +01:00 committed by Martin Hjelmare
parent e9647f8814
commit 078e907178
1 changed files with 5 additions and 7 deletions
homeassistant/components/pushetta

View File

@ -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