diff --git a/AuroraPlus/__init__.py b/AuroraPlus/__init__.py index 48c3cda..85d14ff 100644 --- a/AuroraPlus/__init__.py +++ b/AuroraPlus/__init__.py @@ -47,35 +47,46 @@ def gettoken(self, username, password): except Timeout: self.Error = 'Token request timed out' - def request(self, timespan): + def request(self, timespan, index=-1): try: - request = self.session.get(self.url + '/usage/' + timespan +'?serviceAgreementID=' + self.serviceAgreementID + '&customerId=' + self.customerId + '&index=-1', headers={'Authorization': self.token}) + request = self.session.get( + self.url + + '/usage/' + + timespan + + '?serviceAgreementID=' + + self.serviceAgreementID + + '&customerId=' + + self.customerId + + '&index=' + + str(index), + headers={'Authorization': self.token} + ) if (request.status_code == 200): return request.json() else: - self.Error = 'Data request failed: ' + request.reason + self.Error = 'Data request failed: ' + request.reason except Timeout: self.Error = 'Data request timed out' - def getsummary(self): - summarydata = self.request("day") + def getsummary(self, index=-1): + summarydata = self.request("day", index) self.DollarValueUsage = summarydata['SummaryTotals']['DollarValueUsage'] self.KilowattHourUsage = summarydata['SummaryTotals']['KilowattHourUsage'] - def getday(self): - self.day = self.request("day") + def getday(self, index=-1): + self.day = self.request("day", index) - def getweek(self): - self.week = self.request("week") + def getweek(self, index=-1): + self.week = self.request("week", index) - def getmonth(self): - self.month = self.request("month") + def getmonth(self, index=-1): + self.month = self.request("month", index) - def getquarter(self): - self.quarter = self.request("quarter") + def getquarter(self, index=-1): + self.quarter = self.request("quarter", index) - def getyear(self): - self.year = self.request("year") + def getyear(self, index=-1): + self.year = self.request("year", index) def getcurrent(self): try: