From: Bernhard Tittelbach Date: Mon, 21 Oct 2013 18:12:46 +0000 (+0000) Subject: router_gpio_relay_licht X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=d3cd153880388935532949db5c8f4a26731f6964;p=svn42.git router_gpio_relay_licht --- diff --git a/router_gpio_relay_licht/rc.local b/router_gpio_relay_licht/rc.local new file mode 100644 index 0000000..4978362 --- /dev/null +++ b/router_gpio_relay_licht/rc.local @@ -0,0 +1,14 @@ +# Put your custom commands here that should be executed once +# the system init finished. By default this file does nothing. + +rmmod gpio_button_hotplug +echo 7 > /sys/class/gpio/export +echo 18 > /sys/class/gpio/export +echo 20 > /sys/class/gpio/export +echo 29 > /sys/class/gpio/export +echo out > /sys/class/gpio/gpio7/direction +echo out > /sys/class/gpio/gpio18/direction +echo out > /sys/class/gpio/gpio20/direction +echo out > /sys/class/gpio/gpio29/direction + +exit 0 diff --git a/router_gpio_relay_licht/switch.cgi b/router_gpio_relay_licht/switch.cgi new file mode 100755 index 0000000..9f53097 --- /dev/null +++ b/router_gpio_relay_licht/switch.cgi @@ -0,0 +1,192 @@ +#!/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 + + +GPIOPATH=/sys/class/gpio/gpio +#VALID_ONOFF_IDS="7 18 20 29" +VALID_ONOFF_IDS="7 18 20" + +if [ "$POWER" == "1" -o "$POWER" == "0" ]; then + for CHECKID in $VALID_ONOFF_IDS ; do + if [ "$CHECKID" == "$ID" ]; then + echo "$POWER" > "${GPIOPATH}${ID}/value" + echo "Content-type: text/html" + echo "" + echo "" + echo "" + echo "Realraum Relay Switch" + echo '' + echo "" + exit 0 + fi + done +fi + +DESC_7="Decke Links Vorne" +DESC_20="Decke Rechts Vorne" +DESC_18="Decke Rechts Mitte" +#DESC_29="GPIO Nicht Belegt" + +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 \$DESC_$DISPID)" + [ -z "$NAME" ] && NAME=$DISPID + +echo "
" + echo "" + echo " " + echo " " + echo "" + echo "
$NAME
" + echo "
" + + if [ "$NOFLOAT" == "1" ]; then + echo "
" + fi +done + +echo "
" + +if [ "$MOBILE" != "1" ]; then + +echo "
" + +ITEMCOUNT=0 + +for DISPID in $VALID_SEND_IDS; do + ITEMCOUNT=$((ITEMCOUNT+1)) + NAME="$(eval echo \$DESC_$DISPID)" + [ -z "$NAME" ] && NAME=$DISPID + + echo "
" + echo "" + echo " " + echo "" + echo "
$NAME
" + echo "
" + if [ "$NOFLOAT" == "1" -a $((ITEMCOUNT % 2 )) -ne 1 ]; then + echo "
" + fi + +done +echo "
" + + if [ "$NOFLOAT" == "1" ]; then + echo "
" + tail -n+107 /www/ymhremote.html | head -n 5 + echo "
" + fi + +echo "
" +for DISPID in $VALID_BANSHEE_IDS $VALID_CAM_MOTOR_IDS; do + NAME="$(eval echo \$DESC_$DISPID)" + [ -z "$NAME" ] && NAME=$DISPID + + echo "
" + echo "" + echo " " + echo "" + echo "
$NAME
" + echo "
" + if [ "$NOFLOAT" == "1" ]; then + echo "
" + fi + +done +echo "
" +fi +echo "
" +echo "" +echo ""