l radio: add probability of precipitation

This commit is contained in:
lassulus 2022-06-06 12:55:34 +02:00
parent 885a068ad4
commit 2bb08f9cef
2 changed files with 7 additions and 6 deletions

View File

@ -2,6 +2,7 @@
let
weather_for_ips = pkgs.writers.writePython3Bin "weather_for_ips" {
libraries = [ pkgs.python3Packages.geoip2 ];
flakeIgnore = [ "E501" ];
} ./weather_for_ips.py;
weather_report = pkgs.writers.writeDashBin "weather_report" ''

View File

@ -21,13 +21,13 @@ for ip in fileinput.input():
f'&units=metric'
)
resp = requests.get(url)
weather = json.loads(resp.text)['current']
weather = json.loads(resp.text)
output.append(
f'Weather report for {location.city.name}'
f', {location.country.name}. '
f'Currently it is {weather["weather"][0]["description"]} outside '
f'with a temperature of {weather["temp"]} degrees '
f'and a windspeed of {weather["wind_speed"]} meter per second. '
f'Weather report for {location.city.name}, {location.country.name}. '
f'Currently it is {weather["current"]["weather"][0]["description"]} outside '
f'with a temperature of {weather["current"]["temp"]} degrees, '
f'and a windspeed of {weather["current"]["wind_speed"]} meter per second. '
f'The probability of precipitation is {weather["hourly"][0]["pop"] * 100} percent. '
)
print('\n'.join(output))