Split workers into dedicated files
[khatus.git] / bin / khatus_sensor_weather
diff --git a/bin/khatus_sensor_weather b/bin/khatus_sensor_weather
new file mode 100755 (executable)
index 0000000..340175d
--- /dev/null
@@ -0,0 +1,24 @@
+#! /bin/sh
+
+set -e
+
+weather_station_id="$1"
+
+metar -d "$weather_station_id" 2>&1 \
+| awk '
+    /METAR pattern not found in NOAA data/ {
+        failures++
+    }
+
+    /^Temperature/ {
+        celsius = $3;
+        fahrenheit = (celsius * (9 / 5)) + 32;
+        temperature = fahrenheit
+    }
+
+    END {
+        if (failures > 0) {
+            temperature = "--"
+        }
+        print temperature "°F"
+    }'
This page took 0.02575 seconds and 4 git commands to generate.