Fix global topic prefix handling (#32)

This commit is contained in:
zewelor
2018-12-19 10:31:17 +01:00
committed by GitHub
parent a5a4797a1d
commit 03bb93e2eb
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ class MqttClient:
self.mqttc.connect(self.hostname, port=self.port)
for topic, callback in callbacks:
if self.topic_prefix is not None:
if self.topic_prefix:
topic = "{}/{}".format(self.topic_prefix, topic)
self.mqttc.message_callback_add(topic, callback)
self.mqttc.subscribe(topic)
+1 -1
View File
@@ -71,7 +71,7 @@ class ThermostatWorker(BaseWorker):
return ret
def on_command(self, topic, value):
if self.topic_prefix is not None:
if self.topic_prefix:
_, device_name, method, _ = topic[len(self.topic_prefix+"/"):].split('/')
thermostat = self.devices[device_name]