myTselection / telenet_telemeter

Telenet Telemeter Home Assistant custom component HACS for Belgian ISP and mobile phone network traffic.
MIT License
28 stars 5 forks source link

Seeing error in log viewer - date format issue #38

Closed lantranbot closed 8 months ago

lantranbot commented 8 months ago

Hi,

I'm seeing the below in my log viewer coming in for each telephone number on my account. Seems like the format isn't correct. Not sure where I need to update this on my system, so I've updated your code to match my format.

original : format_string = "%d-%m-%Y %H:%M:%S"

updated : format_string = "%Y-%m-%dT%H:%M:%S+01:00"

(sensor.py - line 1246 : 2023-12-29 13:39:34.847 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.telenet_telemeter_mobile_shared fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 698, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 959, in async_device_update await self.async_update() File "/config/custom_components/telenet_telemeter/sensor.py", line 778, in async_update original_datetime = datetime.strptime(self._period_end_date, format_string) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/_strptime.py", line 568, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/_strptime.py", line 349, in _strptime raise ValueError("time data %r does not match format %r" % ValueError: time data '2024-01-24T00:00:00.0+01:00' does not match format '%d-%m-%Y %H:%M:%S'

Any idea where in the system I should update it to match your settings?

Thanks

myTselection commented 8 months ago

Thx for reporting this, I actually don't have a mobile subscription myself at Telenet so I was not aware the timestamp notation didn't fit. Should be fixed now.