davidn / epa_uvindex

EPA UV Index integration for home-assistant.
Apache License 2.0
8 stars 1 forks source link

ValueError: time data 'Jun/01/2023 04 AM' does not match format '%B/%d/%Y %I %p' #2

Closed deepcoder closed 1 year ago

deepcoder commented 1 year ago

My two sensors just stopped working several days ago, with the error listed below. I have tried deleting the sensors and readding them. Also tried redownloading your integration via HACS. Neither has solved the issue. I am running Home Assistant x86 docker version 2023.5.4

Thanks for your help!

2023-06-01 09:32:29.609 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform epa_uvindex
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 455, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 731, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 844, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/epa_uvindex/sensor.py", line 52, in async_added_to_hass
    await self.async_update()
  File "/config/custom_components/epa_uvindex/sensor.py", line 49, in async_update
    self._attr_extra_state_attributes = {"forecast": await self.epa_uvindex.async_get_hourly_uvindex()}
  File "/config/custom_components/epa_uvindex/epa_uvindex.py", line 53, in async_get_hourly_uvindex
    return self._hourly_forecast(response)
  File "/config/custom_components/epa_uvindex/epa_uvindex.py", line 36, in _hourly_forecast
    "datetime": datetime.strptime(e['DATE_TIME'], "%B/%d/%Y %I %p")
  File "/usr/local/lib/python3.10/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/local/lib/python3.10/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data 'Jun/01/2023 04 AM' does not match format '%B/%d/%Y %I %p'
2023-06-01 09:32:29.615 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up epa_uvindex platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 312, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 455, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 731, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 844, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/epa_uvindex/sensor.py", line 52, in async_added_to_hass
    await self.async_update()
  File "/config/custom_components/epa_uvindex/sensor.py", line 49, in async_update
    self._attr_extra_state_attributes = {"forecast": await self.epa_uvindex.async_get_hourly_uvindex()}
  File "/config/custom_components/epa_uvindex/epa_uvindex.py", line 53, in async_get_hourly_uvindex
    return self._hourly_forecast(response)
  File "/config/custom_components/epa_uvindex/epa_uvindex.py", line 36, in _hourly_forecast
    "datetime": datetime.strptime(e['DATE_TIME'], "%B/%d/%Y %I %p")
  File "/usr/local/lib/python3.10/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/local/lib/python3.10/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data 'Jun/01/2023 04 AM' does not match format '%B/%d/%Y %I %p'
davidn commented 1 year ago

Thanks for the report! I see the same error on my own system. For personal reasons it will probably be at least a few weeks and possibly more before I'm able to investigate or commit changes. If you are able to edit the integration on your system try changing the format string mentioned in the error in epa_uvindex.py, you might be able to get it going then.