示例#1
0
async def main():
    # noinspection PyUnresolvedReferences
    import zhaquirks  # noqa: F401

    api = API()
    while True:
        try:
            await api.connect("auto")
            break
        except SerialException as e:
            print(e)
            await asyncio.sleep(2)

    db = "store.db"
    try:
        app = application.ControllerApplication(api, database_file=db)
    except KeyError:
        LOGGER.error("DB error, removing DB...")
        await asyncio.sleep(1)
        os.remove(db)
        app = application.ControllerApplication(api, database_file=db)

    testapp = TestApp()

    app.add_context_listener(testapp)

    LOGGER.info("STARTUP")
    await app.startup(auto_form=False)
    await app.form_network()

    await app.permit_ncp()
示例#2
0
async def main():
    # noinspection PyUnresolvedReferences
    import zhaquirks  # noqa: F401

    api = API()
    while True:
        try:
            await api.connect("/dev/ttyACM0")
            break
        except SerialException as e:
            print(e)
            await asyncio.sleep(2)

    db = "store.db"
    try:
        app = application.ControllerApplication(api, database_file=db)
    except KeyError:
        LOGGER.error("DB error, removing DB...")
        await asyncio.sleep(1)
        os.remove(db)
        app = application.ControllerApplication(api, database_file=db)

    await app.startup(auto_form=False)
    await app.form_network()
示例#3
0
def app(monkeypatch, database_file=None):
    app = application.ControllerApplication(API(), database_file=database_file)
    return app
示例#4
0
def app():
    app = application.ControllerApplication(APP_CONFIG)
    app._api = API(APP_CONFIG[config.CONF_DEVICE])
    app._api.set_application(app)
    return app
示例#5
0
def app():
    app = application.ControllerApplication(APP_CONFIG)
    app._api = API(APP_CONFIG[config.CONF_DEVICE])
    app._api.set_application(app)
    app._semaphore = asyncio.Semaphore()
    return app