diff --git a/custom_components/telenet_telemeter/manifest.json b/custom_components/telenet_telemeter/manifest.json index 4b41dc6..fe2e6c0 100644 --- a/custom_components/telenet_telemeter/manifest.json +++ b/custom_components/telenet_telemeter/manifest.json @@ -9,5 +9,5 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/myTselection/telenet_telemeter/issues", "requirements": ["beautifulsoup4", "html5lib"], - "version": "1.5.2" + "version": "1.5.3" } \ No newline at end of file diff --git a/custom_components/telenet_telemeter/sensor.py b/custom_components/telenet_telemeter/sensor.py index 7c03cd9..380e4b0 100644 --- a/custom_components/telenet_telemeter/sensor.py +++ b/custom_components/telenet_telemeter/sensor.py @@ -773,15 +773,14 @@ async def async_update(self): self._last_update = productdetails.get('lastupdated') self._product = productdetails.get('label') self._period_end_date = productdetails.get('nextbillingdate') - format_string = "%d-%m-%Y %H:%M:%S" # Parse the timestamp string into a datetime object - original_datetime = datetime.strptime(self._period_end_date, format_string) + original_datetime = datetime.strptime(self._period_end_date, _TELENET_DATETIME_FORMAT) # Add one day to the datetime object new_datetime = original_datetime + timedelta(days=1) # Format the new datetime object back to a string - self._period_end_date = new_datetime.strftime(format_string) + self._period_end_date = new_datetime.strftime(_TELENET_DATETIME_FORMAT) # get shared sensor sharedusage = productdetails.get('sharedusage') @@ -914,15 +913,14 @@ async def async_update(self): self._last_update = productdetails.get('lastupdated') self._product = productdetails.get('label') self._period_end_date = productdetails.get('nextbillingdate') - format_string = "%d-%m-%Y %H:%M:%S" # Parse the timestamp string into a datetime object - original_datetime = datetime.strptime(self._period_end_date, format_string) + original_datetime = datetime.strptime(self._period_end_date, _TELENET_DATETIME_FORMAT) # Add one day to the datetime object new_datetime = original_datetime + timedelta(days=1) # Format the new datetime object back to a string - self._period_end_date = new_datetime.strftime(format_string) + self._period_end_date = new_datetime.strftime(_TELENET_DATETIME_FORMAT) # get shared sensor unassignesub = productdetails.get('unassigned').get('mobilesubscriptions')[self._subsid] @@ -1069,15 +1067,14 @@ async def async_update(self): self._last_update = productdetails.get('lastupdated') self._product = productdetails.get('label') self._period_end_date = productdetails.get('nextbillingdate') - format_string = "%d-%m-%Y %H:%M:%S" # Parse the timestamp string into a datetime object - original_datetime = datetime.strptime(self._period_end_date, format_string) + original_datetime = datetime.strptime(self._period_end_date, _TELENET_DATETIME_FORMAT) # Add one day to the datetime object new_datetime = original_datetime + timedelta(days=1) # Format the new datetime object back to a string - self._period_end_date = new_datetime.strftime(format_string) + self._period_end_date = new_datetime.strftime(_TELENET_DATETIME_FORMAT) # get shared sensor profile = productdetails.get('profiles')[self._profileid] @@ -1243,15 +1240,14 @@ async def async_update(self): self._last_update = mobileusage.get('lastUpdated') self._label = self._product = self._productSubscription.get('label') self._period_end_date = mobileusage.get('nextBillingDate') - format_string = "%d-%m-%Y %H:%M:%S" # Parse the timestamp string into a datetime object - original_datetime = datetime.strptime(self._period_end_date, format_string) + original_datetime = datetime.strptime(self._period_end_date, _TELENET_DATETIME_FORMAT) # Add one day to the datetime object new_datetime = original_datetime + timedelta(days=1) # Format the new datetime object back to a string - self._period_end_date = new_datetime.strftime(format_string) + self._period_end_date = new_datetime.strftime(_TELENET_DATETIME_FORMAT) self._outofbundle = f"{mobileusage.get('outOfBundle').get('usedUnits')} {mobileusage.get('outOfBundle').get('unitType')}" self._number = self._identifier self._active = self._productSubscription.get('status')