Franz, it looks like some of the indentation in the wxMesh.py driver has
been corrupted. python uses indentation to understand the structure of the
code. Could you check the lines I have indicated below? The error might be
right - do you have some special character on line 48?.
You are using wysiwig's fork of my original driver, and your MQTT
publication looks correct for it.
Also, paste source code in and use the {} to "Highlight code syntax". This
will help understand where the issue is.
def __init__(self, **stn_dict):
# where to find the data file
self.host = stn_dict.get('host', 'localhost')
# subscribe to all sub-topic of the topic define in weewx.conf
self.topic = stn_dict.get('topic', 'weather') + "/#"
self.username = stn_dict.get('username', 'XXX') <---- Is this line not
indented in your wxMesh.py file?
self.password = stn_dict.get('password', 'password')
# how often to poll the weather data file, seconds
self.poll_interval = float(stn_dict.get('poll_interval', 5.0))
# mapping from variable names to weewx names
self.label_map = stn_dict.get('label_map', {})
loginf("host is %s" % self.host)
loginf("topic is %s" % self.topic)
loginf("polling interval is %s" % self.poll_interval)
loginf('label map is %s' % self.label_map)
self.payload = "Empty"
self.receive_buffer = {} <---- This line should be indented
#self.payloadList = [payload]
self.client = mqtt.Client(client_id="XXX", protocol=mqtt.MQTTv31)
#self.client.on_connect = self.on_connect
self.client.on_message = self.on_message
self.client.username_pw_set(self.username, self.password) <---- Too
much indent, probably harmless
self.client.connect(self.host, 1883, 60)
self.client.subscribe(self.topic, qos=0)
# The callback for when a PUBLISH message is received from the server.
def on_message(self, client, userdata, msg):
self.payload = str(msg.payload)
string_topic = str(msg.topic)
key = string_topic.split('/')[-1]
self.receive_buffer[key] = str(msg.payload)<----Too much indent,
probably harmless