Skip to content

Commit b6debfc

Browse files
author
brentru
committedJan 8, 2019
make weather_id an optional param, update example
1 parent fbbfe8f commit b6debfc

File tree

3 files changed

+20
-66
lines changed

3 files changed

+20
-66
lines changed
 

Diff for: ‎Adafruit_IO/client.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,14 @@ def receive_time(self, time):
162162
timepath = "time/{0}".format(time)
163163
return self._get(timepath, is_time=True)
164164

165-
def receive_weather(self, weather_id):
166-
"""Get the specified weather record with current weather and all available forecast information.
167-
:param int id: ID for forecast
165+
def receive_weather(self, weather_id=None):
166+
"""Adafruit IO Weather Service, Powered by Dark Sky
167+
:param int id: optional ID for retrieving a specified weather record.
168168
"""
169-
weatherpath = "integrations/weather/{0}".format(weather_id)
169+
if weather_id:
170+
weatherpath = "integrations/weather/{0}".format(weather_id)
171+
else:
172+
weatherpath = "integrations/weather"
170173
return self._get(weatherpath)
171174

172175
def receive(self, feed):
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
"""
2-
Example of getting a darkskies forecast
3-
from Adafruit IO.
2+
Example of getting a forecast from Adafruit IO
3+
Note: This functionality is for IO PLUS users ONLY.
4+
5+
Author: Brent Rubell for Adafruit Industries
46
"""
57
# import Adafruit IO REST client.
68
from Adafruit_IO import Client, Feed, RequestError
79

10+
# Set to your Adafruit IO username.
11+
# (go to https://accounts.adafruit.com to find your username)
12+
ADAFRUIT_IO_USERNAME = 'USER'
13+
814
# Set to your Adafruit IO key.
915
# Remember, your key is a secret,
1016
# so make sure not to publish it when you publish this code!
11-
ADAFRUIT_IO_KEY = 'PASS'
17+
ADAFRUIT_IO_KEY = 'PASSWORD'
1218

13-
# Set to your Adafruit IO username.
14-
# (go to https://accounts.adafruit.com to find your username)
15-
ADAFRUIT_IO_USERNAME = 'USER'
1619

1720
# Create an instance of the REST client.
1821
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)
1922

23+
print('Get all weather integration records without their current forecast values.')
24+
records = aio.receive_weather()
25+
print(records)
2026

21-
27+
print('Get the specified weather record with current weather and all available forecast information.')
2228
forecast = aio.receive_weather(2153)
23-
2429
print(forecast)

Diff for: ‎examples/basics/digital_in.py

-54
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.