@@ -116,6 +116,8 @@ def send_data(self, feed, value):
116
116
specified value to the feed identified by either name, key, or ID.
117
117
Returns a Data instance with details about the newly appended row of data.
118
118
Note that send_data now operates the same as append.
119
+ :param string feed: Name/Key/ID of Adafruit IO feed.
120
+ :param string value: Value to send.
119
121
"""
120
122
return self .create_data (feed , Data (value = value ))
121
123
@@ -126,6 +128,8 @@ def send_batch_data(self, feed, data_list):
126
128
ID, feed key, or feed name. Data must be an instance of the Data class
127
129
with at least a value property set on it. Returns a Data instance with
128
130
details about the newly appended row of data.
131
+ :param string feed: Name/Key/ID of Adafruit IO feed.
132
+ :param Data data_list: Multiple data values.
129
133
"""
130
134
path = "feeds/{0}/data/batch" .format (feed )
131
135
data_dict = type (data_list )((data ._asdict () for data in data_list ))
@@ -136,58 +140,57 @@ def append(self, feed, value):
136
140
specified value to the feed identified by either name, key, or ID.
137
141
Returns a Data instance with details about the newly appended row of data.
138
142
Note that unlike send the feed should exist before calling append.
143
+ :param string feed: Name/Key/ID of Adafruit IO feed.
144
+ :param string value: Value to append to feed.
139
145
"""
140
146
return self .create_data (feed , Data (value = value ))
141
147
142
- def send_location_data (self , feed , value , lat , lon , ele ):
143
- """Sends locational data to a feed
144
-
145
- args:
146
- - lat: latitude
147
- - lon: logitude
148
- - ele: elevation
149
- - (optional) value: value to send to the feed
148
+ def send_location_data (self , feed , lat , lon , ele , value = None ):
149
+ """Sends locational data to a feed.
150
+ :param string feed: Name/Key/ID of Adafruit IO feed.
151
+ :param int lat: Latitude.
152
+ :param int lon: Longitude.
153
+ :param int ele: Elevation.
154
+ :param int value: Optional value to send, defaults to None.
150
155
"""
151
- return self .create_data (feed , Data (value = value ,lat = lat , lon = lon , ele = ele ))
156
+ return self .create_data (feed , Data (value = value ,lat = lat , lon = lon , ele = ele ))
152
157
153
158
def receive_time (self , time ):
154
159
"""Returns the time from the Adafruit IO server.
155
-
156
- args:
157
- - time (string): millis, seconds, ISO-8601
160
+ :param string time: Time to be returned: `millis`, `seconds`, `ISO-8601`.
158
161
"""
159
162
timepath = "time/{0}" .format (time )
160
163
return self ._get (timepath , is_time = True )
161
164
162
165
def receive (self , feed ):
163
- """Retrieve the most recent value for the specified feed. Feed can be a
164
- feed ID, feed key, or feed name. Returns a Data instance whose value
165
- property holds the retrieved value .
166
+ """Retrieve the most recent value for the specified feed. Returns a Data
167
+ instance whose value property holds the retrieved value.
168
+ :param string feed: Name/Key/ID of Adafruit IO feed .
166
169
"""
167
170
path = "feeds/{0}/data/last" .format (feed )
168
171
return Data .from_dict (self ._get (path ))
169
172
170
173
def receive_next (self , feed ):
171
- """Retrieve the next unread value from the specified feed. Feed can be
172
- a feed ID, feed key, or feed name. Returns a Data instance whose value
173
- property holds the retrieved value .
174
+ """Retrieve the next unread value from the specified feed. Returns a Data
175
+ instance whose value property holds the retrieved value.
176
+ :param string feed: Name/Key/ID of Adafruit IO feed .
174
177
"""
175
178
path = "feeds/{0}/data/next" .format (feed )
176
179
return Data .from_dict (self ._get (path ))
177
180
178
181
def receive_previous (self , feed ):
179
- """Retrieve the previous unread value from the specified feed. Feed can
180
- be a feed ID, feed key, or feed name. Returns a Data instance whose
181
- value property holds the retrieved value .
182
+ """Retrieve the previous unread value from the specified feed. Returns a
183
+ Data instance whose value property holds the retrieved value.
184
+ :param string feed: Name/Key/ID of Adafruit IO feed .
182
185
"""
183
186
path = "feeds/{0}/data/previous" .format (feed )
184
187
return Data .from_dict (self ._get (path ))
185
188
186
189
def data (self , feed , data_id = None ):
187
- """Retrieve data from a feed. Feed can be a feed ID, feed key, or feed
188
- name. Data_id is an optional id for a single data value to retrieve .
189
- If data_id is not specified then all the data for the feed will be
190
- returned in an array .
190
+ """Retrieve data from a feed. If data_id is not specified then all the data
191
+ for the feed will be returned in an array .
192
+ :param string feed: Name/Key/ID of Adafruit IO feed.
193
+ :param string data_id: ID of the piece of data to delete .
191
194
"""
192
195
if data_id is None :
193
196
path = "feeds/{0}/data" .format (feed )
@@ -197,41 +200,46 @@ def data(self, feed, data_id=None):
197
200
return Data .from_dict (self ._get (path ))
198
201
199
202
def create_data (self , feed , data ):
200
- """Create a new row of data in the specified feed. Feed can be a feed
201
- ID, feed key, or feed name. Data must be an instance of the Data class
202
- with at least a value property set on it. Returns a Data instance with
203
- details about the newly appended row of data.
203
+ """Create a new row of data in the specified feed.
204
+ Returns a Data instance with details about the newly
205
+ appended row of data.
206
+ :param string feed: Name/Key/ID of Adafruit IO feed.
207
+ :param Data data: Instance of the Data class. Must have a value property set.
204
208
"""
205
209
path = "feeds/{0}/data" .format (feed )
206
210
return Data .from_dict (self ._post (path , data ._asdict ()))
207
211
208
212
def delete (self , feed , data_id ):
209
- """Delete data from a feed. Feed can be a feed ID, feed key, or feed
210
- name. Data_id must be the ID of the piece of data to delete.
213
+ """Delete data from a feed.
214
+ :param string feed: Name/Key/ID of Adafruit IO feed.
215
+ :param string data_id: ID of the piece of data to delete.
211
216
"""
212
217
path = "feeds/{0}/data/{1}" .format (feed , data_id )
213
218
self ._delete (path )
214
219
215
220
def toRed (self , data ):
216
- """Hex color feed to red channel.
221
+ """Hex color feed to red channel.
222
+ :param int data: Color value, in hexadecimal.
217
223
"""
218
224
return ((int (data [1 ], 16 ))* 16 ) + int (data [2 ], 16 )
219
225
220
226
def toGreen (self , data ):
221
227
"""Hex color feed to green channel.
228
+ :param int data: Color value, in hexadecimal.
222
229
"""
223
230
return (int (data [3 ], 16 ) * 16 ) + int (data [4 ], 16 )
224
231
225
232
def toBlue (self , data ):
226
- """Hex color feed to blue channel.
233
+ """Hex color feed to blue channel.
234
+ :param int data: Color value, in hexadecimal.
227
235
"""
228
236
return (int (data [5 ], 16 ) * 16 ) + int (data [6 ], 16 )
229
237
230
- # Feed functionality.
238
+ # feed functionality.
231
239
def feeds (self , feed = None ):
232
240
"""Retrieve a list of all feeds, or the specified feed. If feed is not
233
- specified a list of all feeds will be returned. If feed is specified it
234
- can be a feed name, key, or ID and the requested feed will be returned .
241
+ specified a list of all feeds will be returned.
242
+ :param string feed: Name/Key/ ID of Adafruit IO feed, defaults to None .
235
243
"""
236
244
if feed is None :
237
245
path = "feeds"
@@ -241,25 +249,23 @@ def feeds(self, feed=None):
241
249
return Feed .from_dict (self ._get (path ))
242
250
243
251
def create_feed (self , feed ):
244
- """Create the specified feed. Feed should be an instance of the Feed
245
- type with at least the name property set .
252
+ """Create the specified feed.
253
+ :param string feed: Name/Key/ID of Adafruit IO feed .
246
254
"""
247
255
path = "feeds/"
248
256
return Feed .from_dict (self ._post (path , {"feed" : feed ._asdict ()}))
249
257
250
258
def delete_feed (self , feed ):
251
- """Delete the specified feed. Feed can be a feed ID, feed key, or feed
252
- name .
259
+ """Delete the specified feed.
260
+ :param string feed: Name/Key/ID of Adafruit IO feed .
253
261
"""
254
262
path = "feeds/{0}" .format (feed )
255
263
self ._delete (path )
256
264
257
265
# Group functionality.
258
266
def groups (self , group = None ):
259
- """Retrieve a list of all groups, or the specified group. If group is
260
- not specified a list of all groups will be returned. If group is
261
- specified it can be a group name, key, or ID and the requested group
262
- will be returned.
267
+ """Retrieve a list of all groups, or the specified group.
268
+ :param string group: Name/Key/ID of Adafruit IO Group. Defaults to None.
263
269
"""
264
270
if group is None :
265
271
path = "groups/"
@@ -269,15 +275,15 @@ def groups(self, group=None):
269
275
return Group .from_dict (self ._get (path ))
270
276
271
277
def create_group (self , group ):
272
- """Create the specified group. Group should be an instance of the Group
273
- type with at least the name and feeds property set .
278
+ """Create the specified group.
279
+ :param string group: Name/Key/ID of Adafruit IO Group .
274
280
"""
275
281
path = "groups/"
276
282
return Group .from_dict (self ._post (path , group ._asdict ()))
277
283
278
284
def delete_group (self , group ):
279
- """Delete the specified group. Group can be a group ID, group key, or
280
- group name .
285
+ """Delete the specified group.
286
+ :param string group: Name/Key/ID of Adafruit IO Group .
281
287
"""
282
288
path = "groups/{0}" .format (group )
283
289
self ._delete (path )
0 commit comments