From aa7915789186f59feb302b9d6739d1d790454b00 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 4 Mar 2017 20:24:58 +0000 Subject: [PATCH] first step to implement animations for lounge light --- light.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/light.sh b/light.sh index c6a7e37..a4f84cb 100755 --- a/light.sh +++ b/light.sh @@ -17,7 +17,7 @@ STATE_1="a\x00\x03\xff\xff\xff|255255255255255255;\ STATE_2="n\x00\x02\x01\x00|170000070150000050;\ 000000000000000000;\ 000000000000000000" -STATE_3="!/usr/bin/python3 /home/automation/fensterbogenbeleuchtung_animations/animations.py|170000070150000050;\ +STATE_3="!/usr/bin/python3 /home/automation/fensterbogenbeleuchtung_animations/animations.py|!;\ 000000000000000000;\ 000000000000000000" @@ -44,13 +44,7 @@ esac set_room_color() { case "$ROOM_NUMBER" in 1) - PID_FILES="$( find "$(dirname "$TMPFILE_PID_BASE")" -name "$(basename "${TMPFILE_PID_BASE}_1_*")" )" - if ! [ -z "$PID_FILES" ]; then - for i in "$PID_FILES"; do - kill "$( cat "$i" )" - rm -f "$i" - done - fi + find "$(dirname "$TMPFILE_PID_BASE")" -name "$(basename "${TMPFILE_PID_BASE}_1_*")" -exec sh -c 'cat {} | xargs kill; rm -f {}' \; COLOR_A="$(echo "$STATE" | cut -d";" -f1 | cut -d"|" -f1)" COLOR_B="$(echo "$STATE" | cut -d";" -f1 | cut -d"|" -f2)" if [ "${COLOR_A:0:1}" == "!" ]; then @@ -59,7 +53,17 @@ case "$ROOM_NUMBER" in else for i in {1..5}; do (echo -en "$COLOR_A" > /dev/udp/172.23.92.15/49152 &); sleep .01; done fi - for i in {1..5}; do (echo -en "$COLOR_B" > /dev/udp/172.23.92.16/31302 &); done + if [ "${COLOR_B:0:1}" == "!" ]; then + ( + while true; do + echo -en "255204017255204017" > /dev/udp/172.23.92.16/31302 & + sleep .5 + done + ) & + echo $! > ${TMPFILE_PID_BASE}_1_B + else + for i in {1..5}; do (echo -en "$COLOR_B" > /dev/udp/172.23.92.16/31302 &); sleep .01; done + fi ;; 2) # COLOR_A="$(echo "$STATE" | cut -d";" -f2 | cut -d"|" -f1)"