Skip to content

Commit af518a2

Browse files
brentrubrentru
authored andcommitted
update readme, setup, lib
1 parent 03396c0 commit af518a2

File tree

3 files changed

+28
-55
lines changed

3 files changed

+28
-55
lines changed

README.rst

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,49 +27,30 @@ Please ensure all dependencies are available on the CircuitPython filesystem.
2727
This is easily achieved by downloading
2828
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
2929

30-
Installing from PyPI
31-
--------------------
32-
.. note:: This library is not available on PyPI yet. Install documentation is included
33-
as a standard element. Stay tuned for PyPI availability!
34-
.. todo:: Remove the above note if PyPI version is/will be available at time of release.
35-
If the library is not planned for PyPI, remove the entire 'Installing from PyPI' section.
36-
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
37-
PyPI <https://pypi.org/project/adafruit-circuitpython-adafruit_io/>`_. To install for current user:
38-
39-
.. code-block:: shell
40-
41-
pip3 install adafruit-circuitpython-adafruit_io
42-
43-
To install system-wide (this may be required in some cases):
44-
45-
.. code-block:: shell
46-
47-
sudo pip3 install adafruit-circuitpython-adafruit_io
48-
49-
To install in a virtual environment in your current project:
50-
51-
.. code-block:: shell
52-
53-
mkdir project-name && cd project-name
54-
python3 -m venv .env
55-
source .env/bin/activate
56-
pip3 install adafruit-circuitpython-adafruit_io
57-
5830
Usage Example
5931
=============
6032

6133
Create an Adafruit IO Client object
6234
.. code-block:: python
63-
aio = adafruit_io.Client(ADAFRUIT_IO_USER, ADAFRUIT_IO_KEY, wifi)
35+
io = RESTClient(ADAFRUIT_IO_USER, ADAFRUIT_IO_KEY, wifi)
6436
6537
Sending `data` to an Adafruit IO feed
6638
.. code-block:: python
67-
aio.send_data(my_adafruit_io_feed, data)
39+
io.send_data(feed, data)
6840
6941
Receiving `data` from an Adafruit IO feed
7042
.. code-block:: python
71-
data = aio.receive_data(my_adafruit_io_feed)
43+
data = io.receive_data(feed)
44+
45+
Creating a new feed named `circuitpython` with a description
46+
.. code-block:: python
47+
feed = io.create_new_feed('circuitpython', 'an Adafruit IO CircuitPython feed')
48+
49+
Listing the record of a specified feed:
50+
.. code-block:: python
51+
feed = io.get_feed('circuitpython')
7252
53+
More usage examples are included in the `examples folder of this repository<<https://github.com/adafruit/Adafruit_CircuitPython_Adafruit_IO/blob/examples>`_
7354

7455
Contributing
7556
============

adafruit_io.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
2626
A CircuitPython/Python library for communicating with Adafruit IO
2727
28-
2928
* Author(s): Brent Rubell for Adafruit Industries
3029
3130
Implementation Notes
@@ -40,19 +39,17 @@
4039
https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI
4140
"""
4241

43-
# imports
44-
4542
__version__ = "0.0.0-auto.0"
4643
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Adafruit_IO.git"
4744

4845
class AdafruitIO_ThrottleError(Exception):
49-
"""Adafruit IO request error class for Throttle Errors"""
46+
"""Adafruit IO request error class for rate-limiting"""
5047
def __init__(self):
5148
super(AdafruitIO_ThrottleError, self).__init__("Number of Adafruit IO Requests exceeded! \
5249
Please try again in 30 seconds..")
5350

5451
class AdafruitIO_RequestError(Exception):
55-
"""Base Adafruit IO request error class"""
52+
"""Adafruit IO request error class"""
5653
def __init__(self, response):
5754
response_content = response.json()
5855
error = response_content['error']
@@ -63,18 +60,15 @@ class RESTClient():
6360
"""
6461
REST Client for interacting with the Adafruit IO API.
6562
"""
66-
def __init__(self, username, key, wifi_manager, api_version='v2'):
67-
"""
68-
Creates an instance of the Adafruit IO REST Client
69-
:param str username: Adafruit IO Username
70-
:param str key: Adafruit IO Key
71-
:param wifi_manager: WiFiManager Object
72-
:param str api_version: Adafruit IO REST API Version
73-
"""
74-
self.api_version = api_version
75-
self.url = 'https://io.adafruit.com/api'
76-
self.username = username
77-
self.key = key
63+
def __init__(self, adafruit_io_username, adafruit_io_key, wifi_manager):
64+
"""
65+
Creates an instance of the Adafruit IO REST Client.
66+
:param str adafruit_io_username: Adafruit IO Username
67+
:param str adafruit_io_key: Adafruit IO Key
68+
:param wifi_manager: WiFiManager object from adafruit_esp32spi_wifimanager
69+
"""
70+
self.username = adafruit_io_username
71+
self.key = adafruit_io_key
7872
if wifi_manager:
7973
self.wifi = wifi_manager
8074
else:
@@ -96,10 +90,9 @@ def _handle_error(response):
9690
raise AdafruitIO_RequestError(response)
9791
elif response.status_code >= 400:
9892
raise AdafruitIO_RequestError(response)
99-
# no error? do nothing
10093

10194
def _compose_path(self, path):
102-
return "{0}/{1}/{2}/{3}".format(self.url, self.api_version, self.username, path)
95+
return "{0}/{1}/{2}/{3}".format('https://io.adafruit.com/api', 'v2', self.username, path)
10396

10497
# HTTP Requests
10598
def _post(self, path, payload):
@@ -184,7 +177,8 @@ def create_new_group(self, group_key, group_description):
184177
:param str group_description: Brief summary about the group
185178
"""
186179
path = self._compose_path("groups")
187-
payload = {'name':group_key, 'description':group_description}
180+
payload = {'name':group_key,
181+
'description':group_description}
188182
return self._post(path, payload)
189183

190184
def delete_group(self, group_key):

setup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
long_description = f.read()
1818

1919
setup(
20-
name='adafruit-circuitpython-adafruit_io',
20+
name='adafruit-circuitpython-adafruitio',
2121

2222
use_scm_version=True,
2323
setup_requires=['setuptools_scm'],
@@ -27,7 +27,7 @@
2727
long_description_content_type='text/x-rst',
2828

2929
# The project's main homepage.
30-
url='https://github.com/adafruit/Adafruit_CircuitPython_Adafruit_IO',
30+
url='https://github.com/adafruit/Adafruit_CircuitPython_AdafruitIO',
3131

3232
# Author details
3333
author='Adafruit Industries',
@@ -59,7 +59,5 @@
5959

6060
# You can just specify the packages manually here if your project is
6161
# simple. Or you can use find_packages().
62-
# TODO: IF LIBRARY FILES ARE A PACKAGE FOLDER,
63-
# CHANGE `py_modules=['...']` TO `packages=['...']`
6462
py_modules=['adafruit_adafruit_io'],
6563
)

0 commit comments

Comments
 (0)