Skip to content

Commit e0904c6

Browse files
author
brentru
committed
add forecast topic to mqtt message parser
1 parent 6752497 commit e0904c6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Adafruit_IO/mqtt_client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ def _mqtt_message(self, client, userdata, msg):
109109
"""
110110
parsed_topic = msg.topic.split('/')
111111
if self.on_message is not None:
112-
topic = parsed_topic[2]
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':
115+
topic = parsed_topic[4]
113116
payload = '' if msg.payload is None else msg.payload.decode('utf-8')
114117
elif self.on_message is not None and parsed_topic[0] == 'time':
115118
topic = parsed_topic[0]
@@ -211,6 +214,7 @@ def subscribe_weather(self, weather_id, forecast_type):
211214
self._client.subscribe('{0}/integration/weather/{1}/{2}'.format(self._username, weather_id, forecast_type))
212215
else:
213216
raise TypeError("Invalid Forecast Type Specified.")
217+
return
214218

215219
def subscribe_time(self, time):
216220
"""Subscribe to changes on the Adafruit IO time feeds. When the feed is

0 commit comments

Comments
 (0)