added new lounge light mode

This commit is contained in:
root 2017-03-04 17:27:48 +00:00
parent 91212e0468
commit 14e32028dd
1 changed files with 32 additions and 10 deletions

View File

@ -2,6 +2,7 @@
TMPFILE_BASE=/tmp/light_state
TMPFILE_CUSTOM_BASE=/tmp/light_state_custom
TMPFILE_PID_BASE=/tmp/light_state_pid
ROOM_NUMBER="$1"
COLOR="$2"
@ -16,6 +17,9 @@ 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;\
000000000000000000;\
000000000000000000"
get_room_color_string() {
case "$ROOM_NUMBER" in
@ -40,18 +44,36 @@ esac
set_room_color() {
case "$ROOM_NUMBER" in
1)
echo -en "$(echo "$STATE" | cut -d";" -f1 | cut -d"|" -f1)" > /dev/udp/172.23.92.15/49152 &
echo -en "$(echo "$STATE" | cut -d";" -f1 | cut -d"|" -f2)" > /dev/udp/172.23.92.16/31302 &
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
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
${COLOR_A:1} >/dev/null 2>&1 &
echo $! > ${TMPFILE_PID_BASE}_1_A
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
;;
2)
# echo -en "$(echo "$STATE" | cut -d";" -f2 | cut -d"|" -f1)" > /dev/null
# echo -en "$(echo "$STATE" | cut -d";" -f2 | cut -d"|" -f2)" > /dev/null
# COLOR_A="$(echo "$STATE" | cut -d";" -f2 | cut -d"|" -f1)"
# COLOR_B="$(echo "$STATE" | cut -d";" -f2 | cut -d"|" -f2)"
# echo -en "$COLOR_A" > /dev/null
# echo -en "$COLOR_B" > /dev/null
echo "not implemented" >&1
exit 1
;;
3)
# echo -en "$(echo "$STATE" | cut -d";" -f3 | cut -d"|" -f1)" > /dev/null
# echo -en "$(echo "$STATE" | cut -d";" -f3 | cut -d"|" -f2)" > /dev/null
# COLOR_A="$(echo "$STATE" | cut -d";" -f3 | cut -d"|" -f1)"
# COLOR_B="$(echo "$STATE" | cut -d";" -f3 | cut -d"|" -f2)"
# echo -en "$COLOR_A" > /dev/null
# echo -en "$COLOR_B" > /dev/null
echo "not implemented" >&1
exit 1
;;
@ -87,6 +109,9 @@ if [ -z "$COLOR" ]; then
2)
STATE=$STATE_2
;;
3)
STATE=$STATE_3
;;
*)
STATE=$STATE_0
LIGHT_STATE=0
@ -97,9 +122,6 @@ else
touch "${TMPFILE_CUSTOM_BASE}_$ROOM_NUMBER"
fi
for i in {1..5}; do
set_room_color
sleep .01
done
set_room_color
echo $LIGHT_STATE > "${TMPFILE_BASE}_$ROOM_NUMBER"