@@ -37,7 +37,12 @@ def device_types_list(self):
37
37
def device_list (self , device_type_id = 0 ):
38
38
"""Return array of dictionaries - one array item per device.
39
39
40
- If device_type_id is not set devices of all device types are returned!
40
+ :param device_type_id: Return only devices of a certain type ID.
41
+ If set to 0 returns all devices of all types (default)!
42
+ :type device_type_id: int
43
+ :return: List of dictionaries
44
+ :rtype: list
45
+
41
46
"""
42
47
device_type_ids = []
43
48
out = []
@@ -54,13 +59,15 @@ def device_list(self, device_type_id = 0):
54
59
return out
55
60
56
61
def device_messages (self , device_id ):
57
- """Return array of messages from device with ID defined in device_id.
58
- Limit of 100 is the maximum Sigfox API will accept.
62
+ """Return array of 100 last messages from device.
63
+
64
+ :param device_id: ID of the device
65
+ :type device_id: str
59
66
60
67
"""
61
68
out = []
62
69
63
- url = self .api_url + 'devices/' + device_id + '/messages?limit=100'
70
+ url = self .api_url + 'devices/' + str ( device_id ) + '/messages?limit=100'
64
71
r = requests .get (url , auth = requests .auth .HTTPBasicAuth (self .login , self .password ))
65
72
pprint (json .loads (r .text )['paging' ]['next' ])
66
73
@@ -72,11 +79,10 @@ def device_messages(self, device_id):
72
79
73
80
try :
74
81
json .loads (r .text )['paging' ]['next' ]
75
- print ("Loading next page..." )
82
+ print ("Loading next page of messages for " + str ( device_id ) + " ..." )
76
83
out .extend (self .device_messages_page (json .loads (r .text )['paging' ]['next' ]))
77
84
except Exception as e :
78
- # print("No paging")
79
- raise
85
+ raise
80
86
81
87
return out
82
88
0 commit comments