Beispiel #1
0
def setup(hass, base_config):
    """Set up the Lutron component."""
    from pylutron import Lutron

    hass.data[LUTRON_CONTROLLER] = None
    hass.data[LUTRON_DEVICES] = {'light': []}

    config = base_config.get(DOMAIN)
    hass.data[LUTRON_CONTROLLER] = Lutron(
        config['lutron_host'],
        config['lutron_user'],
        config['lutron_password']
    )
    hass.data[LUTRON_CONTROLLER].load_xml_db()
    hass.data[LUTRON_CONTROLLER].connect()
    _LOGGER.info("Connected to Main Repeater at %s", config['lutron_host'])

    # Sort our devices into types
    for area in hass.data[LUTRON_CONTROLLER].areas:
        for output in area.outputs:
            hass.data[LUTRON_DEVICES]['light'].append((area.name, output))

    for component in ('light',):
        discovery.load_platform(hass, component, DOMAIN, None, base_config)
    return True
Beispiel #2
0
def setup(hass, base_config):
    """Set up the Lutron component."""
    from pylutron import Lutron

    hass.data[LUTRON_CONTROLLER] = None
    hass.data[LUTRON_DEVICES] = {'light': [], 'cover': []}

    config = base_config.get(DOMAIN)
    hass.data[LUTRON_CONTROLLER] = Lutron(
        config[CONF_HOST], config[CONF_USERNAME], config[CONF_PASSWORD])

    hass.data[LUTRON_CONTROLLER].load_xml_db()
    hass.data[LUTRON_CONTROLLER].connect()
    _LOGGER.info("Connected to main repeater at %s", config[CONF_HOST])

    # Sort our devices into types
    for area in hass.data[LUTRON_CONTROLLER].areas:
        for output in area.outputs:
            if output.type == 'SYSTEM_SHADE':
                hass.data[LUTRON_DEVICES]['cover'].append((area.name, output))
            else:
                hass.data[LUTRON_DEVICES]['light'].append((area.name, output))

    for component in ('light', 'cover'):
        discovery.load_platform(hass, component, DOMAIN, None, base_config)
    return True
Beispiel #3
0
def setup(hass, base_config):
    """Set up the Lutron integration."""
    hass.data[LUTRON_BUTTONS] = []
    hass.data[LUTRON_CONTROLLER] = None
    hass.data[LUTRON_DEVICES] = {
        "light": [],
        "cover": [],
        "switch": [],
        "scene": [],
        "binary_sensor": [],
    }

    config = base_config.get(DOMAIN)
    hass.data[LUTRON_CONTROLLER] = Lutron(
        config[CONF_HOST], config[CONF_USERNAME], config[CONF_PASSWORD]
    )

    hass.data[LUTRON_CONTROLLER].load_xml_db()
    hass.data[LUTRON_CONTROLLER].connect()
    _LOGGER.info("Connected to main repeater at %s", config[CONF_HOST])

    # Sort our devices into types
    for area in hass.data[LUTRON_CONTROLLER].areas:
        for output in area.outputs:
            if output.type == "SYSTEM_SHADE":
                hass.data[LUTRON_DEVICES]["cover"].append((area.name, output))
            elif output.is_dimmable:
                hass.data[LUTRON_DEVICES]["light"].append((area.name, output))
            else:
                hass.data[LUTRON_DEVICES]["switch"].append((area.name, output))
        for keypad in area.keypads:
            for button in keypad.buttons:
                # If the button has a function assigned to it, add it as a scene
                if button.name != "Unknown Button" and button.button_type in (
                    "SingleAction",
                    "Toggle",
                    "SingleSceneRaiseLower",
                    "MasterRaiseLower",
                ):
                    # Associate an LED with a button if there is one
                    led = next(
                        (led for led in keypad.leds if led.number == button.number),
                        None,
                    )
                    hass.data[LUTRON_DEVICES]["scene"].append(
                        (area.name, keypad.name, button, led)
                    )

                hass.data[LUTRON_BUTTONS].append(
                    LutronButton(hass, area.name, keypad, button)
                )
        if area.occupancy_group is not None:
            hass.data[LUTRON_DEVICES]["binary_sensor"].append(
                (area.name, area.occupancy_group)
            )

    for platform in PLATFORMS:
        discovery.load_platform(hass, platform, DOMAIN, {}, base_config)
    return True
Beispiel #4
0
def setup(hass, base_config):
    """Set up the Lutron component."""
    from pylutron import Lutron

    hass.data[LUTRON_BUTTONS] = []
    hass.data[LUTRON_CONTROLLER] = None
    hass.data[LUTRON_DEVICES] = {
        "light": [],
        "cover": [],
        "switch": [],
        "scene": [],
        "binary_sensor": [],
    }

    config = base_config.get(DOMAIN)
    hass.data[LUTRON_CONTROLLER] = Lutron(config[CONF_HOST],
                                          config[CONF_USERNAME],
                                          config[CONF_PASSWORD])

    hass.data[LUTRON_CONTROLLER].load_xml_db()
    hass.data[LUTRON_CONTROLLER].connect()
    _LOGGER.info("Connected to main repeater at %s", config[CONF_HOST])

    # Sort our devices into types
    for area in hass.data[LUTRON_CONTROLLER].areas:
        for output in area.outputs:
            if output.type == "SYSTEM_SHADE":
                hass.data[LUTRON_DEVICES]["cover"].append((area.name, output))
            elif output.is_dimmable:
                hass.data[LUTRON_DEVICES]["light"].append((area.name, output))
            else:
                hass.data[LUTRON_DEVICES]["switch"].append((area.name, output))
        for keypad in area.keypads:
            for button in keypad.buttons:
                # This is the best way to determine if a button does anything
                # useful until pylutron is updated to provide information on
                # which buttons actually control scenes.
                for led in keypad.leds:
                    if (led.number == button.number
                            and button.name != "Unknown Button" and
                            button.button_type in ("SingleAction", "Toggle")):
                        hass.data[LUTRON_DEVICES]["scene"].append(
                            (area.name, keypad.name, button, led))

                hass.data[LUTRON_BUTTONS].append(
                    LutronButton(hass, keypad, button))
        if area.occupancy_group is not None:
            hass.data[LUTRON_DEVICES]["binary_sensor"].append(
                (area.name, area.occupancy_group))

    for component in ("light", "cover", "switch", "scene", "binary_sensor"):
        discovery.load_platform(hass, component, DOMAIN, {}, base_config)
    return True
