Limych / ha-gismeteo

Gismeteo Weather Provider for Home Assistant
Other
116 stars 20 forks source link

unit ° thus indicating it has a numeric value; however, it has the non-numeric value: unknown #156

Closed whatzefak closed 1 month ago

whatzefak commented 1 year ago

Environment

Describe the bug

Configuration.yaml


weather:
  - platform: gismeteo

Steps to Reproduce

Expected behavior

Debug log



Add your logs here.

Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:597
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 8:16:41 AM (1 occurrences)
Last logged: 8:16:41 AM
Sensor sensor.my_smart_home_wind_bearing has device class None, state class None and unit ° thus indicating it has a numeric value; however, it has the non-numeric value: unknown (<class 'str'>); Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.

**Additional context**
<!--
  Add any other context about the problem here.
-->
ildar170975 commented 1 year ago

In 2023.5 the log is FLOODED by these errors.

IgorA-XXI commented 1 year ago

To remove these error messages edit custom_components/gismeteo/api.py and replace STATE_UNKNOWN by 0 in definition:

def wind_bearing(self, src=None):
    """Return the current wind bearing."""
    src = src or self._current
    bearing = int(src.get(ATTR_WEATHER_WIND_BEARING, 0))
    return (bearing - 1) * 45 if bearing > 0 else  STATE_UNKNOWN

Looks like this not a bug in this integration, but a feature of the new version of Sensor integration, which does not accept "unknown" for numeric values; the same type of error is reported in HA 2023.5 by many other integrations, including Energy, Mobile, etc.

My guess is that it happens on a regular basis with wind_bearing and does not happen with other entities of Gismeteo integration is that wind will have no direction, if there is no wind at all :) ...i.e. wind speed equals zero. All other entities of the integration are always defined.