Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add forecast service call for extra attributes for nws #32729

Merged
34 changes: 31 additions & 3 deletions source/_integrations/nws.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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.
## 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).
Comment on lines +31 to +33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix trailing spaces and align terminology.

Remove trailing spaces and align the terminology with the rest of the document.

-## Action `nws.get_forecasts_extra` 
+## Action `nws.get_forecasts_extra`
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## 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).
## 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).
Tools
Markdownlint

31-31: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


| Data attribute | Optional | Description | Example |
| ---------------------- | -------- | ----------- | --------|
| `type` | no | The type of forecast, must be either `twice_daily` or `hourly`. | `twice_daily` |
Comment on lines +35 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix table formatting and improve attribute description.

The table rows are missing trailing pipes, and the description for the type attribute should specify the forecast types.

| Data attribute | Optional | Description | Example |
| ---------------------- | -------- | ----------- | --------|
| `type` | no | The type of forecast, must be either `twice_daily` or `hourly`. | `twice_daily` |

Committable suggestion was skipped due to low confidence.


```yaml
service: nws.get_forecasts_extra
target:
entity_id:
- weather.khou
data:
type: twice_daily
response_variable: weather_forecast
```

Details about the `weather.get_forecasts` action are available in the [`weather` documentation](/integrations/weather/).
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.
Comment on lines +49 to +50
Copy link
Contributor

@coderabbitai coderabbitai bot Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix redundancy in the description.

The phrase "at a given point in time" is redundant.

- `forecast` is a list of forecasted conditions at a given point in time that are not returned from `weather.get_forecasts`.
+ `forecast` is a list of forecasted conditions at a point in time that are not returned from `weather.get_forecasts`.
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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.
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 point in time that are not returned from `weather.get_forecasts`. The `datetime` and `is_daytime` attributes are still provided for context.
Tools
LanguageTool

[style] ~50-~50: This phrase is redundant. Consider writing “point” or “time”.
Context: ...ist of forecasted conditions at a given point in time that are not returned from `weather.get...

(MOMENT_IN_TIME)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phrasing "forecast is a list of forecasted conditions at a given point in time" is mirrored from the parent weather.get_forecasts action. This language should be kept consistent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MatthewFlamm Thank you for pointing out the importance of maintaining consistency with the weather.get_forecasts documentation. I agree that we should keep the phrasing "at a given point in time" to ensure uniformity across the documentation.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the `weather.get_forecasts` action documentation to verify the phrasing.
rg "weather.get_forecasts" -A 10

Length of output: 9388

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the weather.get_forecasts documentation language is changed, we should change here in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MatthewFlamm Thank you for the clarification. I agree that if the weather.get_forecasts documentation language is updated in the future, we should also update the nws.get_forecasts_extra documentation to maintain consistency.


| 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 |
Comment on lines +52 to +57
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix table formatting and remove redundancy in description.

The table rows are missing trailing pipes, and the description of the forecast field is redundant.

| 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 |

Additionally, update the description to remove redundancy:

-`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.
+`forecast` is a list of forecasted conditions at a point in time that are not returned from `weather.get_forecasts`. The `datetime` and `is_daytime` attributes are still provided for context.
Tools
LanguageTool

[uncategorized] ~57-~57: Possible missing preposition found.
Context: ...ition | Partly Sunny then Slight Chance Showers And Thunderstorms | ## Details Detail...

(AI_EN_LECTOR_MISSING_PREPOSITION)


## 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.