File tree 3 files changed +20
-66
lines changed
3 files changed +20
-66
lines changed Original file line number Diff line number Diff line change @@ -162,11 +162,14 @@ def receive_time(self, time):
162
162
timepath = "time/{0}" .format (time )
163
163
return self ._get (timepath , is_time = True )
164
164
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.
168
168
"""
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"
170
173
return self ._get (weatherpath )
171
174
172
175
def receive (self , feed ):
Original file line number Diff line number Diff line change 1
1
"""
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
4
6
"""
5
7
# import Adafruit IO REST client.
6
8
from Adafruit_IO import Client , Feed , RequestError
7
9
10
+ # Set to your Adafruit IO username.
11
+ # (go to https://accounts.adafruit.com to find your username)
12
+ ADAFRUIT_IO_USERNAME = 'USER'
13
+
8
14
# Set to your Adafruit IO key.
9
15
# Remember, your key is a secret,
10
16
# so make sure not to publish it when you publish this code!
11
- ADAFRUIT_IO_KEY = 'PASS '
17
+ ADAFRUIT_IO_KEY = 'PASSWORD '
12
18
13
- # Set to your Adafruit IO username.
14
- # (go to https://accounts.adafruit.com to find your username)
15
- ADAFRUIT_IO_USERNAME = 'USER'
16
19
17
20
# Create an instance of the REST client.
18
21
aio = Client (ADAFRUIT_IO_USERNAME , ADAFRUIT_IO_KEY )
19
22
23
+ print ('Get all weather integration records without their current forecast values.' )
24
+ records = aio .receive_weather ()
25
+ print (records )
20
26
21
-
27
+ print ( 'Get the specified weather record with current weather and all available forecast information.' )
22
28
forecast = aio .receive_weather (2153 )
23
-
24
29
print (forecast )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments