diff --git a/wled b/wled index f9d53b3..451472c 100755 --- a/wled +++ b/wled @@ -7,7 +7,7 @@ # License: CC0 print_usage() { - echo "Usage: $0 [f(nordcenter)|w(ohnzimmer)] [on|off|1-17 (preset number)|dump]" + echo "Usage: $0 [f(nordcenter)|w(ohnzimmer)] [on|off|1-17|list]" } if test $# -ne 2; then @@ -41,6 +41,15 @@ case "$2" in [1-9]|[1-9][0-7]) api_resp=$(curl -s -4 --json "{'on':true,'ps':$2}" "http://$wled_host/json") ;; + l|list) + echo "Presets on $wled_host:" + curl -s -4 "http://$wled_host/presets.json" | \ + # Split into lines. One line per preset. + sed --sandbox -n 's/"\([0-9]\{1,2\}\)"/\n"\1"/gp' | \ + # Extract number and name. Append final newline. + sed --sandbox -n 's/^"\([0-9]\{1,2\}\)":.*"n":"\([[:print:]]*\)".*$/\1: \2/p; a\' + exit $? + ;; dump) curl -s -4 -w '\n' "http://$wled_host/json" exit 0