def on_zeroconf_discovered(self, name, address, info): """Called on every zeroconf discovered device""" # if (name.lower().startswith('feinstaubsensor') # or name.lower().startswith('nam') # or name.lower().startswith('smogomierz') # or name.lower().startswith('airrohr') # or name.lower().startswith(self.customNameSave)): item = QtWidgets.QListWidgetItem('{}: {}'.format(address, name.split('.')[0])) item.setData(ROLE_DEVICE, 'http://{}:{}'.format(address, info.port)) self.discoveryList.addItem(item)
self.zeroconf_discovery.start() def on_zeroconf_discovered(self, name, address, info): """Called on every zeroconf discovered device""" if (name.startswith('Feinstaubsensor') or name.startswith('NAM') or name.startswith('Smogomierz') or name.startswith('airrohr')): item = QtWidgets.QListWidgetItem('{}: {}'.format( address, name.split('.')[0])) item.setData(ROLE_DEVICE, 'http://{}:{}'.format(address, info.port)) self.discoveryList.addItem(item) @QtCore.Slot(QtWidgets.QListWidgetItem) def on_discoveryList_itemDoubleClicked(self, index): QtGui.QDesktopServices.openUrl(QtCore.QUrl(index.data(ROLE_DEVICE))) @QtCore.Slot() def on_discoveryRefreshButton_clicked(self): self.discoveryList.clear() self.discovery_start() if __name__ == "__main__": logging.basicConfig(level=logging.INFO) app = QtWidgets.QApplication(sys.argv) window = MainWindow(app=app) window.show() sys.exit(app.exec_())