title: Data parsing in mqtt broker
body: <p>I have a python code which is used to receive data from mqtt subscriber.The message from mqtt subscriber is send as strings based on the strings received i am manipulating the results.
  But the code is hitting only at the else case every time.</p>
  <pre><code>
      import paho.mqtt.client as mqtt
      MQTT_ADDRESS = '192.168.103.5'
      MQTT_USER = 'user'
      MQTT_PASSWORD = '12345678'
      MQTT_TOPIC = 'home/+/+'
      def on_connect(client, userdata, flags, rc):
          &quot;&quot;&quot; The callback for when the client receives a CONNACK response from the server.&quot;&quot;&quot;
          print('Connected with result code ' + str(rc))
          client.subscribe(MQTT_TOPIC)
      candidate1 = 0
      candidate2 = 0
      candidate3 = 0
      total_count = 0
      def on_message(client, userdata, msg):
          &quot;&quot;&quot;The callback for when a PUBLISH message is received from the server.&quot;&quot;&quot;
          global candidate1
          global candidate2
          global candidate3
          global total_count
          print(msg.topic + ' ' + str(msg.payload))
          msg1 = &quot;Candidate1:&quot;
          print(msg1)
          rx_msg = str(msg.payload)
          print(rx_msg)
          msg2 = &quot;Candidate2:&quot;
          print(msg2)
          total_count = total_count + 1
          f_total = open(&quot;total_count.txt&quot;,&quot;w&quot;)
          f_total.write(str(total_count))
          f_total.close()
          if msg1 == rx_msg:
              candidate1 = candidate1+1
              f_c1 = open(&quot;candidate1.txt&quot;,&quot;w&quot;)
              f_c1.write(str(candidate1))
              f_c1.close()
          elif msg2 == rx_msg:
              candidate2 = candidate2+1
              f_c2 = open(&quot;candidate2.txt&quot;,&quot;w&quot;)
              f_c2.write(str(candidate2))
              f_c2.close()
          else:
              candidate3 = candidate3+1
              f_c3 = open(&quot;candidate3.txt&quot;,&quot;w&quot;)
              f_c3.write(str(candidate3))
              f_c3.close()
      
      
      def parse_message(msg):
          &quot;&quot;&quot;This callback parses input is received&quot;&quot;&quot;
      
      def main():
          mqtt_client = mqtt.Client()
          mqtt_client.username_pw_set(MQTT_USER, MQTT_PASSWORD)
          mqtt_client.on_connect = on_connect
          mqtt_client.on_message = on_message
      
          mqtt_client.connect(MQTT_ADDRESS, 1883)
          mqtt_client.loop_forever()
      
      
      if __name__ == '__main__':
          print('MQTT to InfluxDB bridge')
          main()
  
  </code></pre>
  <p>Is there anything wrong in the code?</p>