Skip to content

Add Adafruit IO REST Client, Examples, and more! #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 48 commits into from
Feb 22, 2019

Conversation

brentru
Copy link
Member

@brentru brentru commented Feb 21, 2019

Ready for public consumption and review!

Adding:

  • adafruit_io.py: CircuitPython Adafruit IO REST Client
  • examples: Usage examples for the library (sensor communication, feed interaction, data, metadata)
    • note: examples reference wifi_settings.py, instead of esp32_ to allow for an identical WiFiManager class in the Adafruit_CircuitPython_ESP_ATcontrol library.
  • Cookiecutter'd files

Examples tested on a PyPortal running CircuitPython 4 Beta 2 prior to PR'ing

@brentru brentru requested review from jerryneedell and a team February 21, 2019 22:23
@jerryneedell
Copy link

jerryneedell commented Feb 22, 2019

@brentru the weather example failes:

>>> import adafruit_io_simpletest_weather
Getting weather record from IO...
Failed to connect, retrying
 ('No such ssid', b'Needell Airport')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "adafruit_io_simpletest_weather.py", line 59, in <module>
  File "adafruit_io/adafruit_io.py", line 230, in receive_weather
  File "adafruit_io/adafruit_io.py", line 108, in _get
  File "adafruit_io/adafruit_io.py", line 81, in _handle_error
AdafruitIO_RequestError: Adafruit IO Error 404: not found - API documentation can be found at https://io.adafruit.com/api/docs

the randomizer test also fails with 404
temparature test works fine

@brentru
Copy link
Member Author

brentru commented Feb 22, 2019

@jerryneedell The location_id in the example is set to a placeholder. You'd need to visit https://io.adafruit.com/your_username/services/weather and add a location to obtain the location_id. I'll make a note in the comments. You also need an active IO Plus subscription for that example.

@jerryneedell
Copy link

got it -- working now

@jerryneedell
Copy link

jerryneedell commented Feb 22, 2019

How do I get the time correctly -- I think I got millis and seconds OK , but how do I print the ISO-8601 time?
I could not find any info in the API docs -- did I miss it?
Here is what I tried

time_ms = io.receive_time("millis")
print(time_ms)
time_sec = io.receive_time("seconds")
print(time_sec)
time_ISO = io.receive_time("ISO-8601")
print(time_ISO)

1550866462822
1550866465
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "aio_time.py", line 61, in <module>
  File "adafruit_io/adafruit_io.py", line 246, in receive_time
  File "adafruit_io/adafruit_io.py", line 109, in _get
  File "adafruit_esp32spi/adafruit_esp32spi_requests.py", line 110, in json
ValueError: invalid syntax for integer with base 10
>>> 

it fails on the call to io.receive_time("ISO-8601")
not on the print

@brentru
Copy link
Member Author

brentru commented Feb 22, 2019

@jerryneedell Fixed in this commit.

1550869727066
1550869729
2019-02-22T21:08:53+00:00 

@jerryneedell
Copy link

great! downloaded and ran -- worked great!

Copy link

@jerryneedell jerryneedell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested all the examples via a feather nrf52840 and ESP32 (ESPRESIF devKit) -- all work fine!
The code looks good to me -- I think this is ready to merge and get more folks using it.

@brentru
Copy link
Member Author

brentru commented Feb 22, 2019

@jerryneedell thanks, just did a re-test on a fresh install of 4.0b2. Merging

@brentru brentru merged commit f34ad8c into adafruit:master Feb 22, 2019
Copy link
Collaborator

@sommersoft sommersoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this got merged while I was looking it over; makes sense as it was approved. 😄

But, wanted to make note of a couple things.

This does look like it was a fun one to work on!

brentru pushed a commit that referenced this pull request Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants