예제 #1
0
    def run(self):
        global IMPORT_RESULT

        zc = EsphomeZeroconf()

        def on_update(dat):
            for key, b in dat.items():
                PING_RESULT[key] = b

        stat = DashboardStatus(zc, on_update)
        imports = DashboardImportDiscovery(zc)

        stat.start()
        while not STOP_EVENT.is_set():
            entries = _list_dashboard_entries()
            stat.request_query(
                {entry.filename: f"{entry.name}.local."
                 for entry in entries})
            IMPORT_RESULT = imports.import_state

            PING_REQUEST.wait()
            PING_REQUEST.clear()

        stat.stop()
        stat.join()
        imports.cancel()
        zc.close()
예제 #2
0
    def run(self):
        zc = Zeroconf()

        def on_update(dat):
            for key, b in dat.items():
                PING_RESULT[key] = b

        stat = DashboardStatus(zc, on_update)
        stat.start()
        while not STOP_EVENT.is_set():
            entries = _list_dashboard_entries()
            stat.request_query({entry.filename: entry.name + '.local.' for entry in entries})

            PING_REQUEST.wait()
            PING_REQUEST.clear()
        stat.stop()
        stat.join()
        zc.close()