Move imports to top for joaoapps_join (#29402)
parent
e04a208af0
commit
73e25296ca
homeassistant/components/joaoapps_join
|
@ -1,10 +1,19 @@
|
|||
"""Support for Joaoapps Join services."""
|
||||
import logging
|
||||
|
||||
from pyjoin import (
|
||||
get_devices,
|
||||
ring_device,
|
||||
send_file,
|
||||
send_notification,
|
||||
send_sms,
|
||||
send_url,
|
||||
set_wallpaper,
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_API_KEY, CONF_NAME
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.const import CONF_NAME, CONF_API_KEY
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -35,14 +44,6 @@ CONFIG_SCHEMA = vol.Schema(
|
|||
|
||||
def register_device(hass, api_key, name, device_id, device_ids, device_names):
|
||||
"""Register services for each join device listed."""
|
||||
from pyjoin import (
|
||||
ring_device,
|
||||
set_wallpaper,
|
||||
send_sms,
|
||||
send_file,
|
||||
send_url,
|
||||
send_notification,
|
||||
)
|
||||
|
||||
def ring_service(service):
|
||||
"""Service to ring devices."""
|
||||
|
@ -114,7 +115,6 @@ def register_device(hass, api_key, name, device_id, device_ids, device_names):
|
|||
|
||||
def setup(hass, config):
|
||||
"""Set up the Join services."""
|
||||
from pyjoin import get_devices
|
||||
|
||||
for device in config[DOMAIN]:
|
||||
api_key = device.get(CONF_API_KEY)
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
"""Support for Join notifications."""
|
||||
import logging
|
||||
|
||||
from pyjoin import get_devices, send_notification
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.notify import (
|
||||
ATTR_DATA,
|
||||
ATTR_TITLE,
|
||||
|
@ -34,8 +37,6 @@ def get_service(hass, config, discovery_info=None):
|
|||
device_ids = config.get(CONF_DEVICE_IDS)
|
||||
device_names = config.get(CONF_DEVICE_NAMES)
|
||||
if api_key:
|
||||
from pyjoin import get_devices
|
||||
|
||||
if not get_devices(api_key):
|
||||
_LOGGER.error("Error connecting to Join. Check the API key")
|
||||
return False
|
||||
|
@ -60,7 +61,6 @@ class JoinNotificationService(BaseNotificationService):
|
|||
|
||||
def send_message(self, message="", **kwargs):
|
||||
"""Send a message to a user."""
|
||||
from pyjoin import send_notification
|
||||
|
||||
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
|
||||
data = kwargs.get(ATTR_DATA) or {}
|
||||
|
|
Loading…
Reference in New Issue