weather conditions

This commit is contained in:
fred 2024-02-25 20:29:05 +01:00
parent ea7ba67add
commit 5643f79535
1 changed files with 45 additions and 6 deletions

View File

@ -10,18 +10,57 @@ ME="${0##*/}"
. "$MY_PATH/../tools/my.sh"
# Mapping of weather conditions to emoticons
weather_emoticon_map=(
["Clear"]="😊"
["Clouds"]="☁️"
["Rain"]="🌧️"
["Snow"]="❄️"
["Thunderstorm"]="⛈️"
# Add more mappings as needed
)
default_emoticon="😊"
## GET IPFSNODEID WHEATER
source ~/.zen/GPS
echo "... ~/.zen/GPS ... $LAT $LON ..."
ville=$(my_IPCity)
echo "my_IPCity = $ville"
## caching IPCity
[[ ~/.zen/IPCity ]] \
&& my_IPCity > ~/.zen/IPCity
ville=$(cat ~/.zen/IPCity)
api_key="ac5e65a2fd10d3788d40cdae0d4516ba" # Remplacez YOUR_API_KEY par votre clé API OpenWeatherMap
url="http://api.openweathermap.org/data/2.5/weather?q=$ville&APPID=$api_key&units=metric"
meteo=$(curl -s $url)
# Extraire les informations pertinentes de la réponse JSON
temperature=$(echo $meteo | jq -r '.main.temp')
description=$(echo $meteo | jq -r '.weather[0].description')
echo "$ville : $description, ( $temperature °C )"
# Extract relevant weather information
condition=$(echo "$meteo" | jq -r '.weather[0].main')
emoticon=${weather_emoticon_map[$condition]}
selected_emoticon=${emoticon:-$default_emoticon}
description=$(echo "$meteo" | jq -r '.weather[0].description')
temp=$(echo "$meteo" | jq -r '.main.temp')
humidity=$(echo "$meteo" | jq -r '.main.humidity')
wind_speed=$(echo "$meteo" | jq -r '.wind.speed')
# Create a sentence with "emoticons" and ASCII art decorations
echo "# $ville
## $selected_emoticon $condition
$description
---
T=${temp} °C
H=${humidity} %
W=${wind_speed} m/s
---
😊 Stay cozy BRO !
"
## SATELLITE IMAGE ...
## Add more +++