mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Move imports to top for joaoapps_join (#29402)
This commit is contained in:
parent
e04a208af0
commit
73e25296ca
@ -1,10 +1,19 @@
|
|||||||
"""Support for Joaoapps Join services."""
|
"""Support for Joaoapps Join services."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from pyjoin import (
|
||||||
|
get_devices,
|
||||||
|
ring_device,
|
||||||
|
send_file,
|
||||||
|
send_notification,
|
||||||
|
send_sms,
|
||||||
|
send_url,
|
||||||
|
set_wallpaper,
|
||||||
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.const import CONF_API_KEY, CONF_NAME
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.const import CONF_NAME, CONF_API_KEY
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_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):
|
def register_device(hass, api_key, name, device_id, device_ids, device_names):
|
||||||
"""Register services for each join device listed."""
|
"""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):
|
def ring_service(service):
|
||||||
"""Service to ring devices."""
|
"""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):
|
def setup(hass, config):
|
||||||
"""Set up the Join services."""
|
"""Set up the Join services."""
|
||||||
from pyjoin import get_devices
|
|
||||||
|
|
||||||
for device in config[DOMAIN]:
|
for device in config[DOMAIN]:
|
||||||
api_key = device.get(CONF_API_KEY)
|
api_key = device.get(CONF_API_KEY)
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
"""Support for Join notifications."""
|
"""Support for Join notifications."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from pyjoin import get_devices, send_notification
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.notify import (
|
from homeassistant.components.notify import (
|
||||||
ATTR_DATA,
|
ATTR_DATA,
|
||||||
ATTR_TITLE,
|
ATTR_TITLE,
|
||||||
@ -34,8 +37,6 @@ def get_service(hass, config, discovery_info=None):
|
|||||||
device_ids = config.get(CONF_DEVICE_IDS)
|
device_ids = config.get(CONF_DEVICE_IDS)
|
||||||
device_names = config.get(CONF_DEVICE_NAMES)
|
device_names = config.get(CONF_DEVICE_NAMES)
|
||||||
if api_key:
|
if api_key:
|
||||||
from pyjoin import get_devices
|
|
||||||
|
|
||||||
if not get_devices(api_key):
|
if not get_devices(api_key):
|
||||||
_LOGGER.error("Error connecting to Join. Check the API key")
|
_LOGGER.error("Error connecting to Join. Check the API key")
|
||||||
return False
|
return False
|
||||||
@ -60,7 +61,6 @@ class JoinNotificationService(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 pyjoin import send_notification
|
|
||||||
|
|
||||||
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
|
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
|
||||||
data = kwargs.get(ATTR_DATA) or {}
|
data = kwargs.get(ATTR_DATA) or {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user