Private variables start with _
This commit is contained in:
parent
a4098bf50d
commit
65a1323dc8
1 changed files with 6 additions and 6 deletions
|
@ -5,18 +5,18 @@ import paho.mqtt.client as mqtt
|
|||
class Mqtt:
|
||||
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
self._config = config
|
||||
|
||||
def connect(self):
|
||||
self.client = mqtt.Client()
|
||||
self.client.username_pw_set(self.config['user'], self.config['password'])
|
||||
self.client.connect(self.config['host'], self.config['port'])
|
||||
self.client.loop_start()
|
||||
self._client = mqtt.Client()
|
||||
self._client.username_pw_set(self._config['user'], self._config['password'])
|
||||
self._client.connect(self._config['host'], self._config['port'])
|
||||
self._client.loop_start()
|
||||
|
||||
def disconnect(self):
|
||||
self.client.disconnect()
|
||||
|
||||
def publish(self, topic, payload):
|
||||
topic = "{}/{}".format(self.config['topic'], topic)
|
||||
topic = "{}/{}".format(self._config['topic'], topic)
|
||||
logging.info("Publish %s: %s, %s, %s", topic, payload, self._config["qos"], self._config["retain"])
|
||||
self._client.publish(topic, payload, self._config["qos"], self._config["retain"])
|
||||
|
|
Loading…
Reference in a new issue