Replies: 3 comments 1 reply
-
|
This need for choosing icon: $clear_day = 226,152,128,239,184,143
$few_clouds = 240,159,140,164,239,184,143
$partly_cloudy = 240,159,140,165,239,184,143,239,184,143
$cloudy = 240,159,140,167,239,184,143,239,184,143,239,184,143
$rain = 240,159,140,166,239,184,143,239,184,143,239,184,143,239,184,143
$thunderstorm = 226,155,136,239,184,143,239,184,143,239,184,143,239,184,143,239,184,143
$snowflake = 226,157,132,239,184,143,239,184,143,239,184,143,239,184,143,239,184,143
$snowman = 226,155,132,239,184,143,239,184,143,239,184,143,239,184,143
$wind = 240,159,140,172,239,184,143,239,184,143,239,184,143,239,184,143
$tornado = 240,159,140,170,239,184,143,239,184,143,239,184,143,239,184,143,239,184,143
$fog = 240,159,140,171,239,184,143,239,184,143,239,184,143,239,184,143,239,184,143,239,184,143
$rainbow = 240,159,140,136,239,184,143,239,184,143,239,184,143,239,184,143,239,184,143,239,184,143
Try
{
$ErrorActionPreference = 'Stop'
$json = Invoke-RestMethod wttr.in/Moscow?format=j1
}
Catch
{
Wtite-Host "`e[91merror: `e[0mService is unavailable"
return
}
$condition = $json.current_condition.weatherDesc.Value
$temp = $json.current_condition.temp_C
$windDirection = $json.current_condition.winddir16Point
$windSpeed = $json.current_condition.windspeedKmph
$pressure = [int]($json.current_condition.pressure) / 1.35951
$icon =
switch ($condition) # Need for all available
{
"Sunny" { [text.encoding]::UTF8.GetString($clear_day) }
"Cloudy" { [text.encoding]::UTF8.GetString($cloudy) }
default { $_ }
}
'Moscow: {0} {1}°C {2} {3}km/h {4}mmHg' -f $icon, $temp, $windDirection, $windSpeed, [int] $pressure
|
Beta Was this translation helpful? Give feedback.
-
|
They are called WWO codes Line 9 in 7c841f4 or |
Beta Was this translation helpful? Give feedback.
-
|
This is not a complete list, but it is better than what you currently have: https://github.com/chubin/wttr.in/blob/master/share/translations/en.txt The most comprehensive list of all supported weather conditions is available here (refer to the third column for English names): https://github.com/chubin/wttr.in/blob/master/share/translations/de.txt However, not all conditions have a correspondent numeric ID, as you can see |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Could you show me a list of available weather condition names? I only know "Sunny" and "Cloudy". So as not to find out in practice every day.
Beta Was this translation helpful? Give feedback.
All reactions