-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added logging, and documented rate limiting in test.py
- Loading branch information
avryhof
committed
Oct 26, 2018
1 parent
3b2cb70
commit ac4ad87
Showing
4 changed files
with
86 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,3 +196,4 @@ gen### VisualStudioCode template | |
!.vscode/extensions.json | ||
|
||
/*.env | ||
/ambient_api.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
import datetime | ||
import pprint | ||
import time | ||
|
||
from ambient_api.ambientapi import AmbientAPI | ||
|
||
weather = AmbientAPI() | ||
weather = AmbientAPI(log_level='CONSOLE') | ||
|
||
devices = weather.get_devices() | ||
|
||
for device in devices: | ||
# Wait two seconds between requests so we don't get a 429 response. | ||
# https://ambientweather.docs.apiary.io/#introduction/rate-limiting | ||
# This probably won't happen much in real world situations. | ||
time.sleep(2) | ||
print('Device') | ||
print(str(device)) | ||
|
||
print('Last Data') | ||
pprint.pprint(device.last_data) | ||
|
||
print('Get Data') | ||
pprint.pprint(device.get_data(end_date=datetime.datetime(year=2018, month=10, day=1))) | ||
pprint.pprint(device.get_data()) |