From 972726282f2ec6c7ff96a2a796e5cd1c0a8fae42 Mon Sep 17 00:00:00 2001 From: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com> Date: Fri, 19 Jul 2024 04:50:02 -0400 Subject: [PATCH] Add forecast service call for extra attributes for nws (#32729) * add description of * fix link * fix link again * additional info * Current with changes in core PR * Align with changes in core; use short_forecast * Suggestion for table formatting. Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Use end pipes Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * tiny tweaks --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com> --- source/_integrations/nws.markdown | 34 ++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/source/_integrations/nws.markdown b/source/_integrations/nws.markdown index 1fc39a17476..c554ad89f2d 100644 --- a/source/_integrations/nws.markdown +++ b/source/_integrations/nws.markdown @@ -26,8 +26,36 @@ According to the [API documentation](https://www.weather.gov/documentation/servi Providing a METAR station code is optional, and if not supplied, the closest station to the latitude and longitude will be chosen. A list of nearby stations is printed to the log with level `DEBUG` if no station is supplied. Stations can also be found on the [NOAA website](https://www.cnrfc.noaa.gov/metar.php). Codes with only three characters, for example, `ADW` should be prefixed with the letter K, `KADW`. -One weather entity is created for each entry in the configuration. Hourly and day/night forecasts are provided through the `weather.get_forecasts` action. The time supplied for each forecast is the start time for the forecast. Sensors are also created as disabled entities after configuration and can be enabled by the user. +One weather entity is created for each entry in the configuration. Hourly and day/night forecasts are provided through the [`weather.get_forecasts` action](/integrations/weather/action--weatherget_forecasts). The time supplied for each forecast is the start time for the forecast. Sensors are also created as disabled entities after configuration and can be enabled by the user. + +## Action `nws.get_forecasts_extra` + +`nws.get_forecasts_extra` provides extra data in a form similar to `weather.get_forecasts`. See [`weather.get_forecasts` documentation](/integrations/weather/action--weatherget_forecasts). + +| Data attribute | Optional | Description | Example | +| ---------------------- | -------- | ----------- | --------| +| `type` | no | The type of forecast, must be either `twice_daily` or `hourly`. | `twice_daily` | + +```yaml +service: nws.get_forecasts_extra +target: + entity_id: + - weather.khou +data: + type: twice_daily +response_variable: weather_forecast +``` + +The response data field is a mapping of called target entities, each containing the `forecast` field. +`forecast` is a list of forecasted conditions at a given point in time that are not returned from `weather.get_forecasts`. The `datetime` and `is_daytime` attributes are still provided for context. + +| Response data | Description | Example | +| ---------------------- | ----------- | -------- | +| `datetime` | The time of the forecasted conditions. | 2023-02-17T14:00:00+00:00 | +| `is_daytime` | Only set for `twice_daily` forecasts. | True | +| `detailed_description` | Only set for `twice_daily` forecasts. | 50% Chance of rain, otherwise partly cloudy with a high of 75F. | +| `short_description` | Short weather condition | Partly Sunny then Slight Chance Showers And Thunderstorms | + +## Details Details about the API are available in the [NWS API documentation](https://www.weather.gov/documentation/services-web-api). The [pynws](https://github.com/MatthewFlamm/pynws) library is used to retrieve data. - -Details about the `weather.get_forecasts` action are available in the [`weather` documentation](/integrations/weather/).