NWS integration error about wmoUnit:degC

My NWS weather component stopped updating recently. Looking at the logs, I noticed a KeyLookup error regarding wmoUnit:degC.

The NWS library appears to be expecting unit:degC for the unit codes. From my very little testing, NWS API is returning wmoUnit:degC (in field features[0].properties.temperature.unitCode of example). For the moment, I have manually modified the pynws/simple_nws.py file on my HA installation (diff looks like this).

I hope to follow the process to get this change submitted, but haven’t done enough due diligence for myself to even file an issue with pynws.

I didn’t know the best category to put this. Since it’s a temporary/hacky direct file fix to an included library, I thought of it as a temporary “Configuration” until a more long-term issue and possible fix are in place.

You are correct. This is widespread on all stations I have checked. I’m planning on a more robust fix that will accept any “*:degC” in case it reverts back to the old constant.

It sounds like you are on the right track, feel free to open a PR if you want to implement the more robust method.

1 Like

I couldn’t wait as this bug has shut down a few of my automations. There is a PR submitted already to homeassistant/core.

1 Like

Glad to see there’s a PR already!

It should be live in the new release 2021.10.0

1 Like

I’m seeing a really odd behavior after the update. Temperature is jumping all over the place (NWS isn’t showing that, it’s been about 50F all morning!

Any ideas?

I think this may be a bug due to a change in the NWS servers. The observations used to be returned sorted (newest first). It looks like observations are coming in unsorted and home assistant is simply using the first value (It could be yesterdays temperature at 2 PM for example). I suspect this is due to the same server changes as the change in the unit code format.

If you are capable and are interested, would you be able to upgrade to pynws 1.3.2 on your home assistant for testing?

@MatthewFlamm I’ll give it a whirl tonight when I get home.

I apparently have no idea what I’m doing! LOL. I was unable to figure out how to test this. I assume I’m missing the most painfully obvious way to get access to built in integration files.

No problem, it is complicated for sure. Thank you for trying! I will submit a PR to bump the version for home assistant. If you submit an issue to homeassistant/core then it would help push through the PR.

Done! #57342

2021.10.3 includes a fix (hopefully)


@MatthewFlamm that did the trick! You are fantastic! Thanks for the quick turn around on fixing this!!

1 Like