briis / hass-weatherflow2mqtt

WeatherFlow to MQTT for Home Assistant. Use UDP to get local weather data in to Home Assistant using MQTT Discovery
MIT License
129 stars 29 forks source link

Error running KeyError: 'sea_level_pressure' #234

Closed FutureGUIs closed 1 year ago

FutureGUIs commented 1 year ago

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'
AngryApostrophe commented 1 year ago

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'

dgrove commented 1 year ago

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)

GlennGoddard commented 1 year ago

Interesting that people are getting different issues from not receiving the forecast. I'm not getting Feels Like Temperature, and the Zambretti, and my current conditions went to 'clear-night' hours before night. @briis had error checking in here for when forecast was not obtainable, so I'm not sure what happened here.

GlennGoddard commented 1 year ago

I didn't notice that the container keep restarting itself since I was getting all other sensors updating. So, did WeatherFlow change the API and not publish that change?

marc-gist commented 1 year ago

I didn't notice that the container keep restarting itself since I was getting all other sensors updating. So, did WeatherFlow change the API and not publish that change?

I would guess that is the issue, that the API has changed in some way, causing wf2m to error out :( Hopefully an easy quick fix!

idaband commented 1 year ago

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)

which file? I'm using the hass-weatherflow plugin. I wanted to test this.

GlennGoddard commented 1 year ago

@briis just pushed out a new build, it will be a few hours before I can test it; but he says the forecast is coming thru on it.

AndrewsBrewing commented 1 year ago

@briis just pushed out a new build, it will be a few hours before I can test it; but he says the forecast is coming thru on it.

Where do you see that Glenn?

briis commented 1 year ago

If you are running the Add-On, you go to Settings, System and Updates and refresh the updates, that should show an update for the Add-On. If you run a Plain docker container, just pull the latest version and recreate the container.

briis commented 1 year ago

I'm using the hass-weatherflow plugin

@idaband The hass-weatherflow plugin is a different thing than this. It is an integration. Go here for support on that.

chasut commented 1 year ago

still getting the KeyError on sea_level_pressure causing the container to stop and restart. I double-checked that I pulled the right image. Anyone else?

Screenshot 2023-08-29 at 2 23 26 PM
briis commented 1 year ago

Could you post your station id? Either here or in a PM to me, then I will check the raw data. Also are you using Metric or Imperial units? I cannot reproduce it here.

chasut commented 1 year ago

49000, imperial

chasut commented 1 year ago

BTW, looking at the data, it appears that the forecast is information is coming in fine, as is the value for sea_level_pressure all the way to HA. But for some reason the container just chokes on something. The feels like temperature and Zambretti number are unknown, however. Could it be in that calculation?

GlennGoddard commented 1 year ago

@briis When I removed (previously) the forecast from the docker run, then my feels like and zabretti functioned normally.

alvinchen1 commented 1 year ago

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](https://github.com/briis/hass-weatherflow2mqtt/assets/26409535/efcee22d-054c-453d-b4fe-7931c672d351)
hmjgriffon1 commented 1 year ago

Mine also says 3.1.7?

INFO:weatherflow2mqtt.weatherflow_mqtt:🏠 Home Assistant Supervisor Mode 🏠 INFO:weatherflow2mqtt.weatherflow_mqtt:Add-On value Unit System is: {'length': 'mi', 'accumulated_precipitation': 'in', 'mass': 'lb', 'pressure': 'psi', 'temperature': '°F', 'volume': 'gal', 'wind_speed': 'mph'} INFO:weatherflow2mqtt.weatherflow_mqtt:Timezone is America/New_York INFO:weatherflow2mqtt.weatherflow_mqtt:Unit System is imperial INFO:weatherflow2mqtt.weatherflow_mqtt:Zambretti Values: 28.3488 and 31.3018 INFO:weatherflow2mqtt.weatherflow_mqtt:Connected to the MQTT server at core-mosquitto:1883 INFO:weatherflow2mqtt.weatherflow_mqtt:The UDP server is listening on port 50222 INFO:weatherflow2mqtt.weatherflow_mqtt:Setting up Hub sensor: Status 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.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'

![image](https://github.com/briis/hass-weatherflow2mqtt/assets/121559144/916e2e57-ccf9-480a-9bc4-9236e908a99a)
FutureGUIs commented 1 year ago

My station id: 20063 @briis I'm still getting the sea level error on the latest too.

hmjgriffon1 commented 1 year ago

Can confirm the addon works fine when station ID and token are removed, so yeah, probably is something with the API to the cloud, at least I have all of my local data though.

GlennGoddard commented 1 year ago

Forecast still causing errors on latest build; I will check with WeatherFlow tomorrow if they changed any thing with the API or specific stations/tokens. Since not everyone is have forecast issues, then it implies that certain stations/tokens were changed and not an API issue; unless it was an API call limit but that should still be the same for those it currently works for.

AndrewsBrewing commented 1 year ago

My issue is probably unrelated. But my add-on keeps stopping on its own. I'm not good at this but I can get you any logs / info if you need it to help me.

AndrewsBrewing commented 1 year ago

My issue is probably unrelated. But my add-on keeps stopping on its own. I'm not good at this but I can get you any logs / info if you need it to help me.

Sorry, I'm just catching up with you guys. When I removed my Station ID and API Key, it stopped stopping on me,

chasut commented 1 year ago

Did some poking around and have a hypothesis on the issue: The weatherflow api is NOT returning the see_level_pressure as expected on the hourly forecast.

  1. Looks to me like the code expects that value in line 187 of forecast.py and that is what is reported as the error in the logs
  2. see_level_pressure is expected in the return for the hourly forecast based on the weatherflow api documentation
  3. I called the data manually, and sure enough, the see_level_pressure is NOT in the json for the hourly forecast
  4. I found this https://community.weatherflow.com/t/uv-sea-level-pressure-in-hourly-forecast/22222/3 in the developers forum.

So, it may just magically start working again once the weatherflow guys address the issue.

briis commented 1 year ago

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)

chasut commented 1 year ago

Oddly, on occasion, the Hourly Forecast at my station WILL have the see_level_pressure and everything loads just fine. Consequently everything looks fairly normal because all of the forecast data gets loaded at that time. I don't know the frequency, but it I haven't witnessed more than a few times a day. In any case, I hope the folks at WeatherFlow get this addressed quickly.

Thanks @briss for quickly patching up the hole they made.

briis commented 1 year ago

I have released V2.3.1, which should solve this issue. The reason for this is that on some stations the Hourly Forecast is not returning a value for Sea Level Pressure and sometimes also UV. I am not sure why this happens, and why only on some stations, but the issue is with WeatherFlow. This release now returns a 0 value, if no data is returned for the above two items, but ensures that the rest of the flow will still run.

Please let me know if this fixes the issue.

FutureGUIs commented 1 year ago

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