From 08c90c95b71f74a15b09c23efef484d4b471ec04 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 6 Jan 2020 10:33:27 +0100 Subject: mode-button-scheduler: give proper message if no action defined --- mode-button-scheduler | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'mode-button-scheduler') diff --git a/mode-button-scheduler b/mode-button-scheduler index 2873398..2b6f083 100644 --- a/mode-button-scheduler +++ b/mode-button-scheduler @@ -8,20 +8,24 @@ :local Count ($ModeButton->"count"); :local Code ($ModeButton->[ :tostr $Count ]); -:local Parsed [ :parse $Code ]; :set ($ModeButton->"count") 0; / system scheduler remove mode-button-scheduler; -:log info ("Acting on " . $Count . " mode-button presses: " . $Code); +:if ([ :len $Code ] > 0) do={ + :log info ("Acting on " . $Count . " mode-button presses: " . $Code); -:if ([ / system routerboard settings get silent-boot ] = false) do={ - :for I from=1 to=$Count do={ - :beep length=200ms; - :delay 200ms; + :if ([ / system routerboard settings get silent-boot ] = false) do={ + :for I from=1 to=$Count do={ + :beep length=200ms; + :delay 200ms; + } + } else={ + :delay 1s; } + + :local Parsed [ :parse $Code ]; + $Parsed; } else={ - :delay 1s; + :log info ("No action defined for " . $Count . " mode-button presses."); } - -$Parsed; -- cgit v1.2.3-70-g09d2