Skip to content

Switch to small feed/group format #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions adafruit_io/adafruit_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def add_feed_callback(self, feed_key, callback_method):

"""
self._client.add_topic_callback(
"{0}/feeds/{1}".format(self._user, feed_key), callback_method
"{0}/f/{1}".format(self._user, feed_key), callback_method
)

def remove_feed_callback(self, feed_key):
Expand All @@ -214,7 +214,7 @@ def remove_feed_callback(self, feed_key):
:param str feed_key: Adafruit IO feed key.

"""
self._client.remove_topic_callback("{0}/feeds/{1}".format(self._user, feed_key))
self._client.remove_topic_callback("{0}/f/{1}".format(self._user, feed_key))

def loop(self):
"""Manually process messages from Adafruit IO.
Expand Down Expand Up @@ -251,11 +251,11 @@ def subscribe(self, feed_key=None, group_key=None, shared_user=None):
client.subscribe([('temperature'), ('humidity')])
"""
if shared_user is not None and feed_key is not None:
self._client.subscribe("{0}/feeds/{1}".format(shared_user, feed_key))
self._client.subscribe("{0}/f/{1}".format(shared_user, feed_key))
elif group_key is not None:
self._client.subscribe("{0}/groups/{1}".format(self._user, group_key))
self._client.subscribe("{0}/g/{1}".format(self._user, group_key))
elif feed_key is not None:
self._client.subscribe("{0}/feeds/{1}".format(self._user, feed_key))
self._client.subscribe("{0}/f/{1}".format(self._user, feed_key))
else:
raise AdafruitIO_MQTTError("Must provide a feed_key or group_key.")

Expand Down Expand Up @@ -332,11 +332,11 @@ def unsubscribe(self, feed_key=None, group_key=None, shared_user=None):

"""
if shared_user is not None and feed_key is not None:
self._client.unsubscribe("{0}/feeds/{1}".format(shared_user, feed_key))
self._client.unsubscribe("{0}/f/{1}".format(shared_user, feed_key))
elif group_key is not None:
self._client.unsubscribe("{0}/groups/{1}".format(self._user, feed_key))
self._client.unsubscribe("{0}/g/{1}".format(self._user, feed_key))
elif feed_key is not None:
self._client.unsubscribe("{0}/feeds/{1}".format(self._user, feed_key))
self._client.unsubscribe("{0}/f/{1}".format(self._user, feed_key))
else:
raise AdafruitIO_MQTTError("Must provide a feed_key or group_key.")

Expand Down Expand Up @@ -416,18 +416,18 @@ def publish(self, feed_key, data, metadata=None, shared_user=None, is_group=Fals

"""
if is_group:
self._client.publish("{0}/groups/{1}".format(self._user, feed_key), data)
self._client.publish("{0}/g/{1}".format(self._user, feed_key), data)
if shared_user is not None:
self._client.publish("{0}/feeds/{1}".format(shared_user, feed_key), data)
self._client.publish("{0}/f/{1}".format(shared_user, feed_key), data)
if metadata is not None:
if isinstance(data, int or float):
data = str(data)
csv_string = data + "," + metadata
self._client.publish(
"{0}/feeds/{1}/csv".format(self._user, feed_key), csv_string
"{0}/f/{1}/csv".format(self._user, feed_key), csv_string
)
else:
self._client.publish("{0}/feeds/{1}".format(self._user, feed_key), data)
self._client.publish("{0}/f/{1}".format(self._user, feed_key), data)

def get(self, feed_key):
"""Calling this method will make Adafruit IO publish the most recent
Expand All @@ -440,7 +440,7 @@ def get(self, feed_key):

io.get('temperature')
"""
self._client.publish("{0}/feeds/{1}/get".format(self._user, feed_key), "\0")
self._client.publish("{0}/f/{1}/get".format(self._user, feed_key), "\0")


class IO_HTTP:
Expand Down