Exemple #1
0
async def do_run():
    """Connect to the PLM and load the ALDB."""
    # devices = await async_connect(device=DEVICE)
    devices = await async_connect(host=HOST,
                                  username=USERNAME,
                                  password=PASSWORD)
    await devices.async_load(workdir=PATH, id_devices=0)
    # modem = devices.modem '', '13.37.42'
    identify_scenes()
    device1 = devices["2C.38.32"]
    device1.groups[1].subscribe(state_changed)
    device2 = devices["13.37.42"]
    device2.groups[1].subscribe(state_changed)
    _LOGGER.info("Turning scene on")
    await async_trigger_scene_on(group=0x1A)
    await asyncio.sleep(5)
    _LOGGER.info("Turning scene off")
    set_log_levels(
        logger="info",
        logger_pyinsteon="info",
        logger_messages="info",
        logger_topics=False,
    )
    await async_trigger_scene_off(group=0x1A)
    await asyncio.sleep(5)
    await async_close()
Exemple #2
0
async def do_run():
    """Connect to the PLM and load the ALDB."""
    # devices = await async_connect(device=DEVICE)
    devices = await async_connect(host=HOST,
                                  username=USERNAME,
                                  password=PASSWORD)
    await devices.async_load(workdir=PATH, id_devices=0)
    devices.subscribe(device_added)
    await async_enter_linking_mode(link_mode=AllLinkMode.EITHER, group=0)
    _LOGGER.info("Press device SET button")
    await done.get()
    await async_close()
Exemple #3
0
async def load_device_properties():
    """Load the device databae."""
    devices = await async_connect(device=DEVICE)
    # devices = await async_connect(host=HOST,
    #                              username=USERNAME,
    #                              password=PASSWORD)

    await devices.async_load(workdir=PATH)
    await devices.async_save(workdir=PATH)
    addresses = ["13.36.96", "45.31.94"]
    for address in addresses:
        device = devices[address]
        await device.aldb.async_load(refresh=True)
        _LOGGER.info("ALDB load status for %s: %s", device.address,
                     device.aldb.status.name)
        _LOGGER.info("Loading device properties")
        await device.async_read_op_flags()
        await device.async_read_ext_properties()
        await asyncio.sleep(
            3)  # Give the device some time to respond to get ext prop

        await devices.async_save(workdir=PATH)
        _LOGGER.info("")
        for mem_addr in device.aldb:
            rec = device.aldb[mem_addr]
            _LOGGER.info(rec)
    await async_close()
Exemple #4
0
async def do_run():
    """Connect to the PLM and load the ALDB."""
    # devices = await async_connect(device=DEVICE)
    devices = await async_connect(host=HOST,
                                  username=USERNAME,
                                  password=PASSWORD)
    await devices.async_load(workdir=PATH, id_devices=0)
    await async_enter_unlinking_mode(group=1)
    _LOGGER.info('Press device SET button')
    await asyncio.sleep(10)
    await async_enter_unlinking_mode(group=0)
    _LOGGER.info('Press device SET button')
    await asyncio.sleep(10)
    await async_close()
Exemple #5
0
async def load_database():
    """Load the device databae."""
    await async_connect(device=DEVICE)
    # await async_connect(host=HOST,
    #                     username=USERNAME,
    #                     password=PASSWORD)

    await devices.async_load(workdir=PATH, id_devices=0)
    _LOGGER.info("Trigger the device now...")
    # Uncomment the line below to mock a device sending a message.
    asyncio.ensure_future(send_messages())
    await asyncio.sleep(10)
    for address in devices:
        device = devices[address]
        _LOGGER.info("Device: %s %s", device.address, device.description)
    await async_close()
Exemple #6
0
async def do_run():
    """Connect to the PLM and load the ALDB."""
    devices = await async_connect(device=DEVICE)
    # modem = await async_connect(host=HOST,
    #                             username=USERNAME,
    #                             password=PASSWORD)
    modem = devices.modem
    _LOGGER.info('Connected')
    _LOGGER.info('Modem Address: %s', modem.address)
    _LOGGER.info('Loading ALDB')
    await modem.aldb.async_load()

    _LOGGER.info('ALDB Load Status: %s', modem.aldb.status)
    for record in modem.aldb:
        _LOGGER.info(modem.aldb[record])
    await async_close()
