Update join (#7443)
* update python-join-api to 0.0.2 * bump python-join-api to 0.0.2
This commit is contained in:
parent
8d50045971
commit
d251621f2b
3 changed files with 60 additions and 25 deletions
|
@ -12,38 +12,51 @@ from homeassistant.components.notify import (
|
|||
from homeassistant.const import CONF_API_KEY
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
REQUIREMENTS = ['python-join-api==0.0.1']
|
||||
REQUIREMENTS = ['python-join-api==0.0.2']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_DEVICE_ID = 'device_id'
|
||||
CONF_DEVICE_IDS = 'device_ids'
|
||||
CONF_DEVICE_NAMES = 'device_names'
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_DEVICE_ID): cv.string,
|
||||
vol.Optional(CONF_API_KEY): cv.string
|
||||
vol.Required(CONF_API_KEY): cv.string,
|
||||
vol.Optional(CONF_DEVICE_ID): cv.string,
|
||||
vol.Optional(CONF_DEVICE_IDS): cv.string,
|
||||
vol.Optional(CONF_DEVICE_NAMES): cv.string,
|
||||
})
|
||||
|
||||
|
||||
# pylint: disable=unused-variable
|
||||
def get_service(hass, config, discovery_info=None):
|
||||
"""Get the Join notification service."""
|
||||
device_id = config.get(CONF_DEVICE_ID)
|
||||
api_key = config.get(CONF_API_KEY)
|
||||
device_id = config.get(CONF_DEVICE_ID)
|
||||
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 theAPI key")
|
||||
_LOGGER.error("Error connecting to Join. Check the API key")
|
||||
return False
|
||||
return JoinNotificationService(device_id, api_key)
|
||||
if device_id is None and device_ids is None and device_names is None:
|
||||
_LOGGER.error("No device was provided. Please specify device_id"
|
||||
", device_ids, or device_names")
|
||||
return False
|
||||
return JoinNotificationService(api_key, device_id,
|
||||
device_ids, device_names)
|
||||
|
||||
|
||||
class JoinNotificationService(BaseNotificationService):
|
||||
"""Implement the notification service for Join."""
|
||||
|
||||
def __init__(self, device_id, api_key=None):
|
||||
def __init__(self, api_key, device_id, device_ids, device_names):
|
||||
"""Initialize the service."""
|
||||
self._device_id = device_id
|
||||
self._api_key = api_key
|
||||
self._device_id = device_id
|
||||
self._device_ids = device_ids
|
||||
self._device_names = device_names
|
||||
|
||||
def send_message(self, message="", **kwargs):
|
||||
"""Send a message to a user."""
|
||||
|
@ -51,6 +64,7 @@ class JoinNotificationService(BaseNotificationService):
|
|||
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
|
||||
data = kwargs.get(ATTR_DATA) or {}
|
||||
send_notification(
|
||||
device_id=self._device_id, text=message, title=title,
|
||||
device_id=self._device_id, device_ids=self._device_ids,
|
||||
device_names=self._device_names, text=message, title=title,
|
||||
icon=data.get('icon'), smallicon=data.get('smallicon'),
|
||||
api_key=self._api_key)
|
||||
vibration=data.get('vibration'), api_key=self._api_key)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue