@@ -69,7 +69,7 @@ def __init__(self, mqtt_client):
69
69
)
70
70
# MiniMQTT's username kwarg is optional, IO requires a username
71
71
try :
72
- self ._user = self ._client ._user
72
+ self ._user = self ._client .user
73
73
except :
74
74
raise TypeError (
75
75
"Adafruit IO requires a username, please set one in MiniMQTT"
@@ -84,9 +84,11 @@ def __init__(self, mqtt_client):
84
84
self ._client .on_connect = self ._on_connect_mqtt
85
85
self ._client .on_disconnect = self ._on_disconnect_mqtt
86
86
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
87
89
self ._logger = False
88
90
# Write to the MiniMQTT logger, if avaliable.
89
- if self ._client ._logger is not None :
91
+ if self ._client .logger is not None :
90
92
self ._logger = True
91
93
self ._client .set_logger_level ("DEBUG" )
92
94
self ._connected = False
@@ -182,6 +184,24 @@ def _on_message_mqtt(self, client, topic, payload):
182
184
)
183
185
self .on_message (self , topic_name , message )
184
186
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
+
185
205
def loop (self ):
186
206
"""Manually process messages from Adafruit IO.
187
207
Call this method to check incoming subscription messages.
0 commit comments