From c929ed7d13a739c2e5674555b92cef22c3250928 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Sat, 20 Dec 2014 01:19:29 +0000 Subject: [PATCH] moved mswitch.cgi switch.cgi to deckenlichtschalter git repo --- raspberrypi_gpio_relay_licht/mswitch.cgi | 83 ------------ raspberrypi_gpio_relay_licht/switch.cgi | 209 ------------------------------ 2 files changed, 292 deletions(-) delete mode 100755 raspberrypi_gpio_relay_licht/mswitch.cgi delete mode 100755 raspberrypi_gpio_relay_licht/switch.cgi diff --git a/raspberrypi_gpio_relay_licht/mswitch.cgi b/raspberrypi_gpio_relay_licht/mswitch.cgi deleted file mode 100755 index d62bce9..0000000 --- a/raspberrypi_gpio_relay_licht/mswitch.cgi +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/zsh - -VALID_ONOFF_IDS=(ceiling1 ceiling2 ceiling3 ceiling4 ceiling5 ceiling6) -VALID_GPIO_IDS=(4 23 18 17 22 21) -local -A IDGPIOMAP -local -A GPIOIDMAP -IDGPIOMAP[ceiling1]=4 -IDGPIOMAP[ceiling2]=23 -IDGPIOMAP[ceiling3]=18 -IDGPIOMAP[ceiling4]=17 -IDGPIOMAP[ceiling5]=22 -IDGPIOMAP[ceiling6]=21 -GPIOPATH=/sys/class/gpio/gpio -SAVESTATE=/var/log/licht/mswitch.state - -for k v in ${(kv)IDGPIOMAP}; do - GPIOIDMAP[$v]=$k -done - -local -A GPIOS -for QUERY in `echo $QUERY_STRING | tr '&' ' '`; do - for VALIDID in $VALID_ONOFF_IDS; do - if [ "$QUERY" = "$VALIDID=1" ]; then - GPIOS[$IDGPIOMAP[$VALIDID]]=1 - elif [ "$QUERY" = "$VALIDID=0" ]; then - GPIOS[$IDGPIOMAP[$VALIDID]]=0 - fi - done - if [ "$QUERY" = "mobile=1" ]; then - MOBILE='1' - NOFLOAT='1' - elif [ "$QUERY" = "nofloat=1" ]; then - NOFLOAT='1' - fi -done - - -print_gpio_state() { - GPIO=${IDGPIOMAP[$1]} - GPIOVALUE=$(cat "${GPIOPATH}${GPIO}/value") - if [[ $GPIOVALUE == "0" ]]; then - echo -n "true" - else - echo -n "false" - fi -} - -print_gpio_state_10() { - GPIO=${IDGPIOMAP[$1]} - GPIOVALUE=$(cat "${GPIOPATH}${GPIO}/value") - if [[ $GPIOVALUE == "0" ]]; then - echo -n "1" - else - echo -n "0" - fi -} - -gpio_is_on() { - GPIO=${IDGPIOMAP[$1]} - GPIOVALUE=$(cat "${GPIOPATH}${GPIO}/value") - [ "$GPIOVALUE" = "0" ] -} - -echo "Content-type: text/html" -echo "" - -local -a GPIOSTATES -for CHECKID in $VALID_ONOFF_IDS; do - VAL=$GPIOS[$IDGPIOMAP[$CHECKID]] - if [[ $VAL == 1 || $VAL == 0 ]]; then - [[ $VAL == 1 ]] && VAL=0 || VAL=1 - echo "$VAL" > "${GPIOPATH}${IDGPIOMAP[$CHECKID]}/value" - fi - GPIOSTATES+=(\"${CHECKID}\":"$(print_gpio_state $CHECKID)") - URISTATES+=("${CHECKID}=$(print_gpio_state_10 $CHECKID)") -done -JSON_STATE="{${(j:,:)GPIOSTATES}}" -print ${(q)JSON_STATE} -if ((#GPIOS > 0)); then - print "[$(date +%s),\"$REMOTE_ADDR\",${(q)JSON_STATE}]," >> /var/log/licht/mswitch.log - echo -n "${(j:&:)URISTATES}">$SAVESTATE -fi - diff --git a/raspberrypi_gpio_relay_licht/switch.cgi b/raspberrypi_gpio_relay_licht/switch.cgi deleted file mode 100755 index 5ff6ac6..0000000 --- a/raspberrypi_gpio_relay_licht/switch.cgi +++ /dev/null @@ -1,209 +0,0 @@ -#!/bin/sh - -for QUERY in `echo $QUERY_STRING | tr '&' ' '`; do - for VALUE in `echo $QUERY | tr '=' ' '`; do - if [ "$VALUE" = "id" ]; then - ID='?' - elif [ "$ID" = "?" ]; then - ID=$VALUE - elif [ "$VALUE" = "power" ]; then - POWER='?' - elif [ "$POWER" = "?" ]; then - POWER=$VALUE - elif [ "$VALUE" = "mobile" ]; then - MOBILE='1' - NOFLOAT='1' - elif [ "$VALUE" = "nofloat" ]; then - NOFLOAT='1' - fi - i=$i+1 - done -done - -VALID_ONOFF_IDS="ceiling1 ceiling2 ceiling3 ceiling4 ceiling5 ceiling6" -VALID_SEND_IDS="" - -DESC_ceiling1="Decke E-Labor (SSW)" -DESC_ceiling2="Decke Leinwand (S)" -DESC_ceiling3="Decke Eingang (W)" -DESC_ceiling4="Decke Durchgang (O)" -DESC_ceiling5="Decke Auslage (N)" -DESC_ceiling6="Decke Küche (NNO)" - -echo "Content-type: text/html" -echo "" -echo "" -echo "" -echo "Realraum Relay Power" -echo '' -echo '' -echo "" -echo "" -#echo "

Realraum rf433ctl

" -#echo "
" -echo "
" -echo "
" -for DISPID in $VALID_ONOFF_IDS; do - NAME="$(eval echo -n \$DESC_$DISPID)" - [ -z "$NAME" ] && NAME=$DISPID - - echo "
" - echo "" - if gpio_is_on $DISPID; then - echo " " - echo " " - else - echo " " - echo " " - fi - echo "" - echo -n "
$NAME
" -# echo -n "
$NAME (" -# print_gpio_state $DISPID -# echo ")
" - echo "
" - - if [ "$NOFLOAT" = "1" ]; then - echo "
" - fi -done - -#Alle -echo "
" -echo "" -echo -n " " -echo -n " " -echo "" -echo -n "
Alle
" -echo "
" - -if [ "$NOFLOAT" = "1" ]; then - echo "
" -fi - -#Pattern1 -echo "
" -echo -n " " -echo -n " " -echo -n " " -echo -n " " -echo -n " " -echo -n " " -echo "
" - -if [ "$NOFLOAT" = "1" ]; then - echo "
" -fi -echo "
" - -if [ "$MOBILE" != "1" -a -n "$VALID_SEND_IDS" ]; then - -echo "
" - -ITEMCOUNT=0 - -echo "
" -fi -echo "
" -echo "" -echo "" -- 1.7.10.4