@@ -70,10 +70,10 @@ def __init__(self, mqtt_client):
70
70
# MiniMQTT's username kwarg is optional, IO requires a username
71
71
try :
72
72
self ._user = self ._client .user
73
- except :
73
+ except Exception as err :
74
74
raise TypeError (
75
75
"Adafruit IO requires a username, please set one in MiniMQTT"
76
- )
76
+ ) from err
77
77
# User-defined MQTT callback methods must be init'd to None
78
78
self .on_connect = None
79
79
self .on_disconnect = None
@@ -105,17 +105,17 @@ def reconnect(self):
105
105
"""
106
106
try :
107
107
self ._client .reconnect ()
108
- except :
109
- raise AdafruitIO_MQTTError ("Unable to reconnect to Adafruit IO." )
108
+ except Exception as err :
109
+ raise AdafruitIO_MQTTError ("Unable to reconnect to Adafruit IO." ) from err
110
110
111
111
def connect (self ):
112
112
"""Connects to the Adafruit IO MQTT Broker.
113
113
Must be called before any other API methods are called.
114
114
"""
115
115
try :
116
116
self ._client .connect ()
117
- except :
118
- raise AdafruitIO_MQTTError ("Unable to connect to Adafruit IO." )
117
+ except Exception as err :
118
+ raise AdafruitIO_MQTTError ("Unable to connect to Adafruit IO." ) from err
119
119
120
120
def disconnect (self ):
121
121
"""Disconnects from Adafruit IO MQTT Broker.
@@ -556,11 +556,22 @@ def send_data(self, feed_key, data, metadata=None, precision=None):
556
556
if precision :
557
557
try :
558
558
data = round (data , precision )
559
- except NotImplementedError : # received a non-float value
560
- raise NotImplementedError ("Precision requires a floating point value" )
559
+ except NotImplementedError as err : # received a non-float value
560
+ raise NotImplementedError (
561
+ "Precision requires a floating point value"
562
+ ) from err
561
563
payload = self ._create_data (data , metadata )
562
564
self ._post (path , payload )
563
565
566
+ def receive_all_data (self , feed_key ):
567
+ """
568
+ Get all data values from a specified Adafruit IO feed. Data is
569
+ returned in reverse order.
570
+ :param str feed_key: Adafruit IO feed key
571
+ """
572
+ path = self ._compose_path ("feeds/{0}/data" .format (feed_key ))
573
+ return self ._get (path )
574
+
564
575
def receive_data (self , feed_key ):
565
576
"""
566
577
Return the most recent value for the specified feed.
0 commit comments