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

Spec requirements #1

Open
rwx-yxu opened this issue Jan 27, 2023 · 10 comments
Open

Spec requirements #1

rwx-yxu opened this issue Jan 27, 2023 · 10 comments

Comments

@rwx-yxu
Copy link
Owner

rwx-yxu commented Jan 27, 2023

Current thinking for the commands should be:

  • Now: Print out the current weather conditions along with the temp.
  • Day: Prints out an overview for the day for morning, afternoon and night. Temp high and lows as well.
  • Week: Prints out the week view

The weather API options are openweathermap or met office
Noticed that open weather map queries the met office anyway for their data
image

@rwx-yxu
Copy link
Owner Author

rwx-yxu commented Jan 27, 2023

Got an API key for Met office. I did some queries to the API and it feels less friendly to use than open weather map.
Firstly, I need to supply a location id for the met office site close to me. there is also a region id that the Met has for broader summary of the weather.

Can find sites through this call: http://datapoint.metoffice.gov.uk/public/data/val/wxfcs/all/json/sitelist?key=
Can find regions with this call: http://datapoint.metoffice.gov.uk/public/data/txt/wxfcs/regionalforecast/json/sitelist?key=

To get weather info, I need to use the location id after the data type along with a res parameter that only accepts 3hourly or daily.
Example response:

{
    "SiteRep": {
        "Wx": {
            "Param": [
                {
                    "name": "FDm",
                    "units": "C",
                    "$": "Feels Like Day Maximum Temperature"
                },
                {
                    "name": "FNm",
                    "units": "C",
                    "$": "Feels Like Night Minimum Temperature"
                },
                {
                    "name": "Dm",
                    "units": "C",
                    "$": "Day Maximum Temperature"
                },
                {
                    "name": "Nm",
                    "units": "C",
                    "$": "Night Minimum Temperature"
                },
                {
                    "name": "Gn",
                    "units": "mph",
                    "$": "Wind Gust Noon"
                },
                {
                    "name": "Gm",
                    "units": "mph",
                    "$": "Wind Gust Midnight"
                },
                {
                    "name": "Hn",
                    "units": "%",
                    "$": "Screen Relative Humidity Noon"
                },
                {
                    "name": "Hm",
                    "units": "%",
                    "$": "Screen Relative Humidity Midnight"
                },
                {
                    "name": "V",
                    "units": "",
                    "$": "Visibility"
                },
                {
                    "name": "D",
                    "units": "compass",
                    "$": "Wind Direction"
                },
                {
                    "name": "S",
                    "units": "mph",
                    "$": "Wind Speed"
                },
                {
                    "name": "U",
                    "units": "",
                    "$": "Max UV Index"
                },
                {
                    "name": "W",
                    "units": "",
                    "$": "Weather Type"
                },
                {
                    "name": "PPd",
                    "units": "%",
                    "$": "Precipitation Probability Day"
                },
                {
                    "name": "PPn",
                    "units": "%",
                    "$": "Precipitation Probability Night"
                }
            ]
        },
        "DV": {
            "dataDate": "2023-01-27T14:00:00Z",
            "type": "Forecast",
            "Location": {
                "i": "350473",
                "lat": "53.5207",
                "lon": "-2.2131",
                "name": "BLACKLEY",
                "country": "ENGLAND",
                "continent": "EUROPE",
                "elevation": "56.0",
                "Period": [
                    {
                        "type": "Day",
                        "value": "2023-01-27Z",
                        "Rep": [
                            {
                                "D": "NNE",
                                "Gn": "4",
                                "Hn": "86",
                                "PPd": "41",
                                "S": "2",
                                "V": "GO",
                                "Dm": "7",
                                "FDm": "6",
                                "W": "7",
                                "U": "1",
                                "$": "Day"
                            },
                            {
                                "D": "SW",
                                "Gm": "4",
                                "Hm": "95",
                                "PPn": "9",
                                "S": "2",
                                "V": "MO",
                                "Nm": "2",
                                "FNm": "1",
                                "W": "7",
                                "$": "Night"
                            }
                        ]
                    },
                    {
                        "type": "Day",
                        "value": "2023-01-28Z",
                        "Rep": [
                            {
                                "D": "SSW",
                                "Gn": "7",
                                "Hn": "88",
                                "PPd": "20",
                                "S": "4",
                                "V": "MO",
                                "Dm": "6",
                                "FDm": "5",
                                "W": "8",
                                "U": "1",
                                "$": "Day"
                            },
                            {
                                "D": "SW",
                                "Gm": "11",
                                "Hm": "96",
                                "PPn": "20",
                                "S": "7",
                                "V": "MO",
                                "Nm": "5",
                                "FNm": "2",
                                "W": "8",
                                "$": "Night"
                            }
                        ]
                    },
                    {
                        "type": "Day",
                        "value": "2023-01-29Z",
                        "Rep": [
                            {
                                "D": "WSW",
                                "Gn": "20",
                                "Hn": "83",
                                "PPd": "11",
                                "S": "11",
                                "V": "GO",
                                "Dm": "9",
                                "FDm": "5",
                                "W": "8",
                                "U": "1",
                                "$": "Day"
                            },
                            {
                                "D": "WNW",
                                "Gm": "31",
                                "Hm": "78",
                                "PPn": "20",
                                "S": "16",
                                "V": "VG",
                                "Nm": "6",
                                "FNm": "1",
                                "W": "8",
                                "$": "Night"
                            }
                        ]
                    },
                    {
                        "type": "Day",
                        "value": "2023-01-30Z",
                        "Rep": [
                            {
                                "D": "WNW",
                                "Gn": "27",
                                "Hn": "72",
                                "PPd": "11",
                                "S": "13",
                                "V": "VG",
                                "Dm": "8",
                                "FDm": "4",
                                "W": "8",
                                "U": "1",
                                "$": "Day"
                            },
                            {
                                "D": "WSW",
                                "Gm": "22",
                                "Hm": "85",
                                "PPn": "48",
                                "S": "11",
                                "V": "VG",
                                "Nm": "5",
                                "FNm": "3",
                                "W": "12",
                                "$": "Night"
                            }
                        ]
                    },
                    {
                        "type": "Day",
                        "value": "2023-01-31Z",
                        "Rep": [
                            {
                                "D": "W",
                                "Gn": "34",
                                "Hn": "76",
                                "PPd": "15",
                                "S": "18",
                                "V": "VG",
                                "Dm": "9",
                                "FDm": "4",
                                "W": "7",
                                "U": "1",
                                "$": "Day"
                            },
                            {
                                "D": "W",
                                "Gm": "31",
                                "Hm": "77",
                                "PPn": "14",
                                "S": "16",
                                "V": "VG",
                                "Nm": "6",
                                "FNm": "2",
                                "W": "8",
                                "$": "Night"
                            }
                        ]
                    }
                ]
            }
        }
    }
}

