Ejemplo n.º 1
0
def get_service(hass, config):
    """Get the Join notification service."""
    device_id = config.get(CONF_DEVICE_ID)
    api_key = config.get(CONF_API_KEY)
    if api_key:
        from pyjoin import get_devices
        if not get_devices(api_key):
            _LOGGER.error("Error connecting to Join, check API key")
            return False
    return JoinNotificationService(device_id, api_key)
Ejemplo n.º 2
0
def get_service(hass, config):
    """Get the Join notification service."""
    device_id = config.get(CONF_DEVICE_ID)
    api_key = config.get(CONF_API_KEY)
    if api_key:
        from pyjoin import get_devices
        if not get_devices(api_key):
            _LOGGER.error("Error connecting to Join, check API key")
            return False
    return JoinNotificationService(device_id, api_key)
Ejemplo n.º 3
0
def setup(hass, config):
    """Setup Join services."""
    from pyjoin import get_devices
    for device in config[DOMAIN]:
        device_id = device.get(CONF_DEVICE_ID)
        api_key = device.get(CONF_API_KEY)
        name = device.get(CONF_NAME)
        name = name.lower().replace(" ", "_") + "_" if name else ""
        if api_key:
            if not get_devices(api_key):
                _LOGGER.error("Error connecting to Join, check API key")
                return False
        register_device(hass, device_id, api_key, name)
    return True
Ejemplo n.º 4
0
def setup(hass, config):
    """Setup Join services."""
    from pyjoin import (get_devices, ring_device, set_wallpaper, send_sms,
                        send_file, send_url, send_notification)
    device_id = config[DOMAIN].get(CONF_DEVICE_ID)
    api_key = config[DOMAIN].get(CONF_API_KEY)
    name = config[DOMAIN].get(CONF_NAME)
    if api_key:
        if not get_devices(api_key):
            _LOGGER.error("Error connecting to Join, check API key")
            return False

    def ring_service(service):
        """Service to ring devices."""
        ring_device(device_id, api_key=api_key)

    def set_wallpaper_service(service):
        """Service to set wallpaper on devices."""
        set_wallpaper(device_id, url=service.data.get('url'), api_key=api_key)

    def send_file_service(service):
        """Service to send files to devices."""
        send_file(device_id, url=service.data.get('url'), api_key=api_key)

    def send_url_service(service):
        """Service to open url on devices."""
        send_url(device_id, url=service.data.get('url'), api_key=api_key)

    def send_tasker_service(service):
        """Service to open url on devices."""
        send_notification(device_id=device_id,
                          text=service.data.get('command'),
                          api_key=api_key)

    def send_sms_service(service):
        """Service to send sms from devices."""
        send_sms(device_id=device_id,
                 sms_number=service.data.get('number'),
                 sms_text=service.data.get('message'),
                 api_key=api_key)

    name = name.lower().replace(" ", "_") + "_" if name else ""
    hass.services.register(DOMAIN, name + 'ring', ring_service)
    hass.services.register(DOMAIN, name + 'set_wallpaper',
                           set_wallpaper_service)
    hass.services.register(DOMAIN, name + 'send_sms', send_sms_service)
    hass.services.register(DOMAIN, name + 'send_file', send_file_service)
    hass.services.register(DOMAIN, name + 'send_url', send_url_service)
    hass.services.register(DOMAIN, name + 'send_tasker', send_tasker_service)
    return True
Ejemplo n.º 5
0
def get_service(opp, config, discovery_info=None):
    """Get the Join notification service."""
    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 and not get_devices(api_key):
        _LOGGER.error("Error connecting to Join. Check the API key")
        return False
    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)
Ejemplo n.º 6
0
def get_service(hass, config, discovery_info=None):
    """Get the Join notification service."""
    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 the API key")
            return False
    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)
Ejemplo n.º 7
0
def setup(hass, config):
    """Set up the Join services."""
    for device in config[DOMAIN]:
        api_key = device.get(CONF_API_KEY)
        device_id = device.get(CONF_DEVICE_ID)
        device_ids = device.get(CONF_DEVICE_IDS)
        device_names = device.get(CONF_DEVICE_NAMES)
        name = device.get(CONF_NAME)
        name = f"{name.lower().replace(' ', '_')}_" if name else ""
        if api_key and not get_devices(api_key):
            _LOGGER.error("Error connecting to Join, check API key")
            return False
        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

        register_device(hass, api_key, name, device_id, device_ids,
                        device_names)
    return True
Ejemplo n.º 8
0
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)
        device_id = device.get(CONF_DEVICE_ID)
        device_ids = device.get(CONF_DEVICE_IDS)
        device_names = device.get(CONF_DEVICE_NAMES)
        name = device.get(CONF_NAME)
        name = name.lower().replace(" ", "_") + "_" if name else ""
        if api_key:
            if not get_devices(api_key):
                _LOGGER.error("Error connecting to Join, check API key")
                return False
        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

        register_device(hass, api_key, name,
                        device_id, device_ids, device_names)
    return True