Clear MPD state on non-0 exit from MPD song sensor
[khatus.git] / bin / khatus_controller
index 587e37c..72136d0 100755 (executable)
@@ -2,13 +2,22 @@
 
 /^OK/ { debug("OK line", $0) }
 
+/^ERROR in:MPD.*NON_ZERO_EXIT_CODE/ {
+    for (mpd_key in db) {
+        if (mpd_key ~ "^mpd_") {
+            delete db[mpd_key]
+        }
+    }
+    next
+}
+
 /^ERROR/ {
-       debug("ERROR line", $0)
-       shift()
-       msg_head = $1
-       shift()
-       msg_body = $0
-       alert_trigger_hi(msg_head, "KhatusSensorError", msg_body)
+    debug("ERROR line", $0)
+    shift()
+    msg_head = $1
+    shift()
+    msg_body = $0
+    alert_trigger_hi(msg_head, "KhatusSensorError", msg_body)
 }
 
 /^OK in:ENERGY battery/\
     db["weather_temperature"] = $0
 }
 
-/^OK in:WEATHER phenomena/\
+/^OK in:WEATHER phenomenon/\
 {
     shift()
     shift()
     shift()
-    alert_trigger_low("weather_phenomena", "WeatherPhenomena", $0)
+    alert_trigger_low("weather_phenomenon", "WeatherPhenomenon", $0)
 }
 
 /^OK in:DATE_TIME/\
This page took 0.037713 seconds and 4 git commands to generate.