@@ -213,12 +213,24 @@ def subscribe_time(self, time):
213
213
raise TypeError ('Invalid Time Feed Specified.' )
214
214
return
215
215
216
- def unsubscribe (self , feed_id ):
217
- """Unsubscribes from a specified MQTT feed .
218
- Note: this does not prevent publishing to a feed , it will unsubscribe
216
+ def unsubscribe (self , feed_id = None , group_id = None ):
217
+ """Unsubscribes from a specified MQTT topic .
218
+ Note: this does not prevent publishing to a topic , it will unsubscribe
219
219
from receiving messages via on_message.
220
220
"""
221
- (res , mid ) = self ._client .unsubscribe ('{0}/feeds/{1}' .format (self ._username , feed_id ))
221
+ if feed_id is not None :
222
+ self ._client .unsubscribe ('{0}/feeds/{1}' .format (self ._username , feed_id ))
223
+ elif group_id is not None :
224
+ self ._client .unsubscribe ('{0}/groups/{1}' .format (self ._username , group_id ))
225
+ else :
226
+ raise TypeError ('Invalid topic type specified.' )
227
+ return
228
+
229
+ def publish_group (self , group_id , feed_id , value = None ):
230
+ """Publish a value to a specified feed within a group
231
+ """
232
+ pub_string = '{0}/feeds/{1}.{2}' .format (self ._username , group_id , feed_id )
233
+ self ._client .publish ('{0}/feeds/{1}.{2}' .format (self ._username , group_id , feed_id ), payload = value )
222
234
223
235
def publish (self , feed_id , value = None , feed_user = None ):
224
236
"""Publish a value to a specified feed.
@@ -233,4 +245,4 @@ def publish(self, feed_id, value=None, feed_user=None):
233
245
payload = value )
234
246
else :
235
247
(res , self ._pub_mid ) = self ._client .publish ('{0}/feeds/{1}' .format (self ._username , feed_id ),
236
- payload = value )
248
+ payload = value )
0 commit comments