summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2022-06-06 12:55:34 +0200
committerlassulus <lassulus@lassul.us>2022-06-06 12:55:45 +0200
commit2bb08f9cef428b7e7ac9864eea30a74984aea693 (patch)
treecd61a0672ca185daabd041157dd4f59649b58c07
parent885a068ad4a0e647cee527aabd39953ad3e238b2 (diff)
l radio: add probability of precipitation
-rw-r--r--lass/2configs/radio/news.nix1
-rw-r--r--lass/2configs/radio/weather_for_ips.py12
2 files changed, 7 insertions, 6 deletions
diff --git a/lass/2configs/radio/news.nix b/lass/2configs/radio/news.nix
index aa10ea29..99b58511 100644
--- a/lass/2configs/radio/news.nix
+++ b/lass/2configs/radio/news.nix
@@ -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" ''
diff --git a/lass/2configs/radio/weather_for_ips.py b/lass/2configs/radio/weather_for_ips.py
index 8d9a2e7b..213e69d3 100644
--- a/lass/2configs/radio/weather_for_ips.py
+++ b/lass/2configs/radio/weather_for_ips.py
@@ -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))