Skip to content

Commit b2b8b18

Browse files
author
brentru
committed
same line on example
1 parent 25538f9 commit b2b8b18

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

examples/mqtt/mqtt_weather.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,18 @@ def message(client, topic, payload):
9191
parseForecast(five_day_forecast)
9292

9393
def parseForecast(forecast_data):
94-
"""Parses incoming forecast data
94+
"""Parses and prints incoming forecast data
9595
"""
9696
# incoming data is a utf-8 string, encode it as a json object
9797
forecast = json.loads(forecast_data)
98+
99+
# Print out the forecast
98100
try:
99-
print('It is {0} and of {1}F.'.format(forecast['summary'], forecast['temperature']))
101+
print('It is {0} and {1}F.'.format(forecast['summary'], forecast['temperature']))
100102
except KeyError:
101103
# future weather forecasts return a high and low temperature, instead of 'temperature'
102104
print('It will be {0} with a high of {1}F and a low of {2}F.'.format(forecast['summary'], forecast['temperatureLow'], forecast['temperatureHigh']))
103-
print('with a humidity of {0}% and a wind speed of {1}mph.'.format(forecast['humidity'], forecast['windSpeed']))
104-
print('There is a {0}% chance of precipitation.'.format(forecast['precipProbability']))
105+
print('with a humidity of {0}%, a wind speed of {1}mph, and a {2}% chance of precipitation.'.format(forecast['humidity'], forecast['windSpeed'], forecast['precipProbability']))
105106

106107
# Create an MQTT client instance.
107108
client = MQTTClient(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)
@@ -117,4 +118,4 @@ def parseForecast(forecast_data):
117118
# Start a message loop that blocks forever waiting for MQTT messages to be
118119
# received. Note there are other options for running the event loop like doing
119120
# so in a background thread--see the mqtt_client.py example to learn more.
120-
client.loop_blocking()
121+
client.loop_blocking()

0 commit comments

Comments
 (0)