Skip to content

Commit 4affb39

Browse files
authored
Merge pull request #61 from brentru/small-feed-names
Switch to small feed/group format
2 parents 2d0717c + 024192a commit 4affb39

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

adafruit_io/adafruit_io.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def add_feed_callback(self, feed_key, callback_method):
202202
203203
"""
204204
self._client.add_topic_callback(
205-
"{0}/feeds/{1}".format(self._user, feed_key), callback_method
205+
"{0}/f/{1}".format(self._user, feed_key), callback_method
206206
)
207207

208208
def remove_feed_callback(self, feed_key):
@@ -214,7 +214,7 @@ def remove_feed_callback(self, feed_key):
214214
:param str feed_key: Adafruit IO feed key.
215215
216216
"""
217-
self._client.remove_topic_callback("{0}/feeds/{1}".format(self._user, feed_key))
217+
self._client.remove_topic_callback("{0}/f/{1}".format(self._user, feed_key))
218218

219219
def loop(self):
220220
"""Manually process messages from Adafruit IO.
@@ -251,11 +251,11 @@ def subscribe(self, feed_key=None, group_key=None, shared_user=None):
251251
client.subscribe([('temperature'), ('humidity')])
252252
"""
253253
if shared_user is not None and feed_key is not None:
254-
self._client.subscribe("{0}/feeds/{1}".format(shared_user, feed_key))
254+
self._client.subscribe("{0}/f/{1}".format(shared_user, feed_key))
255255
elif group_key is not None:
256-
self._client.subscribe("{0}/groups/{1}".format(self._user, group_key))
256+
self._client.subscribe("{0}/g/{1}".format(self._user, group_key))
257257
elif feed_key is not None:
258-
self._client.subscribe("{0}/feeds/{1}".format(self._user, feed_key))
258+
self._client.subscribe("{0}/f/{1}".format(self._user, feed_key))
259259
else:
260260
raise AdafruitIO_MQTTError("Must provide a feed_key or group_key.")
261261

@@ -332,11 +332,11 @@ def unsubscribe(self, feed_key=None, group_key=None, shared_user=None):
332332
333333
"""
334334
if shared_user is not None and feed_key is not None:
335-
self._client.unsubscribe("{0}/feeds/{1}".format(shared_user, feed_key))
335+
self._client.unsubscribe("{0}/f/{1}".format(shared_user, feed_key))
336336
elif group_key is not None:
337-
self._client.unsubscribe("{0}/groups/{1}".format(self._user, feed_key))
337+
self._client.unsubscribe("{0}/g/{1}".format(self._user, feed_key))
338338
elif feed_key is not None:
339-
self._client.unsubscribe("{0}/feeds/{1}".format(self._user, feed_key))
339+
self._client.unsubscribe("{0}/f/{1}".format(self._user, feed_key))
340340
else:
341341
raise AdafruitIO_MQTTError("Must provide a feed_key or group_key.")
342342

@@ -416,18 +416,18 @@ def publish(self, feed_key, data, metadata=None, shared_user=None, is_group=Fals
416416
417417
"""
418418
if is_group:
419-
self._client.publish("{0}/groups/{1}".format(self._user, feed_key), data)
419+
self._client.publish("{0}/g/{1}".format(self._user, feed_key), data)
420420
if shared_user is not None:
421-
self._client.publish("{0}/feeds/{1}".format(shared_user, feed_key), data)
421+
self._client.publish("{0}/f/{1}".format(shared_user, feed_key), data)
422422
if metadata is not None:
423423
if isinstance(data, int or float):
424424
data = str(data)
425425
csv_string = data + "," + metadata
426426
self._client.publish(
427-
"{0}/feeds/{1}/csv".format(self._user, feed_key), csv_string
427+
"{0}/f/{1}/csv".format(self._user, feed_key), csv_string
428428
)
429429
else:
430-
self._client.publish("{0}/feeds/{1}".format(self._user, feed_key), data)
430+
self._client.publish("{0}/f/{1}".format(self._user, feed_key), data)
431431

432432
def get(self, feed_key):
433433
"""Calling this method will make Adafruit IO publish the most recent
@@ -440,7 +440,7 @@ def get(self, feed_key):
440440
441441
io.get('temperature')
442442
"""
443-
self._client.publish("{0}/feeds/{1}/get".format(self._user, feed_key), "\0")
443+
self._client.publish("{0}/f/{1}/get".format(self._user, feed_key), "\0")
444444

445445

446446
class IO_HTTP:

0 commit comments

Comments
 (0)