Compare commits
2 commits
edbc155a59
...
bc484958a3
Author | SHA1 | Date | |
---|---|---|---|
bc484958a3 | |||
1262a24b21 |
2 changed files with 12 additions and 1 deletions
|
@ -2,3 +2,5 @@
|
|||
|
||||
Simple shell script to turn predefined wled instances on/off or switch presets.
|
||||
|
||||
Requires *curl* version 7.82.0 or newer.
|
||||
|
||||
|
|
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…
Add table
Reference in a new issue