weather conditions
This commit is contained in:
parent
ea7ba67add
commit
5643f79535
|
@ -10,18 +10,57 @@ ME="${0##*/}"
|
||||||
|
|
||||||
. "$MY_PATH/../tools/my.sh"
|
. "$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
|
## GET IPFSNODEID WHEATER
|
||||||
source ~/.zen/GPS
|
source ~/.zen/GPS
|
||||||
echo "... ~/.zen/GPS ... $LAT $LON ..."
|
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
|
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"
|
url="http://api.openweathermap.org/data/2.5/weather?q=$ville&APPID=$api_key&units=metric"
|
||||||
meteo=$(curl -s $url)
|
meteo=$(curl -s $url)
|
||||||
# Extraire les informations pertinentes de la réponse JSON
|
|
||||||
temperature=$(echo $meteo | jq -r '.main.temp')
|
# Extract relevant weather information
|
||||||
description=$(echo $meteo | jq -r '.weather[0].description')
|
condition=$(echo "$meteo" | jq -r '.weather[0].main')
|
||||||
echo "$ville : $description, ( $temperature °C )"
|
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 ...
|
## SATELLITE IMAGE ...
|
||||||
## Add more +++
|
## Add more +++
|
||||||
|
|
Loading…
Reference in New Issue