Esempio n. 1
0
def setup(hass, config):
    """Activate Tahoma component."""
    from tahoma_api import TahomaApi

    conf = config[DOMAIN]
    username = conf.get(CONF_USERNAME)
    password = conf.get(CONF_PASSWORD)
    exclude = conf.get(CONF_EXCLUDE)
    try:
        api = TahomaApi(username, password)
    except RequestException:
        _LOGGER.exception("Error communicating with Tahoma API")
        return False

    try:
        api.get_setup()
        devices = api.get_devices()
    except RequestException:
        _LOGGER.exception("Cannot fetch informations from Tahoma API")
        return False

    hass.data[DOMAIN] = {'controller': api, 'devices': defaultdict(list)}

    for device in devices:
        _device = api.get_device(device)
        if all(ext not in _device.type for ext in exclude):
            device_type = map_tahoma_device(_device)
            if device_type is None:
                continue
            hass.data[DOMAIN]['devices'][device_type].append(_device)

    for component in TAHOMA_COMPONENTS:
        discovery.load_platform(hass, component, DOMAIN, {}, config)

    return True
Esempio n. 2
0
def setup(hass, config):
    """Activate Tahoma component."""

    conf = config[DOMAIN]
    username = conf.get(CONF_USERNAME)
    password = conf.get(CONF_PASSWORD)
    exclude = conf.get(CONF_EXCLUDE)
    try:
        api = TahomaApi(username, password)
    except RequestException:
        _LOGGER.exception("Error when trying to log in to the Tahoma API")
        return False

    try:
        api.get_setup()
        devices = api.get_devices()
        scenes = api.get_action_groups()
    except RequestException:
        _LOGGER.exception("Error when getting devices from the Tahoma API")
        return False

    hass.data[DOMAIN] = {"controller": api, "devices": defaultdict(list), "scenes": []}

    for device in devices:
        _device = api.get_device(device)
        if all(ext not in _device.type for ext in exclude):
            if is_officially_supported(_device):
                _LOGGER.info(
                    "Type %s for Tahoma device %s is officially supported",
                    _device.type,
                    _device.label,
                )
            else:
                device_type = map_tahoma_device(_device)
                if device_type is None:
                    _LOGGER.warning(
                        "Unsupported type %s for Tahoma device %s",
                        _device.type,
                        _device.label,
                    )
                    continue
                hass.data[DOMAIN]["devices"][device_type].append(_device)

    for scene in scenes:
        hass.data[DOMAIN]["scenes"].append(scene)

    for component in TAHOMA_COMPONENTS:
        discovery.load_platform(hass, component, DOMAIN, {}, config)

    return True
Esempio n. 3
0
def setup(opp, config):
    """Set up Tahoma integration."""

    conf = config[DOMAIN]
    username = conf.get(CONF_USERNAME)
    password = conf.get(CONF_PASSWORD)
    exclude = conf.get(CONF_EXCLUDE)
    try:
        api = TahomaApi(username, password)
    except RequestException:
        _LOGGER.exception("Error when trying to log in to the Tahoma API")
        return False

    try:
        api.get_setup()
        devices = api.get_devices()
        scenes = api.get_action_groups()
    except RequestException:
        _LOGGER.exception("Error when getting devices from the Tahoma API")
        return False

    opp.data[DOMAIN] = {
        "controller": api,
        "devices": defaultdict(list),
        "scenes": []
    }

    for device in devices:
        _device = api.get_device(device)
        if all(ext not in _device.type for ext in exclude):
            device_type = map_tahoma_device(_device)
            if device_type is None:
                _LOGGER.warning(
                    "Unsupported type %s for Tahoma device %s",
                    _device.type,
                    _device.label,
                )
                continue
            opp.data[DOMAIN]["devices"][device_type].append(_device)

    for scene in scenes:
        opp.data[DOMAIN]["scenes"].append(scene)

    for platform in PLATFORMS:
        discovery.load_platform(opp, platform, DOMAIN, {}, config)

    return True
Esempio n. 4
0
def setup(hass, config):
    """Activate Tahoma component."""
    from tahoma_api import TahomaApi

    conf = config[DOMAIN]
    username = conf.get(CONF_USERNAME)
    password = conf.get(CONF_PASSWORD)
    exclude = conf.get(CONF_EXCLUDE)
    try:
        api = TahomaApi(username, password)
    except RequestException:
        _LOGGER.exception("Error when trying to log in to the Tahoma API")
        return False

    try:
        api.get_setup()
        devices = api.get_devices()
        scenes = api.get_action_groups()
    except RequestException:
        _LOGGER.exception("Error when getting devices from the Tahoma API")
        return False

    hass.data[DOMAIN] = {
        'controller': api,
        'devices': defaultdict(list),
        'scenes': []
    }

    for device in devices:
        _device = api.get_device(device)
        if all(ext not in _device.type for ext in exclude):
            device_type = map_tahoma_device(_device)
            if device_type is None:
                _LOGGER.warning('Unsupported type %s for Tahoma device %s',
                                _device.type, _device.label)
                continue
            hass.data[DOMAIN]['devices'][device_type].append(_device)

    for scene in scenes:
        hass.data[DOMAIN]['scenes'].append(scene)

    for component in TAHOMA_COMPONENTS:
        discovery.load_platform(hass, component, DOMAIN, {}, config)

    return True
Esempio n. 5
0
def setup(hass, config):
    """Activate Tahoma component."""
    from tahoma_api import TahomaApi

    conf = config[DOMAIN]
    username = conf.get(CONF_USERNAME)
    password = conf.get(CONF_PASSWORD)
    exclude = conf.get(CONF_EXCLUDE)
    try:
        api = TahomaApi(username, password)
    except RequestException:
        _LOGGER.exception("Error communicating with Tahoma API")
        return False

    try:
        api.get_setup()
        devices = api.get_devices()
    except RequestException:
        _LOGGER.exception("Cannot fetch informations from Tahoma API")
        return False

    hass.data[DOMAIN] = {
        'controller': api,
        'devices': defaultdict(list)
    }

    for device in devices:
        _device = api.get_device(device)
        if all(ext not in _device.type for ext in exclude):
            device_type = map_tahoma_device(_device)
            if device_type is None:
                continue
            hass.data[DOMAIN]['devices'][device_type].append(_device)

    for component in TAHOMA_COMPONENTS:
        discovery.load_platform(hass, component, DOMAIN, {}, config)

    return True
Esempio n. 6
0
    action = Action(dev_url)
    action.add_command(cmd_name, *args)
    controller.apply_actions('Test', [action])


creds = open('.tahoma.credentials').read()
creds = json.loads(creds)
print('Logging in to Tahomalink')
tahoma = TahomaApi(creds['USERNAME'], creds['PASSWORD'])
tahoma.get_setup()

print('Get all registered devices')
devurlbylabel = {}
devs = tahoma.get_devices()
for d in devs:
    _dev = tahoma.get_device(d)
    devurlbylabel[_dev.label] = _dev.url
    # print info
    print('Device label = %s, type = %s (url = %s)' %
          (_dev.label, _dev.type, _dev.url))
    print('    commands = %s' % _dev.command_definitions)
    try:
        print('    state = %s' % _dev.active_states)
    except AttributeError:
        pass
    print('\n')

print('Get all registered scenes')
agroups = tahoma.get_action_groups()
for ag in agroups:
    print('Scene %s: oid = %s\n' % (ag.name, ag.oid))