ciejer / metservice-weather

Metservice New Zealand component for Home Assistant
MIT License
17 stars 1 forks source link

Error caused by non-numeric windspeed #71

Closed MattDoubleYou closed 3 weeks ago

MattDoubleYou commented 1 month ago

System Health details

System Information

version core-2024.9.3
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.4
os_name Linux
os_version 6.6.46-haos
arch x86_64
timezone Pacific/Auckland
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok HACS Data | ok GitHub API Calls Remaining | 5000 Installed Version | 2.0.1 Stage | running Available Repositories | 1422 Downloaded Repositories | 19
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | September 7, 2025 at 12:00 PM relayer_connected | true relayer_region | ap-southeast-1 remote_enabled | true remote_connected | true alexa_enabled | true google_enabled | true remote_server | ap-southeast-1-2.ui.nabu.casa certificate_status | ready instance_id | b246dae1ac9f41cc9db4e37d9b9fd3d0 can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 13.1 -- | -- update_channel | stable supervisor_version | supervisor-2024.09.1 agent_version | 1.6.0 docker_version | 26.1.4 disk_total | 234.0 GB disk_used | 152.7 GB healthy | true supported | true host_connectivity | true supervisor_connectivity | true ntp_synchronized | true virtualization | board | generic-x86-64 supervisor_api | ok version_api | ok installed_addons | Advanced SSH & Web Terminal (19.0.0), Samba share (12.3.2), Home Assistant Google Drive Backup (0.112.1), Frigate (Full Access) (0.14.1), Studio Code Server (5.15.0), Mosquitto broker (6.4.1), Zigbee2MQTT (1.40.1-1), Matter Server (6.5.1)
Dashboards dashboards | 2 -- | -- resources | 12 views | 10 mode | storage
Recorder oldest_recorder_run | September 20, 2024 at 12:13 AM -- | -- current_recorder_run | September 26, 2024 at 6:32 AM estimated_db_size | 316.27 MiB database_engine | sqlite database_version | 3.45.3

Checklist

Describe the issue

this_hour["wind"]["speed"] can equal 'NA', when a float is expected.

The result is that the hourly forecast doesn't display on the weather.home card and any actions using the hourly forecast return an 'unknown error'.

Screenshot_2024-09-28-08-13-05-59_c3a231c25ed346e59462e84656a70e50~2 Screenshot_2024-09-28-08-13-19-94_c3a231c25ed346e59462e84656a70e50~2

Reproduction steps

  1. Requires forecast weather conditions where Metservice is returning 'NA' for a forecast windspeed
  2. In HA, go to DevTools>Actions and enter details to run Weather: Get forecasts for the Metservice integration.
  3. Choose the Hourly forecast type
  4. Note that an 'Unknown Error' is returned
  5. Check the logs to view error details

Debug logs

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/metservice_weather/weather.py:358
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: September 27, 2024 at 6:49:13 AM (46 occurrences)
Last logged: 8:27:26 AM
...
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/weather/websocket_api.py", line 103, in ws_subscribe_forecast
    await entity.async_update_listeners({forecast_type})
  File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 968, in async_update_listeners
    native_forecast_list: list[Forecast] | None = await getattr(
                                                  ^^^^^^^^^^^^^^
  File "/config/custom_components/metservice_weather/weather.py", line 316, in async_forecast_hourly
    return self.forecast_hourly
           ^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/metservice_weather/weather.py", line 358, in forecast_hourly
    if float(this_hour["wind"]["speed"]) > 40:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: 'NA'

Diagnostics dump

No response

ciejer commented 3 weeks ago

This should be resolved in 0.7 - please advise if any ongoing issues. Sorry for the delay!

MattDoubleYou commented 2 weeks ago

This should be resolved in 0.7 - please advise if any ongoing issues. Sorry for the delay!

Thanks for this very useful integration!