switching to wttr to avoid api key requirement

This commit is contained in:
Keegan 2022-08-17 16:43:56 -04:00
parent 60972cc069
commit 4d8504a05a
4 changed files with 17 additions and 1 deletions

View File

@ -46,7 +46,7 @@ func SymbolTest() {
"Sunny": '\ue32b',
"ThunderyHeavyRain": '\ue31d',
"ThunderyShowers": '\ue31d',
"ThunderySnowShowers": '\ue365',
"ThunderySnowShowers": '\ue366',
"VeryCloudy": '\ue312',
}

1
bin/weather/tmp.json Normal file
View File

@ -0,0 +1 @@
{ "FeelsLikeC": "28", "FeelsLikeF": "82", "cloudcover": "75", "humidity": "48", "localObsDateTime": "2022-08-17 01:09 PM", "observation_time": "05:09 PM", "precipInches": "0.0", "precipMM": "0.3", "pressure": "1015", "pressureInches": "30", "temp_C": "25", "temp_F": "77", "uvIndex": "4", "visibility": "16", "visibilityMiles": "9", "weatherCode": "116", "weatherDesc": [ { "value": "Partly cloudy" } ], "weatherIconUrl": [ { "value": "" } ], "winddir16Point": "E", "winddirDegree": "80", "windspeedKmph": "22", "windspeedMiles": "14" }

Binary file not shown.

15
bin/weather/wttr.sh Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
HOUR=$(timedatectl | grep Local | cut -d ':' -f 2 | cut -d ' ' -f 4 | cut -d ':' -f 1)
if [[ ${HOUR} -gt 21 || ${HOUR} -lt 5 ]] ; then # between 9 pm and 5 am
TIME_OF_DAY="NIGHT"
else
TIME_OF_DAY="DAY"
fi
URL=$(printf 'https://v2%s.wttr.in?0&format=j1&nonce=$RANDOM' $TOD)
WTTR=$(curl --silent -fL $URL)
TMP=$(echo $WTTR | jq -r '.current_condition[0]')
TEMP=$(echo $TMP | jq -r '.temp_F')
HUMIDITY=$(echo $TMP | jq -r '.humidity')
CONDITIONS=$(echo $TMP | jq -r '.weatherDesc[0].value')
echo $TEMP $HUMIDITY $CONDITIONS