@rwx-yxu
Copy link
Owner Author

rwx-yxu commented Jan 27, 2023

Additional parsing would be required to match the rep names numbers to their actual meaning.

@rwx-yxu
Copy link
Owner Author

rwx-yxu commented Jan 27, 2023

The regional forecast call is useful because it outputs a description for what the weather will be like for the day night and next day:

{
    "RegionalFcst": {
        "createdOn": "2023-01-27T02:22:28",
        "issuedAt": "2023-01-27T04:00:00",
        "regionId": "nw",
        "FcstPeriods": {
            "Period": [
                {
                    "id": "day1to2",
                    "Paragraph": [
                        {
                            "title": "Headline:",
                            "$": "Mostly dry on Friday albeit rather cloudy at times."
                        },
                        {
                            "title": "Today:",
                            "$": "A few light showers are possible this morning, but otherwise today will be mostly dry after early mist clears. Fairly cloudy at times but some brightness is likely, with lengthier sunny spells this afternoon. Light winds and temperatures around average. Maximum Temperature 7C."
                        },
                        {
                            "title": "Tonight:",
                            "$": "Dry with clear spells this evening and remaining generally dry overnight. Patchy frost developing, with areas of low cloud, mist and freezing fog forming. Drizzly rain possible in Cumbria later. Minimum Temperature -2C."
                        },
                        {
                            "title": "Saturday:",
                            "$": "A grey and cloudy day for most areas, with murky conditions at times over higher ground and intermittent light rain and drizzle. Brighter skies may arrive across Cumbria later. Maximum Temperature 8C."
                        }
                    ]
                },

finding the region id is required first for the call

@rwx-yxu
Copy link
Owner Author

rwx-yxu commented Jan 27, 2023

I think that having the summary is nice to have. Open weather API has subscriptions for certain things. Not too much of a difference for the free version because you will get access to 3 hour period forecasts. You will have to supply a long and lat though.

On the other hand, I can make a call to the met office for the sites and set the default one as a cached var. Additional command called "List" which outputs all of the sites. The sites call doesn't provide the regional id so a separate call will need to be made to match the site name with the id.

@rwx-yxu
Copy link
Owner Author

rwx-yxu commented Jan 28, 2023

From a UX pov, having the output of all sites will be not all that friendly because there are over 5000. They wouldn't all fit on the screen.

@rwx-yxu
Copy link
Owner Author

rwx-yxu commented Jan 28, 2023

I should have the commands either accept a location or nothing. If the user passes through nothing, check the var defaultLocationID.

If the user inputs the regional area, then output the sites for that area and tell them to use one of the listed sites for the command.

@rwx-yxu
Copy link
Owner Author

rwx-yxu commented Jan 29, 2023

Only the region name is returned which is a pain because I'll have to make another separate call to the region site list end point to get the id for it if I would want to query for the regional forecast summary

@rwx-yxu
Copy link
Owner Author

rwx-yxu commented Jan 29, 2023

Could find a better way to set the region and site id. I am making two requests and looping through all of the returned values to match what the user has supplied. Not necessarily the best solution but it works.

@rwx-yxu
Copy link
Owner Author

rwx-yxu commented Jan 29, 2023

Met office API doesn't have an end point for the current weather conditions. Parameters that it outputs are for daily and 3 hour intervals.

image

Not sure how openweathermap is getting the current data and even hourly because they get their info from the met as their source.

The time stamp is are for 3hourly or daily time stamps in the future.

@rwx-yxu
Copy link
Owner Author

rwx-yxu commented Jan 31, 2023

My thinking right now is to make a new bonzai cmd for "forecast". The commands could be:

  • weather forecast today
    Each command would grab the daily end point temp and weather along with the regional cast for the day summary.
//Example weather forecast today
Day 7℃ - Cloudy | Night 4℃ - Rain
Windy with some rain to come on Wednesday
This Evening and Tonight:
It will stay windy overnight, especially on coasts and over high ground. There will be a mixture of clear spells and scattered showers overnight, but with more persistent showery rain affecting Cumbria later. Minimum Temperature 4C.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant