Exemple #1
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
Exemple #2
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
Exemple #3
0
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))

if len(sys.argv) != 3:
    sys.exit(0)

devname = sys.argv[1]
cmd = sys.argv[2]
print cmd, devurlbylabel[devname]
apply_action(tahoma, cmd, devurlbylabel[devname])