Skip to content

Commit aca9f67

Browse files
author
brentru
committed
redo parser
1 parent e0904c6 commit aca9f67

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Adafruit_IO/mqtt_client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ def _mqtt_message(self, client, userdata, msg):
108108
assume topic looks like `username/topic/id`
109109
"""
110110
parsed_topic = msg.topic.split('/')
111-
if self.on_message is not None:
112-
topic = parsed_topic[1]
113-
payload = '' if msg.payload is None else msg.payload.decode('utf-8')
114-
elif self.on_message is not None and parsed_topic[2] == 'weather':
111+
print(parsed_topic) # BR: Remove this
112+
if self.on_message is not None and parsed_topic[2] == 'weather':
113+
print('Weather Subscription')
115114
topic = parsed_topic[4]
116115
payload = '' if msg.payload is None else msg.payload.decode('utf-8')
117116
elif self.on_message is not None and parsed_topic[0] == 'time':
@@ -120,6 +119,9 @@ def _mqtt_message(self, client, userdata, msg):
120119
elif self.on_message is not None and parsed_topic[1] == 'groups':
121120
topic = parsed_topic[3]
122121
payload = msg.payload.decode('utf-8')
122+
else:
123+
topic = parsed_topic[1]
124+
payload = '' if msg.payload is None else msg.payload.decode('utf-8')
123125
self.on_message(self, topic, payload)
124126

125127
def _mqtt_subscribe(client, userdata, mid, granted_qos):

0 commit comments

Comments
 (0)