OverflowError: timestamp out of range for platform time_t when loading
sheilnaik opened this issue · 6 comments
Describe the Bug
Receiving an OverflowError: timestamp out of range for platform time_t
when loading the component
File "/config/custom_components/plex_recently_added/sensor.py", line 159, in device_state_attributes
card_item['airdate'] = datetime.utcfromtimestamp(
The Error
Error while setting up plex_recently_added platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 201, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 310, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 481, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 522, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 296, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 323, in _async_write_ha_state
attr.update(self.device_state_attributes or {})
File "/config/custom_components/plex_recently_added/sensor.py", line 159, in device_state_attributes
card_item['airdate'] = datetime.utcfromtimestamp(
OverflowError: timestamp out of range for platform time_t
Indicate if you followed all steps in the troubleshooting doc
Yes, it seems like this may be an issue with a particular item in my library, but I have no idea which one.
What data does the sensor display if any?
None, issue upon loading component.
What displays when visiting the API URL from the troubleshooting guide?
See https://pastebin.com/A1UtXikt
Does the default Home Assistant Plex component work for you?
Yes
Home Assistant Version
Home Assistant 0.115.6
Additional Context
I think the issue might be with an item in my Plex library, but I'm not sure which one. The error message isn't very helpful.
This would be because Casino Royale was added to your library 77 years in the future. On a cold Wednesday morning at 6:00, on January 1, in the year 2098.
The metadata for the addedAt attribute for that movie got messed up somehow, you might try refreshing the metadata for the movie or repairing the metadata by following the steps at the end of this post, etc.
Hey I'm getting the same error. How were you able to track down the offending movie from this error message? Thanks!
I ended up finding it by sorting my library and taking care of it. Still, if there is away to find the offending movie through the HA error it would be good to know.
Couple of ways:
-
Look at the data being supplied by Plex's API and look at all the item's for the attribute that's giving the error. If you look at the pastebin link from the original issue you can see the data supplied by Plex's API. The addedAt attribute for all the items listed there is around
1601725139
, where the one for Casino Royal is4039394400
. So just look for one that looks wildly different from the rest. Those attributes are listed as Unix Epoch time. -
Visit Plex and check your different libraries by selecting them, then clicking "library" and then sorting by the field that's giving the error. Look for the one that is at the top or bottom depending on which way you have it sorted.
It may not be that simple to find the offending item and there may be more than one, so the easiest fix would be following the steps in my original answer to repair all metadata if you're having trouble finding the item causing the error.
Thank you!