<html>
<head>
-<meta http-equiv="refresh" content="0; URL=http://licht.realraum.at/cgi-bin/switch.cgi?nofloat=1">
+<link rel="stylesheet" type="text/css" href="style.css">
</head>
+
+
+
+<script type="text/javascript">
+
+ var pc1_state=false;
+ var pc2_state=false;
+ var pc3_state=false;
+ var pc4_state=false;
+ var pc5_state=false;
+ var pc6_state=false;
+
+function callBackButtons(req)
+{
+ if(req.status != 200)
+ {
+ return;
+ }
+
+
+ var data = JSON.parse(req.responseText);
+
+ if(data['ceiling1']==true)
+ {
+ pc1_state=true;
+ document.getElementById("pc1").style.background="green";
+ }
+ else
+ {
+ pc1_state=false;
+ document.getElementById("pc1").style.background="red";
+ }
+
+
+ if(data['ceiling2']==true)
+ {
+ pc2_state=true;
+ document.getElementById("pc2").style.background="green";
+ }
+ else
+ {
+ pc2_state=false;
+ document.getElementById("pc2").style.background="red";
+ }
+
+ if(data['ceiling3']==true)
+ {
+ pc3_state=true;
+ document.getElementById("pc3").style.background="green";
+ }
+ else
+ {
+ pc3_state=false;
+ document.getElementById("pc3").style.background="red";
+ }
+
+
+ if(data['ceiling4']==true)
+ {
+ pc4_state=true;
+ document.getElementById("pc4").style.background="green";
+ }
+ else
+ {
+ pc4_state=false;
+ document.getElementById("pc4").style.background="red";
+ }
+
+
+ if(data['ceiling5']==true)
+ {
+ pc5_state=true;
+ document.getElementById("pc5").style.background="green";
+ }
+ else
+ {
+ pc5_state=false;
+ document.getElementById("pc5").style.background="red";
+ }
+
+ if(data['ceiling6']==true)
+ {
+ pc6_state=true;
+ document.getElementById("pc6").style.background="green";
+ }
+ else
+ {
+ pc6_state=false;
+ document.getElementById("pc6").style.background="red";
+ }
+}
+
+function updateButtons(uri) {
+ var req = new XMLHttpRequest;
+ req.overrideMimeType("application/json");
+ req.open("GET", uri, true);
+ req.onload = function() {callBackButtons(req)};
+ req.setRequestHeader("googlechromefix","");
+ req.send(null);
+}
+function sendMultiButton( str ) {
+ url = "/cgi-bin/mswitch.cgi?"+str;
+ updateButtons(url);
+}
+
+
+//function pc(n) switches light n
+
+function pc1()
+{
+ if(pc1_state===true)
+ {
+ pc1_state=false;
+ sendMultiButton("ceiling1=0")
+ document.getElementById("pc1").style.background="red";
+ }
+ else
+ {
+ pc1_state=true;
+ sendMultiButton("ceiling1=1")
+ document.getElementById("pc1").style.background="green";
+ }
+}
+function pc2()
+{
+ if(pc2_state===true)
+ {
+ pc2_state=false;
+ sendMultiButton("ceiling2=0")
+ document.getElementById("pc2").style.background="red";
+ }
+ else
+ {
+ pc2_state=true;
+ sendMultiButton("ceiling2=1")
+ document.getElementById("pc2").style.background="green";
+ }
+}
+function pc3()
+{
+ if(pc3_state===true)
+ {
+ pc3_state=false;
+ sendMultiButton("ceiling3=0")
+ document.getElementById("pc3").style.background="red";
+ }
+ else
+ {
+ pc3_state=true;
+ sendMultiButton("ceiling3=1")
+ document.getElementById("pc3").style.background="green";
+ }
+}
+function pc4()
+{
+ if(pc4_state===true)
+ {
+ pc4_state=false;
+ sendMultiButton("ceiling4=0")
+ document.getElementById("pc4").style.background="red";
+ }
+ else
+ {
+ pc4_state=true;
+ sendMultiButton("ceiling4=1")
+ document.getElementById("pc4").style.background="green";
+ }
+}
+function pc5()
+{
+ if(pc5_state===true)
+ {
+ pc5_state=false;
+ sendMultiButton("ceiling5=0")
+ document.getElementById("pc5").style.background="red";
+ }
+ else
+ {
+ pc5_state=true;
+ sendMultiButton("ceiling5=1")
+ document.getElementById("pc5").style.background="green";
+ }
+}
+
+function pc6()
+{
+ if(pc6_state===true)
+ {
+ pc6_state=false;
+ sendMultiButton("ceiling6=0")
+ document.getElementById("pc6").style.background="red";
+ }
+ else
+ {
+ pc6_state=true;
+ sendMultiButton("ceiling6=1")
+ document.getElementById("pc6").style.background="green";
+ }
+}
+
+setInterval("updateButtons('/cgi-bin/mswitch.cgi');", 30*100 );
+updateButtons("/cgi-bin/mswitch.cgi");
+</script>
+
+<body>
+<div style="position:absolute; top:640px;"><a href="switch.html">Link to old switches</a></div>
+<div class="pc1" id="pc1" onclick="pc1()"></div>
+<div class="pc2" id="pc2" onclick="pc2()"></div>
+<div class="pc3" id="pc3" onclick="pc3()"></div>
+<div class="pc4" id="pc4" onclick="pc4()"></div>
+<div class="pc5" id="pc5" onclick="pc5()"></div>
+<div class="pc6" id="pc6" onclick="pc6()"></div>
+</body>
</html>
--- /dev/null
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="stylez.css">
+</head>
+
+
+
+<script type="text/javascript">
+
+ var pc1_state=false;
+ var pc2_state=false;
+ var pc3_state=false;
+ var pc4_state=false;
+ var pc5_state=false;
+ var pc6_state=false;
+
+function callBackButtons(req)
+{
+ if(req.status != 200)
+ {
+ return;
+ }
+
+
+ var data = JSON.parse(req.responseText);
+
+ if(data['ceiling1']==true)
+ {
+ pc1_state=true;
+ document.getElementById("pc1").style.background="green";
+ }
+ else
+ {
+ pc1_state=false;
+ document.getElementById("pc1").style.background="red";
+ }
+
+
+ if(data['ceiling2']==true)
+ {
+ pc2_state=true;
+ document.getElementById("pc2").style.background="green";
+ }
+ else
+ {
+ pc2_state=false;
+ document.getElementById("pc2").style.background="red";
+ }
+
+ if(data['ceiling3']==true)
+ {
+ pc3_state=true;
+ document.getElementById("pc3").style.background="green";
+ }
+ else
+ {
+ pc3_state=false;
+ document.getElementById("pc3").style.background="red";
+ }
+
+
+ if(data['ceiling4']==true)
+ {
+ pc4_state=true;
+ document.getElementById("pc4").style.background="green";
+ }
+ else
+ {
+ pc4_state=false;
+ document.getElementById("pc4").style.background="red";
+ }
+
+
+ if(data['ceiling5']==true)
+ {
+ pc5_state=true;
+ document.getElementById("pc5").style.background="green";
+ }
+ else
+ {
+ pc5_state=false;
+ document.getElementById("pc5").style.background="red";
+ }
+
+ if(data['ceiling6']==true)
+ {
+ pc6_state=true;
+ document.getElementById("pc6").style.background="green";
+ }
+ else
+ {
+ pc6_state=false;
+ document.getElementById("pc6").style.background="red";
+ }
+}
+
+function updateButtons(uri) {
+ var req = new XMLHttpRequest;
+ req.overrideMimeType("application/json");
+ req.open("GET", uri, true);
+ req.onload = function() {callBackButtons(req)};
+ req.setRequestHeader("googlechromefix","");
+ req.send(null);
+}
+function sendMultiButton( str ) {
+ url = "/cgi-bin/mswitch.cgi?"+str;
+ updateButtons(url);
+}
+
+
+//function pc(n) switches light n
+
+function pc1()
+{
+ if(pc1_state===true)
+ {
+ pc1_state=false;
+ sendMultiButton("ceiling1=0")
+ document.getElementById("pc1").style.background="red";
+ }
+ else
+ {
+ pc1_state=true;
+ sendMultiButton("ceiling1=1")
+ document.getElementById("pc1").style.background="green";
+ }
+}
+function pc2()
+{
+ if(pc2_state===true)
+ {
+ pc2_state=false;
+ sendMultiButton("ceiling2=0")
+ document.getElementById("pc2").style.background="red";
+ }
+ else
+ {
+ pc2_state=true;
+ sendMultiButton("ceiling2=1")
+ document.getElementById("pc2").style.background="green";
+ }
+}
+function pc3()
+{
+ if(pc3_state===true)
+ {
+ pc3_state=false;
+ sendMultiButton("ceiling3=0")
+ document.getElementById("pc3").style.background="red";
+ }
+ else
+ {
+ pc3_state=true;
+ sendMultiButton("ceiling3=1")
+ document.getElementById("pc3").style.background="green";
+ }
+}
+function pc4()
+{
+ if(pc4_state===true)
+ {
+ pc4_state=false;
+ sendMultiButton("ceiling4=0")
+ document.getElementById("pc4").style.background="red";
+ }
+ else
+ {
+ pc4_state=true;
+ sendMultiButton("ceiling4=1")
+ document.getElementById("pc4").style.background="green";
+ }
+}
+function pc5()
+{
+ if(pc5_state===true)
+ {
+ pc5_state=false;
+ sendMultiButton("ceiling5=0")
+ document.getElementById("pc5").style.background="red";
+ }
+ else
+ {
+ pc5_state=true;
+ sendMultiButton("ceiling5=1")
+ document.getElementById("pc5").style.background="green";
+ }
+}
+
+function pc6()
+{
+ if(pc6_state===true)
+ {
+ pc6_state=false;
+ sendMultiButton("ceiling6=0")
+ document.getElementById("pc6").style.background="red";
+ }
+ else
+ {
+ pc6_state=true;
+ sendMultiButton("ceiling6=1")
+ document.getElementById("pc6").style.background="green";
+ }
+}
+
+setInterval("updateButtons('/cgi-bin/mswitch.cgi');", 30*100 );
+updateButtons("/cgi-bin/mswitch.cgi");
+</script>
+
+<body>
+<div class="pc1" id="pc1" onclick="pc1()"></div>
+<div class="pc2" id="pc2" onclick="pc2()"></div>
+<div class="pc3" id="pc3" onclick="pc3()"></div>
+<div class="pc4" id="pc4" onclick="pc4()"></div>
+<div class="pc5" id="pc5" onclick="pc5()"></div>
+<div class="pc6" id="pc6" onclick="pc6()"></div>
+
+</body>
+</html>
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
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")
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
+
-#!/bin/sh -e
-#
-# rc.local
-#
-# This script is executed at the end of each multiuser runlevel.
-# Make sure that the script will "exit 0" on success or any other
-# value on error.
-#
-# In order to enable or disable this script just change the execution
-# bits.
-#
-# By default this script does nothing.
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: rc.local
+# Required-Start: $all
+# Required-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop:
+# Short-Description: Run /etc/rc.local if it exist
+### END INIT INFO
-for gpio in 4 17 18 21 22 23; do
- echo $gpio > /sys/class/gpio/export
- echo out > /sys/class/gpio/gpio$gpio/direction
- chown www-data /sys/class/gpio/gpio$gpio/value
-done
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
-# Print the IP address
-_IP=$(hostname -I) || true
-if [ "$_IP" ]; then
- printf "My IP address is %s\n" "$_IP"
-fi
+. /lib/init/vars.sh
+. /lib/lsb/init-functions
-MAX_TRIES=20
-if ! ifconfig eth0 && ifconfig wlan0 ; then
- sleep 6
- while ((MAX_TRIES-- > 0)) && ! /sbin/wpa_cli status | grep -q wpa_state=COMPLETED; do
- /sbin/wpa_cli status
- ifdown wlan0
- ifup wlan0
- done
-fi
+do_start() {
+ if [ -x /etc/rc.local ]; then
+ [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)"
+ /etc/rc.local
+ ES=$?
+ [ "$VERBOSE" != no ] && log_end_msg $ES
+ return $ES
+ fi
+}
-su realraum -s /bin/sh -c "sleep 10 && /home/realraum/play-sound-status.py /home/realraum/play-sound-status.cfg &>/dev/null &" &
-su realraum -s /bin/sh -c "sleep 10 && /home/realraum/stuff.py &>/dev/null &" &
-
-exit 0
+case "$1" in
+ start)
+ do_start
+ ;;
+ restart|reload|force-reload)
+ echo "Error: argument '$1' not supported" >&2
+ exit 3
+ ;;
+ stop)
+ ;;
+ *)
+ echo "Usage: $0 start|stop" >&2
+ exit 3
+ ;;
+esac
--- /dev/null
+body
+{
+ background-image:url("./realraumsimpel.png");
+ background-repeat:no-repeat;
+}
+
+#pc1
+{
+ background-color:#f00;
+}
+.pc1
+{
+ position:absolute;
+ height:122px;
+ width:122px;
+ top:370px;
+ left:697px;
+ background-color:#f00;
+ z-index:20;
+}
+.pc2
+{
+ position:absolute;
+ height:122px;
+ width:122px;
+ top:142px;
+ left:697px;
+ background-color:#f00;
+ z-index:20;
+}
+.pc3
+{
+ position:absolute;
+ height:122px;
+ width:122px;
+ top:370px;
+ left:402px;
+ background-color:#f00;
+ z-index:20;
+}
+.pc4
+{
+ position:absolute;
+ height:122px;
+ width:122px;
+ top:142px;
+ left:402px;
+ background-color:#f00;
+ z-index:20;
+}
+.pc5
+{
+ position:absolute;
+ height:122px;
+ width:122px;
+ top:370px;
+ left:127px;
+ background-color:#f00;
+ z-index:20;
+}
+.pc6
+{
+ position:absolute;
+ height:122px;
+ width:122px;
+ top:142px;
+ left:127px;
+ background-color:#f00;
+ z-index:20;
+}
--- /dev/null
+body
+{
+ background-image:url("./realraumsimpelz.png");
+ background-repeat:no-repeat;
+}
+
+#pc1
+{
+ background-color:#f00;
+}
+.pc1
+{
+ position:absolute;
+ height:122px;
+ width:122px;
+ top:370px;
+ left:697px;
+ background-color:#f00;
+ z-index:20;
+}
+.pc2
+{
+ position:absolute;
+ height:122px;
+ width:122px;
+ top:142px;
+ left:697px;
+ background-color:#f00;
+ z-index:20;
+}
+.pc3
+{
+ position:absolute;
+ height:122px;
+ width:122px;
+ top:370px;
+ left:402px;
+ background-color:#f00;
+ z-index:20;
+}
+.pc4
+{
+ position:absolute;
+ height:122px;
+ width:122px;
+ top:142px;
+ left:402px;
+ background-color:#f00;
+ z-index:20;
+}
+.pc5
+{
+ position:absolute;
+ height:122px;
+ width:122px;
+ top:370px;
+ left:127px;
+ background-color:#f00;
+ z-index:20;
+}
+.pc6
+{
+ position:absolute;
+ height:122px;
+ width:122px;
+ top:142px;
+ left:127px;
+ background-color:#f00;
+ z-index:20;
+}
#Pattern1
echo "<div class=\"switchbox\">"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"4=0&23=0&18=1&17=1&22=0&21=0\");'>[ | ]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"4=1&23=1&18=0&17=0&22=1&21=1\");'>[| |]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"4=1&23=1&18=0&17=0&22=0&21=1\");'>[| .]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"4=0&23=1&18=0&17=1&22=0&21=1\");'>[***]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"4=1&23=0&18=0&17=0&22=0&21=1\");'>[. *]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"4=0&23=1&18=0&17=0&22=1&21=0\");'>[* .]</button>"
+echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=0&ceiling2=0&ceiling3=1&ceiling4=1&ceiling5=0&ceiling6=0\");'>[ | ]</button>"
+echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=1&ceiling2=1&ceiling3=0&ceiling4=0&ceiling5=1&ceiling6=1\");'>[| |]</button>"
+echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=1&ceiling2=0&ceiling3=0&ceiling4=0&ceiling5=1&ceiling6=1\");'>[| .]</button>"
+echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=0&ceiling2=1&ceiling3=0&ceiling4=1&ceiling5=0&ceiling6=1\");'>[***]</button>"
+echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=1&ceiling2=0&ceiling3=0&ceiling4=0&ceiling5=0&ceiling6=1\");'>[* .]</button>"
+echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=0&ceiling2=0&ceiling3=0&ceiling4=0&ceiling5=1&ceiling6=1\");'>[| ]</button>"
echo "</div>"
if [ "$NOFLOAT" = "1" ]; then
--- /dev/null
+<html>
+<head>
+<meta http-equiv="refresh" content="0; URL=http://licht.realraum.at/cgi-bin/switch.cgi?nofloat=1">
+</head>
+</html>