Skip to content

Commit

Permalink
Mobile timestamp formating fix #38
Browse files Browse the repository at this point in the history
  • Loading branch information
myTselection committed Dec 29, 2023
1 parent ddb836d commit e8b2a11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion custom_components/telenet_telemeter/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
20 changes: 8 additions & 12 deletions custom_components/telenet_telemeter/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit e8b2a11

Please sign in to comment.