Like previous post, forecast not updated for hours. Found this in my log:
2021-08-27 03:00:07 ERROR (MainThread) [homeassistant.helpers.entity] Update for weather.ottawa fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 446, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 654, in async_device_update
raise exc
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/environment_canada/weather.py", line 178, in update
self.ec_data.update()
File "/usr/local/lib/python3.9/site-packages/env_canada/ec_data.py", line 207, in res
return fun(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/ratelimit/decorators.py", line 80, in wrapper
return func(*args, **kargs)
File "/usr/local/lib/python3.9/site-packages/env_canada/ec_data.py", line 257, in update
weather_tree = et.fromstring(weather_xml)
File "/usr/local/lib/python3.9/xml/etree/ElementTree.py", line 1348, in XML
return parser.close()
xml.etree.ElementTree.ParseError: unclosed token: line 801, column 1
What I really don’t understand is that the version of the lib being used is 0.2.5
and the latest on GitHub is 0.5.0
. I’m running the very latest HA.
What else I don’t understand is that I cannot find the 0.2.5
version on GitHub (looking back through history). I see 0.2.4
followed by a bump to 0.3.0
. I can find the 0.2.5
version on PyPi which I downloaded to look at the code.
Looking at the latest 0.5.0
code I still see the XML decode logic is the same as 0.2.5
version (env_canada/ec_weather.py at 4ce3ac967272ce7e76c336768bf032d85fb6da52 · michaeldavie/env_canada · GitHub). At a minimum should that code be in a try
block to protect against bad data? That is the exception I’m seeing and have posted here. Beyond a try
block there probably should be some kind of retry logic, if that is not already there.
I also notice that the 0.5.0
version is using asyncio
. Yeah!!! Given that changes the HA integration, I believe, I think I understand why HA is not using this code yet. If it is going to be a while until the asyncio
version is ready, does it make sense to put out a 0.2.6
with the try
block fix?
What are there plans to update to the latest lib? Is help required… testing, coding, other?