INNER CODE UNIT · Python

on_connect

bkbilly/lnxlink · lnxlink/__main__.py:339

    def on_connect(self, client, userdata, flags, rcode, *args):
        """Callback for MQTT connect which reports the connection status
        back to MQTT server"""
        logger.info("MQTT connection: %s", self.mqtt.get_rcode_name(rcode))
        self.invalidate_publish_cache()
        client.subscribe(f"{self.config['pref_topic']}/commands/#")
        self.mqtt.send_lwt("ON")
        if self.config["mqtt"]["discovery"]["enabled"]:
            self.setup_discovery()
        self.kill = False
        self.publ_queue.notify_all()

    def disconnect(self, *args):
        """Service has stopped"""
        self.kill = True
        self.mqtt.disconnect()
        self.stop_event.set()
        self.publ_queue.notify_all()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…