jaydeethree / Home-Assistant-weatherdotcom

Home Assistant custom component/integration for Weather.com
GNU General Public License v3.0
46 stars 7 forks source link

Error during weather."location" entity setup #7

Closed Kelesis closed 1 year ago

Kelesis commented 1 year ago

Hi, not sure if it is related to home assistant upgrade from 2023.08.3 to 2023.9.0 I just did, but the following error is now occurring at startup. The 2 weather."location" and weather."location"_hourly are missing. Other sensor entities are available.

There are 4 occurrences in my log since I tried to restart the integration once.

Thanks anyway for this integration!

Logger: homeassistant.components.weather Source: custom_components/weatherdotcom/weather.py:125 Integration: Météo (documentation, issues) First occurred: 00:20:59 (4 occurrences) Last logged: 06:49:33

Error adding entities for domain weather with platform weatherdotcom Error while setting up weatherdotcom platform for weather Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1002, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 730, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 830, in _async_write_ha_state state, attr = self._async_generate_attributes() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 773, in _async_generate_attributes attr.update(self.state_attributes or {}) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/weather/init.py", line 723, in state_attributes from_unit = self.native_visibility_unit or self._default_visibility_unit ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/weatherdotcom/weather.py", line 125, in native_visibility_unit return self._attr_visibility_unit ^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'WeatherDotComDaily' object has no attribute '_attr_visibility_unit'

lindsand commented 1 year ago

I got the same after the upgrade from 2023.08.3 to 2023.9.0.

Related to this change? https://www.home-assistant.io/blog/2023/09/06/release-20239/#weather-forecast-service

viny182 commented 1 year ago

Same here!

Screenshot_20230907_074057_Home Assistant.jpg

jaydeethree commented 1 year ago

Thanks for reporting this issue! I haven't updated to 2023.9 yet but I will as soon as I have some time, and then I can take a look at this.

Dakael commented 1 year ago

A temporary workaround to be sure, but commenting lines 117-125 in weather.py and restarting home assistant allows the integration load the two weather entities again.

image

viny182 commented 1 year ago

A temporary workaround to be sure, but commenting lines 117-125 in weather.py and restarting home assistant allows the integration to start again.

image

I confirm this works!

jaydeethree commented 1 year ago

It looks like the issue is that https://github.com/home-assistant/core/pull/99263 removed _attr_visibility_unit (as well as several other attributes that this integration doesn't use). As long as that's the only problem this should be pretty quick and easy to fix.

jaydeethree commented 1 year ago

I just released 1.0.7 which fixes this. I tested the update in both Home Assistant 2023.8 and 2023.9, and it appears to work correctly in both versions.