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