@@ -84,6 +84,8 @@ def __init__(self, mqtt_client):
8484 self ._client .on_connect = self ._on_connect_mqtt
8585 self ._client .on_disconnect = self ._on_disconnect_mqtt
8686 self ._client .on_message = self ._on_message_mqtt
87+ self ._client .on_subscribe = self ._on_subscribe_mqtt
88+ self ._client .on_unsubscribe = self ._on_unsubscribe_mqtt
8789 self ._logger = False
8890 # Write to the MiniMQTT logger, if avaliable.
8991 if self ._client .logger is not None :
@@ -182,6 +184,24 @@ def _on_message_mqtt(self, client, topic, payload):
182184 )
183185 self .on_message (self , topic_name , message )
184186
187+ # pylint: disable=not-callable
188+ def _on_subscribe_mqtt (self , client , user_data , topic , qos ):
189+ """Runs when the client calls on_subscribe.
190+ """
191+ if self ._logger :
192+ self ._client ._logger .debug ("Client called on_subscribe" )
193+ if self .on_subscribe is not None :
194+ self .on_subscribe (self , user_data , topic , qos )
195+
196+ # pylint: disable=not-callable
197+ def _on_unsubscribe_mqtt (self , client , user_data , topic , pid ):
198+ """Runs when the client calls on_unsubscribe.
199+ """
200+ if self ._logger :
201+ self ._client ._logger .debug ("Client called on_unsubscribe" )
202+ if self .on_unsubscribe is not None :
203+ self .on_unsubscribe (self , user_data , topic , pid )
204+
185205 def loop (self ):
186206 """Manually process messages from Adafruit IO.
187207 Call this method to check incoming subscription messages.
0 commit comments