Skip to content

Commit 8e0c359

Browse files
committed
Add send_group_multiple_data method
1 parent c3d2a66 commit 8e0c359

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Adafruit_IO/client.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,26 @@ def send_batch_data(self, feed, data_list):
204204
data_dict = type(data_list)((data._asdict() for data in data_list))
205205
self._post(path, {"data": data_dict})
206206

207+
def send_group_multiple_data(self, group, data_list):
208+
"""Create a new row of data in the specified group. Group can be a group
209+
ID, group key, or group name. Data must be a list of GroupFeedData objects, or
210+
a Dict with a feeds property, containing a list of GroupFeedData objects with
211+
at least a value property and key set on it. Optionally, metadata (created_at,
212+
lat/lon/ele) can be set at the root object level.
213+
Returns a Data instance with details about the newly appended rows of data.
214+
215+
:param string group: Name/Key/ID of Adafruit IO group.
216+
:param List[GroupFeedData]|Dict data_list: Multiple data values with keys.
217+
"""
218+
path = "groups/{0}/data".format(group)
219+
if isinstance(data_list, list):
220+
data_dict = {"feeds": [data._asdict() for data in data_list]}
221+
elif isinstance(data_list, dict):
222+
data_dict = data_list
223+
else:
224+
raise TypeError("data_list must be a dict or list")
225+
self._post(path, data_dict)
226+
207227
def append(self, feed, value):
208228
"""Helper function to simplify adding a value to a feed. Will append the
209229
specified value to the feed identified by either name, key, or ID.

0 commit comments

Comments
 (0)