stlehmann / Flask-MQTT

Flask Extension for the MQTT protocol
MIT License
207 stars 71 forks source link

Setting the client name within Flask is invalid #158

Open gdushang opened 11 months ago

gdushang commented 11 months ago

if set client name in flask config,using Mqtt.init_app to init app, client name of mqtt will be set to the default value,

In init App () should be corrected to first obtain the config of Flask, and then set up monitoring self. client ID,

    if "MQTT_CLIENT_ID" in app.config:
        self.client_id = app.config["MQTT_CLIENT_ID"]
    if isinstance(self.client_id, unicode):
        self.client._client_id = self.client_id.encode("utf-8")
    else:
        self.client._client_id = self.client_id