hass-weatherflow2mqtt: Error running KeyError: 'sea_level_pressure'

Home Assistant Version?

2023.8.3

Add-On or Self Hosted?

HA Supervised (Add-On)

Weatherflow2MQTT version?

3.1.6

What happened?

Just started seeing this error in the logs and now the addon won’t stay started.

Relevant log output

File "/usr/local/lib/python3.10/site-packages/weatherflow2mqtt-3.1.6-py3.10.egg/weatherflow2mqtt/forecast.py", line 187, in update_forecast
KeyError: 'sea_level_pressure'

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 5
  • Comments: 27 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I have now done some more research on this issue, and found that some stations, for some unknown reason, do no longer give a Sea Level Pressure Value in the Hourly Forecast, and that is what is causing the error. I cannot fix the underlying problem as this is with WeatherFlow, but I will implement a fix that ensures that a default value of 0 is returned if the item is not present. I did not see this error myself, as I get the Sea Level pressure, and I assume others do so to.

Hopefully I can have a new release out later today. (It is morning where I am)

Until there is a fix, a workaround is to remove STATION_ID and STATION_TOKEN from the config page for the weatherflow2mqtt add-on (this prevents the add-on from trying to get the forecast)

My full log:

INFO:weatherflow2mqtt.weatherflow_mqtt:Setting up Hub sensor: Weather ERROR:asyncio:Task exception was never retrieved future: <Task finished name=‘Task-7’ coro=<WeatherFlowMqtt._update_forecast() done, defined at /usr/local/lib/python3.10/site-packages/weatherflow2mqtt-3.1.6-py3.10.egg/weatherflow2mqtt/weatherflow_mqtt.py:755> exception=KeyError(‘sea_level_pressure’)> Traceback (most recent call last): File “/usr/local/lib/python3.10/site-packages/weatherflow2mqtt-3.1.6-py3.10.egg/weatherflow2mqtt/weatherflow_mqtt.py”, line 760, in _update_forecast if any(forecast := await self.forecast.update_forecast()): File “/usr/local/lib/python3.10/site-packages/weatherflow2mqtt-3.1.6-py3.10.egg/weatherflow2mqtt/forecast.py”, line 187, in update_forecast row[“sea_level_pressure”] KeyError: ‘sea_level_pressure’

Yes, this works now, thank you so much @briis

Hello! same thing for me, just applied 3.2.0. Station number 81247, imperial. Anything else I can help supply to help resolve?

ERROR:asyncio:Task exception was never retrieved future: <Task finished name=‘Task-7’ coro=<WeatherFlowMqtt._update_forecast() done, defined at /usr/local/lib/python3.11/site-packages/weatherflow2mqtt-3.1.7-py3.11.egg/weatherflow2mqtt/weatherflow_mqtt.py:764> exception=KeyError(‘sea_level_pressure’)> Traceback (most recent call last): File “/usr/local/lib/python3.11/site-packages/weatherflow2mqtt-3.1.7-py3.11.egg/weatherflow2mqtt/weatherflow_mqtt.py”, line 769, in _update_forecast if any(forecast := await self.forecast.update_forecast()): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/usr/local/lib/python3.11/site-packages/weatherflow2mqtt-3.1.7-py3.11.egg/weatherflow2mqtt/forecast.py”, line 187, in update_forecast row[“sea_level_pressure”] ~~~^^^^^^^^^^^^^^^^^^^^^^ KeyError: ‘sea_level_pressure’

From the logs, looks like I still am on 3.1.7, but I did apply 3.2.0.

image