@@ -65,7 +65,6 @@ def __init__(
65
65
)
66
66
self ._mqtt_client = None
67
67
self .mqtt_connect = None
68
- self ._mqtt_publish = None
69
68
70
69
def init_io_mqtt (self ):
71
70
"""Initialize MQTT for Adafruit IO"""
@@ -101,7 +100,6 @@ def init_mqtt(
101
100
if use_io :
102
101
self ._mqtt_client = IO_MQTT (self ._mqtt_client )
103
102
self .mqtt_connect = self ._mqtt_client .connect
104
- self ._mqtt_publish = self ._mqtt_client .publish
105
103
106
104
return self ._mqtt_client
107
105
@@ -112,19 +110,21 @@ def _get_mqtt_client(self):
112
110
return self ._mqtt_client
113
111
raise RuntimeError ("Please initialize MQTT before using" )
114
112
115
- def mqtt_loop (self ):
113
+ def mqtt_loop (self , * args , ** kwargs ):
116
114
"""Run the MQTT Loop"""
117
115
try :
118
116
if self ._mqtt_client is not None :
119
- self ._mqtt_client .loop ()
117
+ self ._mqtt_client .loop (* args , ** kwargs )
120
118
except MQTT .MMQTTException as err :
121
119
print ("MMQTTException: {0}" .format (err ))
120
+ except OSError as err :
121
+ print ("OSError: {0}" .format (err ))
122
122
123
123
def mqtt_publish (self , * args , ** kwargs ):
124
124
"""Publish to MQTT"""
125
125
try :
126
126
if self ._mqtt_client is not None :
127
- self ._mqtt_publish (* args , ** kwargs )
127
+ self ._mqtt_client . publish (* args , ** kwargs )
128
128
except OSError as err :
129
129
print ("OSError: {0}" .format (err ))
130
130
0 commit comments