Added "list" command
This commit is contained in:
parent
edbc155a59
commit
1262a24b21
1 changed files with 10 additions and 1 deletions
11
wled
11
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
|
||||
|
|
Loading…
Reference in a new issue