File tree Expand file tree Collapse file tree 3 files changed +20
-66
lines changed Expand file tree Collapse file tree 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):
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 number Diff line number Diff line change 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.
68from 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.
1821aio = 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.' )
2228forecast = aio .receive_weather (2153 )
23-
2429print (forecast )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments