I have an NWS weather platform (component? integration?) ready for testing and feedback.
You can put the files into: config_path/custom_components/nws
Sample config:
weather:
- platform: nws
api_key: email_address
api_key can be any string, but it is recommended to include an email address. The forecast is only day+night right now, although I’m working on adding hourly. The weather component (platform?) frontend currently doesn’t support day+night well, so it will display with timestamps as if hourly. See next post for the status of frontend changes if I can figure out how to make it a custom card.
One can also specify a name, latitude, longitude, or specific station as options. The station is for the current conditions, and the component will use the closest station if not specified. A list of nearby stations is printed in the logs with level INFO if no station is specified. They can also be found, although I don’t know of any convenient page, on the weather.gov website. The forecast is generated by the lat/lon point (or default lat/lon).
Custom card info to come later if I can figure it out.
So far I can’t figure it out. It doesn’t seem like one can drop in a slightly modified existing card as a custom card without significant rewrite, although I hardly know any javascript to really tell.
I’m finalizing putting in some tests and then will submit a PR. One thing that needs to be addressed, probably in a follow-up PR, is to disregard data received that is reported to be poor quality and fall back to a previous value.
The problem is that the Lovelace weather card only supports two modes well, one forecast daily or ‘hourly’. This one gets treated as hourly, so the hours are displayed. What you are noticing is that the forecast for the current day keeps increasing the hour until it is night.
I have a modified weather card as in my second post that fixes this issue, but I need to wait for the nws weather platform to be integrated to submit a PR. No other weather platform to my knowledge provides data in this format (one forecast for day, one forecast for night). All others have one forecast for both, but report a low temperature overnight in that forecast.
Also, thanks for the feedback! I’m nearing completion on submitting the PR. I have to consider how to approach the card changes, either in parallel or subsequently. I fear too many change requests at once will bog down the developers during review, but as you are pointing out, it is confusing in it’s current state.
@MatthewFlamm. Thanks for responding, and thanks for your work on this. If it’s reasonable, I would be interested in a “daily” mode that looks more like the standard weather card (five days out, daily high and low temp in over/under format).
I had considered this. It isn’t straightforward however. What do you do if the forecast for the day is Sunny, but the forecast for the night is Snowy? A lot of subjective decisions need to be made. I also have the weather forecast description as a forecast attribute, we’d have to somehow combine them together in a sensible way. In my experience, you wouldn’t want to simply discard the night forecast entirely.
I suggest that once the current modes are merged, someone can add a third mode ‘daily’ by accounting for these issues. Or, if someone wanted to lay out a path forward on most of the thorny decisions, I can do the code changes easily.
I’ve updated the repo to use the raw metar code as a fall back when the weather API data is missing. There are some stations where this seems to be essential.
Just updated to Hassio 94.0 Seems to have broken your code…
Log Details (ERROR)
Wed Jun 05 2019 23:44:43 GMT-0400 (Eastern Daylight Time)
Error while setting up platform nws
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 126, in _async_setup_platform
SLOW_SETUP_MAX_WAIT)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 416, in wait_for
return fut.result()
File “/config/custom_components/nws/weather.py”, line 136, in async_setup_platform
from pynws import Nws
ModuleNotFoundError: No module named ‘pynws’
hmmmm… It works just fine on my end. What makes me think this is not a code issue is that it can’t import the package dependency, but you already had it installed and working on the previous version.
I am also not using hassio. I see a few breaking changes related to hassio and package management therein, which might be related. Can you try the age old trick of restarting?
I will try to see if there are any changes needed to work with hassio.