Beispiel #5
0
def setup(hass, base_config):
    """Set up the Lutron component."""
    from pylutron import Lutron

    hass.data[LUTRON_BUTTONS] = []
    hass.data[LUTRON_CONTROLLER] = None
    hass.data[LUTRON_DEVICES] = {
        'light': [],
        'cover': [],
        'switch': [],
        'scene': []
    }

    config = base_config.get(DOMAIN)
    hass.data[LUTRON_CONTROLLER] = Lutron(config[CONF_HOST],
                                          config[CONF_USERNAME],
                                          config[CONF_PASSWORD])

    hass.data[LUTRON_CONTROLLER].load_xml_db()
    hass.data[LUTRON_CONTROLLER].connect()
    _LOGGER.info("Connected to main repeater at %s", config[CONF_HOST])

    # Sort our devices into types
    for area in hass.data[LUTRON_CONTROLLER].areas:
        for output in area.outputs:
            if output.type == 'SYSTEM_SHADE':
                hass.data[LUTRON_DEVICES]['cover'].append((area.name, output))
            elif output.is_dimmable:
                hass.data[LUTRON_DEVICES]['light'].append((area.name, output))
            else:
                hass.data[LUTRON_DEVICES]['switch'].append((area.name, output))
        for keypad in area.keypads:
            for button in keypad.buttons:
                # This is the best way to determine if a button does anything
                # useful until pylutron is updated to provide information on
                # which buttons actually control scenes.
                for led in keypad.leds:
                    if (led.number == button.number
                            and button.name != 'Unknown Button' and
                            button.button_type in ('SingleAction', 'Toggle')):
                        hass.data[LUTRON_DEVICES]['scene'].append(
                            (area.name, keypad.name, button, led))

                hass.data[LUTRON_BUTTONS].append(
                    LutronButton(hass, keypad, button))

    for component in ('light', 'cover', 'switch', 'scene'):
        discovery.load_platform(hass, component, DOMAIN, None, base_config)
    return True
def setup(hass, base_config):
    """Set up the Lutron component."""

    hass.data[LUTRON_BUTTONS] = []
    hass.data[LUTRON_CONTROLLER] = None
    hass.data[LUTRON_DEVICES] = {
        "light": [],
        "cover": [],
        "switch": [],
        "scene": [],
        "binary_sensor": [],
        "led": [],
    }

    config = base_config.get(DOMAIN)
    hass.data[LUTRON_CONTROLLER] = Lutron(config[CONF_HOST],
                                          config[CONF_USERNAME],
                                          config[CONF_PASSWORD])

    db_file = config[CONF_LUTRON_DB_FILE]
    if db_file != '' and not db_file.startswith("/"):
        db_file = hass.config.path(db_file)

    hass.data[LUTRON_CONTROLLER].load_xml_db(db_file)
    hass.data[LUTRON_CONTROLLER].connect()
    _LOGGER.info("Connected to main repeater at %s", config[CONF_HOST])

    # Sort our devices into types
    for area in hass.data[LUTRON_CONTROLLER].areas:
        for output in area.outputs:
            if output.type in ("SYSTEM_SHADE", "MOTOR"):
                hass.data[LUTRON_DEVICES]["cover"].append((area.name, output))
            elif output.is_light:
                hass.data[LUTRON_DEVICES]["light"].append((area.name, output))
            else:
                hass.data[LUTRON_DEVICES]["switch"].append((area.name, output))
        for keypad in area.keypads:
            for button in keypad.buttons:
                # If the button has a function assigned to it, add it as a scene
                # TODO verify this!
                if button.name != "Unknown Button" and button.button_type in (
                        "SingleAction", "DualAction", "AdvancedToggle",
                        "AdvancedConditional", "Toggle",
                        "SingleSceneRaiseLower", "MasterRaiseLower",
                        "SimpleConditional"):
                    # Associate an LED with a button if there is one
                    # TODO check this a led is a scene???
                    led = next(
                        (led for led in keypad.leds
                         if led.number == button.number),
                        None,
                    )
                    hass.data[LUTRON_DEVICES]["scene"].append(
                        (area.name, keypad.name, button, led))

                    # Add the LED as a light device if is controlled via integration
                    if not (led is None) and button.led_logic == 5:
                        hass.data[LUTRON_DEVICES]["led"].append(
                            (area.name, keypad.name, led))

                hass.data[LUTRON_BUTTONS].append(
                    LutronButton(hass, area.name, keypad, button))
        if area.occupancy_group is not None:
            hass.data[LUTRON_DEVICES]["binary_sensor"].append(
                (area.name, area.occupancy_group))

    for component in ("light", "cover", "switch", "scene", "binary_sensor"):
        discovery.load_platform(hass, component, DOMAIN, {}, base_config)
    return True