We see the Paho-MQTT client instance created and assigned to the global client variable at line (15). A reference to this object is the client parameter we saw previously in the on_connect(), on_disconnect(), and on_message() methods.
The client_id parameter is set to be the client name we defined earlier in CLIENT_ID, while clean_session=False tells the broker that it must not clear any stored messages for our client when we connect. As we discussed earlier in the command-line examples, this is the back-to-front way of saying we want a durable connection so any messages published to the led topic are stored for our client when it's offline:
def init_mqtt():
global client
client = mqtt.Client( # (15)
client_id=CLIENT_ID,
clean_session=False)
# Route Paho logging to Python logging.
client.enable_logger() # (16)
# Setup callbacks
client.on_connect...