Exemple #7
0
async def load_device_properties():
    """Load the device databae."""
    # devices = await async_connect(device=DEVICE)
    devices = await async_connect(host=HOST,
                                  username=USERNAME,
                                  password=PASSWORD)

    await devices.async_load(workdir=PATH)
    await devices.async_save(workdir=PATH)
    for address in devices:
        device = devices[address]
        _LOGGER.info('Loading device properties')
        await device.async_read_config()

        await devices.async_save(workdir=PATH)
        _LOGGER.info('')
    await async_close()
Exemple #8
0
async def run():
    """Run the monitoring."""
    set_log_levels(logger='info',
                   logger_pyinsteon='info',
                   logger_messages='debug',
                   logger_topics=True)
    await async_connect(host=HOST, username=USERNAME, password=PASSWORD)
    devices.subscribe(device_added)
    await devices.async_load(workdir=PATH)
    await devices.async_save(workdir=PATH)
    await devices.modem.async_get_configuration()
    await devices.modem.async_set_configuration(
        disable_auto_linking=devices.modem.disable_auto_linking,
        monitor_mode=True,
        auto_led=devices.modem.auto_led,
        deadman=devices.modem.deadman)
    _LOGGER.info('Devices loaded: %d', len(devices))
    try:
        while True:
            await asyncio.sleep(5)
    except KeyboardInterrupt:
        await async_close()
        raise KeyboardInterrupt()
Exemple #9
0
async def set_default_links():
    """Load the device databae."""
    # await async_connect(device=DEVICE)
    await async_connect(host=HOST, username=USERNAME, password=PASSWORD)

    await devices.async_load(workdir=PATH, id_devices=0)
    device = devices[address]

    set_log_levels(
        logger="info",
        logger_pyinsteon="info",
        logger_messages="info",
        logger_topics=True,
    )

    devices.modem.aldb.remove(controller=False, group=1, target=address)
    for mem_addr in device.aldb:
        rec = device.aldb[mem_addr]
        if rec.target == devices.modem.address and rec.group == 1:
            device.aldb.remove(mem_addr)

    await devices.modem.aldb.async_write()
    await device.aldb.async_write()

    await device.async_add_default_links()

    set_log_levels(
        logger="info",
        logger_pyinsteon="info",
        logger_messages="info",
        logger_topics=False,
    )

    await devices.modem.aldb.async_load()
    await device.aldb.async_load(refresh=True)

    _LOGGER.info("Modem Links")
    for mem_addr in devices.modem.aldb:
        _LOGGER.info(devices.modem.aldb[mem_addr])

    _LOGGER.info("Device Links")
    for mem_addr in devices[address].aldb:
        _LOGGER.info(device.aldb[mem_addr])
    await async_close()
Exemple #10
0
async def do_run():
    """Connect to the PLM and load the ALDB."""
    # devices = await async_connect(device=DEVICE)
    devices = await async_connect(host=HOST, username=USERNAME, password=PASSWORD)
    modem = devices.modem
    _LOGGER.info("Connected")
    _LOGGER.info("Modem Address: %s", modem.address)
    await devices.async_load(workdir=PATH, id_devices=0)
    device = devices["13.36.96"]
    device.groups[1].subscribe(state_changed)
    await device.async_on()
    await asyncio.sleep(1)
    await device.async_off()

    _LOGGER.info("Please manually turn device on and off.")
    await asyncio.sleep(20)

    _LOGGER.info("Getting device status.")
    await device.async_status()
    await async_close()
Exemple #11
0
async def do_run():
    """Connect to the PLM and load the ALDB."""
    # devices = await async_connect(device=DEVICE)
    devices = await async_connect(host=HOST,
                                  username=USERNAME,
                                  password=PASSWORD)
    modem = devices.modem
    _LOGGER.info('Connected')
    _LOGGER.info('Modem Address: %s', modem.address)
    await devices.async_load(workdir=PATH)
    await devices.async_save(workdir=PATH)
    for address in devices:
        device = devices[address]
        _LOGGER.info('%s %s %s', device.address, device.description, device.model)
    await async_close()
