From 1262a24b21e713b727af085ec55cb3e95380d4e4 Mon Sep 17 00:00:00 2001 From: Shy Date: Fri, 2 Aug 2024 17:07:08 +0200 Subject: [PATCH] Added "list" command --- wled | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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