Skip to content

Commit

Permalink
Merge pull request #98 from makermelissa/ioclient
Browse files Browse the repository at this point in the history
Add delete_io_data and expose io_client
  • Loading branch information
makermelissa authored Nov 8, 2023
2 parents f628e3e + 50ca742 commit ec9c8db
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions adafruit_portalbase/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PortalBase.git"

# pylint: disable=line-too-long, too-many-lines
# pylint: disable=line-too-long, too-many-lines, too-many-public-methods
# you'll need to pass in an io username and key
TIME_SERVICE = (
"https://io.adafruit.com/api/v2/%s/integrations/time/strftime?x-aio-key=%s"
Expand Down Expand Up @@ -493,8 +493,6 @@ def get_io_feed(self, feed_key, detailed=False):
except RuntimeError as exception:
print("An error occured, retrying! 1 -", exception)
continue
break
return None

def get_io_group(self, group_key):
"""Return the Adafruit IO Group that matches the group key
Expand All @@ -510,8 +508,6 @@ def get_io_group(self, group_key):
except RuntimeError as exception:
print("An error occured, retrying! 1 -", exception)
continue
break
return None

def get_io_data(self, feed_key):
"""Return all values from Adafruit IO Feed Data that matches the feed key
Expand All @@ -527,8 +523,21 @@ def get_io_data(self, feed_key):
except RuntimeError as exception:
print("An error occured, retrying! 1 -", exception)
continue
break
return None

def delete_io_data(self, feed_key: str, data_id: str):
"""Return all values from Adafruit IO Feed Data that matches the feed key
:param str feed_key: Name of feed key to receive data from.
"""
io_client = self._get_io_client()

while True:
try:
return io_client.delete_data(feed_key, data_id)
except RuntimeError as exception:
print("An error occured, retrying! 1 -", exception)
continue

def fetch(self, url, *, headers=None, timeout=10):
"""Fetch data from the specified url and return a response object
Expand Down Expand Up @@ -740,3 +749,8 @@ def process_json(self, json_data, json_path):
def is_connected(self):
"""Return whether we are connected."""
return self._wifi.is_connected

@property
def io_client(self):
"""Return the Adafruit IO Client."""
return self._get_io_client()

0 comments on commit ec9c8db

Please sign in to comment.