adafruit / Adafruit_CircuitPython_AdafruitIO

Adafruit IO for CircuitPython
http://io.adafruit.com
MIT License
49 stars 33 forks source link

IO_MQTT.unsubscribe doesn't unsubscribe group-key? (adafruit_io.py) #87

Closed awgrover closed 2 years ago

awgrover commented 2 years ago

In main, and 5.0.4, IO_MQTT.subscribe(feed_key=None,group_key="something") does self._client.subscribe("{0}/groups/{1}".format(self._user, group_key)). Note the group_key. But .unsubscribe() uses feed_key.

That seems like a bug. Wouldn't that fail to unsubscribe from the group?

Suggested patch for unsubscribe (vs 5.0.4, but almost identical fix for main).

--- adafruit_io.py      2022-03-29 10:03:10.891820967 -0400
+++ adafruit_io.py.fix  2022-04-08 11:15:09.378827819 -0400
@@ -334,7 +334,7 @@
         if shared_user is not None and feed_key is not None:
             self._client.unsubscribe("{0}/feeds/{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}/groups/{1}".format(self._user, group_key))
         elif feed_key is not None:
             self._client.unsubscribe("{0}/feeds/{1}".format(self._user, feed_key))
         else:
ladyada commented 2 years ago

could be a typo! please submit a PR :)