Exemple #12
0
async def do_run():
    """Connect to the PLM and load the ALDB."""
    devices = await async_connect(device=DEVICE)
    # modem = await async_connect(host=HOST,
    #                             username=USERNAME,
    #                             password=PASSWORD)
    modem = devices.modem
    _LOGGER.info('Connected')
    _LOGGER.info('Modem Address: %s', modem.address)
    await devices.async_load(workdir=PATH, id_devices=0)
    controller = devices.get('45.31.94')
    responder = devices.get('13.36.96')
    link_result = await async_link_devices(controller, responder, 1)
    await asyncio.sleep(10)
    if link_result:
        _LOGGER.info(link_result)
    await async_close()
Exemple #13
0
async def run():
    """Run the monitoring."""
    set_log_levels(
        logger="info",
        logger_pyinsteon="info",
        logger_messages="info",
        logger_topics=True,
    )
    # await async_connect(host=HOST, username=USERNAME, password=PASSWORD)
    await async_connect(device=DEVICE)
    devices.subscribe(device_added)
    await devices.async_load(workdir=PATH, id_devices=0)
    await devices.async_save(workdir=PATH)

    address = "453194"
    device = devices[address]

    if device:
        await device.async_read_op_flags()
        await device.async_read_ext_properties()
        _LOGGER.info(
            "LED_BLINK_ON_TX_ON: %s",
            device.operating_flags[MOMENTARY_ON_OFF_TRIGGER].value,
        )

        device.operating_flags[MOMENTARY_ON_OFF_TRIGGER].new_value = True

        await device.async_write_op_flags()
        await device.async_write_ext_properties()
        await device.async_read_op_flags()
        await device.async_read_ext_properties()
        _LOGGER.info(
            "LED_BLINK_ON_TX_ON: %s",
            device.operating_flags[MOMENTARY_ON_OFF_TRIGGER].value,
        )
    else:
        _LOGGER.info("No device found for address: %s", address)
    await devices.async_save(workdir=PATH)
    await async_close()
Exemple #14
0
    """Send the messages to mimic triggering."""
    address = "27c387"
    RX1 = unhexlify("0250{}000001cf1300".format(address))
    # pylint: disable=protected-access
    devices.modem._protocol.data_received(RX1)


async def load_database():
    """Load the device databae."""
    await async_connect(device=DEVICE)
    # await async_connect(host=HOST,
    #                     username=USERNAME,
    #                     password=PASSWORD)

    await devices.async_load(workdir=PATH, id_devices=0)
    _LOGGER.info("Trigger the device now...")
    # Uncomment the line below to mock a device sending a message.
    asyncio.ensure_future(send_messages())
    await asyncio.sleep(10)
    for address in devices:
        device = devices[address]
        _LOGGER.info("Device: %s %s", device.address, device.description)
    await async_close()


if __name__ == "__main__":
    set_log_levels(logger="info", logger_pyinsteon="info", logger_messages="info")
    loop = asyncio.get_event_loop()
    _LOGGER.info("Loading All-Link database for all devices")
    loop.run_until_complete(load_database())
Exemple #15
0
def device_added(address):
    """Log a device added to the device list."""
    _LOGGER.info("Device added: %s", address)
Exemple #16
0
def state_changed(name, value, group):
    """Capture the state change."""
    _LOGGER.info('State changed to %s', value)
Exemple #17
0
def state_changed(name, address, value, group):
    """Capture the state change."""
    _LOGGER.info("State changed to %s", value)
Exemple #18
0
USERNAME, PASSWORD, HOST = get_hub_config()


async def load_device_properties():
    """Load the device databae."""
    # devices = await async_connect(device=DEVICE)
    devices = await async_connect(host=HOST,
                                  username=USERNAME,
                                  password=PASSWORD)

    await devices.async_load(workdir=PATH)
    await devices.async_save(workdir=PATH)
    for address in devices:
        device = devices[address]
        _LOGGER.info('Loading device properties')
        await device.async_read_config()

        await devices.async_save(workdir=PATH)
        _LOGGER.info('')
    await async_close()


if __name__ == '__main__':
    set_log_levels(logger='info',
                   logger_pyinsteon='info',
                   logger_messages='debug',
                   logger_topics=True)
    loop = asyncio.get_event_loop()
    _LOGGER.info('Loading All-Link database for all devices')
    loop.run_until_complete(load_device_properties())
Exemple #19
0
def state_changed(name, address, value, group):
    """Capture the state change."""
    _LOGGER.info("Device %s state %d changed to 0x%02x", address, group, value)