Version 1.2

This commit is contained in:
Landei 2015-03-30 14:25:13 +02:00
parent e8c0a8d6f8
commit 4d0a2a27f3
25 changed files with 523 additions and 0 deletions

24
changelog.txt Normal file
View file

@ -0,0 +1,24 @@
---------------------------
PiSwitch - Changelog
---------------------------
V 1.2
- Bezeichnung frei wälbar
- Lichterkette hinzugefügt
---------------------------
V 1.1
- Genauigkeit verbessert
- Footer angepasst
- Parameter hinzugefügt
---------------------------
V 1.0
- erste Version
- Footer hinzugefügt
- Buttons formatiert
- Layout optimiert
---------------------------

9
config.php Normal file
View file

@ -0,0 +1,9 @@
<?php
header("Content-Type: text/html; charset=UTF-8");
/* Konfiguration */
$code = "01001"; //Code der DIP-Schalter der Steckdosen
$path = "/home/pi/rcswitch-pi"; //Pfad zu rcswitch (Standart: /home/pi/rcswitch-pi; muss evtl. geaendert werden)
?>

BIN
images/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
images/pi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
images/switch_off.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
images/switch_on.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

129
index.php Normal file
View file

@ -0,0 +1,129 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>PiSwitch</title>
<link href="style.css" media="screen" type="text/css" rel="stylesheet">
<link rel="shotcut icon" type="image/x-icon" href="images/fav00icon.ico">
<?php
$start = microtime(true);
?>
</head>
<?php
header("Content-Type: text/html; charset=UTF-8");
header("Expires: Mon, 1 Jan 2000 07:00:00 GMT");
header("Cache-Control: no-cache, no-store, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
include 'status.php';
include 'param.php';
include 'name.php';
?>
<body>
<h1>PiSwitch - Interface
<a href="http://raspberrypi.org" target="_blank"><img src="images/pi.png" width="33" height="40"></a>
</h1>
<p>
<form method="post" action="switch.php">
<input type="submit" name="sent11" value="<?php echo $name1; ?> an" class="switchon">
<form method="post" action="switch.php">
<input type="submit" name="sent10" value="<?php echo $name1; ?> aus" class="switchoff">
</form>
</p>
<p>
<form method="post" action="switch.php">
<input type="submit" name="sent21" value="<?php echo $name2; ?> an" class="switchon">
<form method="post" action="switch.php">
<input type="submit" name="sent20" value="<?php echo $name2; ?> aus" class="switchoff">
</form>
</p>
<p>
<form method="post" action="switch.php">
<input type="submit" name="sent31" value="<?php echo $name3; ?> an" class="switchon">
<form method="post" action="switch.php">
<input type="submit" name="sent30" value="<?php echo $name3; ?> aus" class="switchoff">
</p>
<p>
<form method="post" action="switch.php">
<input type="submit" name="kette1" value="<?php echo $name4; ?> an" class="switchon">
<form method="post" action="switch.php">
<input type="submit" name="kette0" value="<?php echo $name4; ?> aus" class="switchoff">
</p>
</form>
<div class="status">
<table border="1">
<tr>
<th>Bezeichnung</th>
<th>Status</th>
</tr>
<tr>
<td><?php echo $name1; ?></td>
<td><?php echo $s1; ?></td>
</tr>
<tr>
<td><?php echo $name2; ?></td>
<td><?php echo $s2; ?></td>
</tr>
<tr>
<td><?php echo $name3; ?></td>
<td><?php echo $s3; ?></td>
</tr>
<tr>
<td><?php echo $name4; ?></td>
<td><?php echo $s4; ?></td>
</tr>
</table>
</div>
<!---
<input type="radio" name="steckdose" value="steckdose01">Steckdose 1<br></br></input>
<input type="radio" name="steckdose" value="steckdose02">Steckdose 2<br></br></input>
<input type="radio" name="steckdose" value="steckdose03">Steckdose 3<br></br></input>
<script type="text/javascript">
JotForm.init(function(){
$('input_5').spinner({ imgPath:'http://d2g9qbzl5h49rh.cloudfront.net/images/', width: '60', maxValue:'59', minValue:'0', allowNegative: false, addAmount: 1, value:'0' });
$('input_4').spinner({ imgPath:'http://d2g9qbzl5h49rh.cloudfront.net/images/', width: '60', maxValue:'23', minValue:'0', allowNegative: false, addAmount: 1, value:'0' });
$('input_6').spinner({ imgPath:'http://d2g9qbzl5h49rh.cloudfront.net/images/', width: '60', maxValue:'59', minValue:'0', allowNegative: false, addAmount: 1, value:'0' });
$('input_7').spinner({ imgPath:'http://d2g9qbzl5h49rh.cloudfront.net/images/', width: '60', maxValue:'7', minValue:'1', allowNegative: false, addAmount: 1, value:'0' });
$('input_8').spinner({ imgPath:'http://d2g9qbzl5h49rh.cloudfront.net/images/', width: '60', maxValue:'12', minValue:'1', allowNegative: false, addAmount: 1, value:'0' });
JotForm.alterTexts({"required":"Dies ist ein Pflichtfeld.","requireOne":"Mindestens ein Feld ist erforderlich.","requireEveryRow":"Jede Zeile benötigt.","requireEveryCell":"Jede Zelle ist erforderlich.","alphabetic":"Dieses Feld darf nur Buchstaben enthalten","cyrillic":"Dieses Feld kann nur kyrillische Zeichen enthalten","numeric":"Dieses Feld darf nur numerische Werte enthalten","alphanumeric":"Dieses Feld darf nur Buchstaben und Zahlen enthalten.","currency":"Diese Feld darf nur Währungswerte enthalten.","fillMask":"Der Feldwert muss die Maske ausfüllen","incompleteFields":"Es gibt unvollständige Pflichtfelder. Bitte füllen Sie diese aus. ","uploadFilesize":"Die Dateigröße kann nicht größer sein als:","uploadFilesizemin":"Die Dateigröße darf nicht tiefer sein als:","confirmClearForm":"Sind Sie sicher, dass Sie das Formular leeren wollen?","lessThan":"Ihre Bewertung sollte geringer als oder gleich sein wie","email":"Geben Sie eine gültige E-Mail Adresse ein","uploadExtensions":"Sie k&ouml;nnen nur folgende Dateien hochladen:","pleaseWait":"Bitte warten Sie...","confirmEmail":"email ist nicht korrekt","submissionLimit":"Es tut uns leid. Es ist nur ein Eintrag erlaubt. Mehrfacheinträge sind in diesem Formular deaktiviert.","gradingScoreError":"Gesamtbewertung sollte nur weniger als oder gleich sein zu","inputCarretErrorA":"Die Eingabe sollte nicht kleiner sein als der Minimalwert:","inputCarretErrorB":"Ihre Eingabe sollte den vorgegebenen Maximalwert nicht übersteigen:","maxDigitsError":"Die maximal erlaubten Ziffern sind","minSelectionsError":"Die mindestgeforderte Anzahl an Selektionen ist","maxSelectionsError":"Die Maximalauswahl an erlaubten Selektionen ist","pastDatesDisallowed":"Datum darf nicht in der Vergangenheit liegen.","multipleFileUploads_typeError":"{file} hat einen ungültigen Erweiterung. Nur {extensions} sind erlaubt.","multipleFileUploads_sizeError":"{file} ist zu groß, die maximale Dateigröße ist {sizeLimit}.","multipleFileUploads_minSizeError":"{file} ist zu klein, minimale Dateigröße ist {minSizeLimit}.","multipleFileUploads_emptyError":"{file} ist leer, bitte wählen Sie wieder Dateien ohne es.","multipleFileUploads_onLeave":"Die Dateien werden gerade hochgeladen. Wenn Sie die Seite jetzt verlassen, wird der Upload abgebrochen.","multipleFileUploads_fileLimitError":"Nur {fileLimit} Dateiuploads sind erlaub!","generalError":"In Ihrem Formular sind Fehler. Bitte beheben Sie diese bevor Sie fortfahren.","generalPageError":"Es existieren Fehler auf dieser Seite. Bitte beseitigen Sie sie bevor Sie fortfahren.","wordLimitError":"Too many words. The limit is","characterLimitError":"Too many Characters. The limit is"});
});
</script>
--->
<div id="footer_container">
<div id="footer">
<div>Version: 1.2 &#xa9 2015 <a href="http://twitter.com/landei00" target="_blank">Landei00</a></div>
<div>Fehler gefunden oder Fragen? <a href="mailto:piswitch@landei.pfweb.eu">piswitch@landei.pfweb.eu</div></a>
<div>-Raspberry Pi is a trademark of the Raspberry Pi Foundation-</div>
</div>
</div>
<p>
<?php
$end = microtime(true);
$zeit = $end - $start;
echo "Zeit: ".$zeit."sek.!";
?>
</p>
</body>
</html>

10
name.php Normal file
View file

@ -0,0 +1,10 @@
<?php
header("Content-Type: text/html; charset=UTF-8");
$name1 = 'Schreibtischlampe';
$name2 = 'Lüfter';
$name3 = 'Luefter 2';
$name4 = 'Kette 1';
?>

52
param.php Normal file
View file

@ -0,0 +1,52 @@
<?php
/* Prueft die evtl. uebergebenen Parameter */
include 'config.php';
header("Content-Type: text/html; charset=UTF-8");
if(isset($_GET["sent11"])){
shell_exec('sudo '.$path.'/./send '.$code.' 1 1');
shell_exec('sudo '.$path.'/./send '.$code.' 1 1');
shell_exec('sudo script/11.sh');
}
if(isset($_GET["sent10"])){
shell_exec('sudo '.$path.'/./send '.$code.' 1 0');
shell_exec('sudo '.$path.'/./send '.$code.' 1 0');
shell_exec('sudo script/10.sh');
}
if(isset($_GET["sent21"])){
shell_exec('sudo '.$path.'/./send '.$code.' 2 1');
shell_exec('sudo '.$path.'/./send '.$code.' 2 1');
shell_exec('sudo script/21.sh');
}
if(isset($_GET["sent20"])){
shell_exec('sudo '.$path.'/./send '.$code.' 2 0');
shell_exec('sudo '.$path.'/./send '.$code.' 2 0');
shell_exec('sudo script/20.sh');
}
if(isset($_GET["sent31"])){
shell_exec('sudo '.$path.'/./send '.$code.' 3 1');
shell_exec('sudo '.$path.'/./send '.$code.' 3 1');
shell_exec('sudo script/31.sh');
}
if(isset($_GET["sent30"])){
shell_exec('sudo '.$path.'/./send '.$code.' 3 0');
shell_exec('sudo '.$path.'/./send '.$code.' 3 0');
shell_exec('sudo script/30.sh');
}
if(isset($_GET["kette1"])){
shell_exec('sudo script/kette1.sh');
}
if(isset($_GET["kette0"])){
shell_exec('sudo script/kette0.sh');
}
?>

5
script/10.sh Normal file
View file

@ -0,0 +1,5 @@
#!/bin/bash
sudo rm status/status_01;
sudo touch status/status_01;
sudo echo "0" >> status/status_01;

5
script/11.sh Normal file
View file

@ -0,0 +1,5 @@
#!/bin/bash
sudo rm status/status_01;
sudo touch status/status_01;
sudo echo "1" >> status/status_01;

5
script/20.sh Normal file
View file

@ -0,0 +1,5 @@
#!/bin/bash
sudo rm status/status_02;
sudo touch status/status_02;
sudo echo "0" >> status/status_02;

5
script/21.sh Normal file
View file

@ -0,0 +1,5 @@
#!/bin/bash
sudo rm status/status_02;
sudo touch status/status_02;
sudo echo "1" >> status/status_02;

5
script/30.sh Normal file
View file

@ -0,0 +1,5 @@
#!/bin/bash
sudo rm status/status_03;
sudo touch status/status_03;
sudo echo "0" >> status/status_03;

5
script/31.sh Normal file
View file

@ -0,0 +1,5 @@
#!/bin/bash
sudo rm status/status_03;
sudo touch status/status_03;
sudo echo "1" >> status/status_03;

33
script/buttons.py Normal file
View file

@ -0,0 +1,33 @@
import RPi.GPIO as GPIO
import time
import os
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(14,GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.setup(15,GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.setup(18,GPIO.IN,pull_up_down=GPIO.PUD_UP)
while True:
input_state1 = GPIO.input(14)
input_state2 = GPIO.input(15)
input_state3 = GPIO.input(18)
if input_state1 == False:
print('Button 1, Steckdose 1 an')
time.sleep(1.5)
os.system("sh 11.sh")
if input_state2 == False:
print('Button 2, Steckdose 2 an')
os.system("sh 21.sh")
time.sleep(1.5)
if input_state3 == False:
print('Button 3, Steckdose 3 an')
os.system("sh 31.sh")
time.sleep(1.5)
#s01 = open("status_01.txt", "r")
#s01.close
#print s01

12
script/kette0.sh Normal file
View file

@ -0,0 +1,12 @@
#!/bin/bash
pin="8"
echo $pin > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio$pin/direction
echo "0" > /sys/class/gpio/gpio$pin/value
sudo rm status/status_04;
sudo touch status/status_04;
sudo echo "0" >> status/status_04;

12
script/kette1.sh Normal file
View file

@ -0,0 +1,12 @@
#!/bin/bash
pin="8"
echo $pin > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio$pin/direction
echo "1" > /sys/class/gpio/gpio$pin/value
sudo rm status/status_04;
sudo touch status/status_04;
sudo echo "1" >> status/status_04;

6
status.php Normal file
View file

@ -0,0 +1,6 @@
<?php
$s1 = file_get_contents('./status/status_01', FILE_USE_INCLUDE_PATH);
$s2 = file_get_contents('./status/status_02', FILE_USE_INCLUDE_PATH);
$s3 = file_get_contents('./status/status_03', FILE_USE_INCLUDE_PATH);
$s4 = file_get_contents('./status/status_04', FILE_USE_INCLUDE_PATH);
?>

1
status/status_01 Normal file
View file

@ -0,0 +1 @@
0

1
status/status_02 Normal file
View file

@ -0,0 +1 @@
0

1
status/status_03 Normal file
View file

@ -0,0 +1 @@
0

1
status/status_04 Normal file
View file

@ -0,0 +1 @@
0

128
style.css Normal file
View file

@ -0,0 +1,128 @@
body {
background:linear-gradient(45deg ,white, #A4C67D) no-repeat center center fixed;
margin-left:100px;
margin-right: 100px;
}
h1 {
font-size:250%;
font-family:Helvetica;
border-bottom:solid thin black;
}
div.status {
margin-top:50px;
}
td {
text-align: center;
font-family:Helvetica;
}
th {
text-align: center;
font-family:Helvetica;
font-size: 13px;
font-weight:900;
}
tbody tr:hover {
background: lightgreen;
color: white;
}
.switchoff{
-moz-box-shadow:inset 0px 1px 0px 0px #f7c5c0;
-webkit-box-shadow:inset 0px 1px 0px 0px #f7c5c0;
box-shadow:inset 0px 1px 0px 0px #f7c5c0;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #fc8d83), color-stop(1, #e4685d));
background:-moz-linear-gradient(top, #fc8d83 5%, #e4685d 100%);
background:-webkit-linear-gradient(top, #fc8d83 5%, #e4685d 100%);
background:-o-linear-gradient(top, #fc8d83 5%, #e4685d 100%);
background:-ms-linear-gradient(top, #fc8d83 5%, #e4685d 100%);
background:linear-gradient(to bottom, #fc8d83 5%, #e4685d 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fc8d83', endColorstr='#e4685d',GradientType=0);
background-color:#fc8d83;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #d83526;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Helvetica;
font-size:15px;
font-weight:bold;
padding:6px 24px;
text-decoration:none;
text-shadow:0px 1px 0px #b23e35;
}
.switchoff:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e4685d), color-stop(1, #fc8d83));
background:-moz-linear-gradient(top, #e4685d 5%, #fc8d83 100%);
background:-webkit-linear-gradient(top, #e4685d 5%, #fc8d83 100%);
background:-o-linear-gradient(top, #e4685d 5%, #fc8d83 100%);
background:-ms-linear-gradient(top, #e4685d 5%, #fc8d83 100%);
background:linear-gradient(to bottom, #e4685d 5%, #fc8d83 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e4685d', endColorstr='#fc8d83',GradientType=0);
background-color:#e4685d;
}
.switchoff:active {
position:relative;
top:1px;
}
.switchon{
-moz-box-shadow:inset 0px 1px 0px 0px #d9fbbe;
-webkit-box-shadow:inset 0px 1px 0px 0px #d9fbbe;
box-shadow:inset 0px 1px 0px 0px #d9fbbe;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #b8e356), color-stop(1, #a5cc52));
background:-moz-linear-gradient(top, #b8e356 5%, #a5cc52 100%);
background:-webkit-linear-gradient(top, #b8e356 5%, #a5cc52 100%);
background:-o-linear-gradient(top, #b8e356 5%, #a5cc52 100%);
background:-ms-linear-gradient(top, #b8e356 5%, #a5cc52 100%);
background:linear-gradient(to bottom, #b8e356 5%, #a5cc52 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#b8e356', endColorstr='#a5cc52',GradientType=0);
background-color:#b8e356;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #83c41a;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Helvetica;
font-size:15px;
font-weight:bold;
padding:6px 24px;
text-decoration:none;
text-shadow:0px 1px 0px #86ae47;
}
.switchon:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #a5cc52), color-stop(1, #b8e356));
background:-moz-linear-gradient(top, #a5cc52 5%, #b8e356 100%);
background:-webkit-linear-gradient(top, #a5cc52 5%, #b8e356 100%);
background:-o-linear-gradient(top, #a5cc52 5%, #b8e356 100%);
background:-ms-linear-gradient(top, #a5cc52 5%, #b8e356 100%);
background:linear-gradient(to bottom, #a5cc52 5%, #b8e356 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#a5cc52', endColorstr='#b8e356',GradientType=0);
background-color:#a5cc52;
}
.switchon:active {
position:relative;
top:1px;
}
#footer {
position:absolute;
bottom: 0;
width: 100%;
background-color: #CFCFCF;
height: 4em;
text-align: center;
left:0; right:0; bottom:0;
font-family: Helvetica;
font-size: 11px;
}

74
switch.php Normal file
View file

@ -0,0 +1,74 @@
<?php
/*
Ueberpruefung der gewaehlten Steckdose
und anschliessendes Senden des entsprechenden
Befehles (Hier NICHTS veraendern!)
*/
include 'config.php';
include 'name.php';
header("Content-Type: text/html; charset=UTF-8");
if(isset($_POST['sent11'])){
shell_exec('sudo '.$path.'/./send '.$code.' 1 1');
shell_exec('sudo '.$path.'/./send '.$code.' 1 1');
shell_exec('sudo script/11.sh');
echo "<script type='text/javascript'>alert('$name1 angeschalten');</script>";
echo "<script type='text/javascript'>window.location.href='index.php';</script>";
}
if(isset($_POST['sent10'])){
shell_exec('sudo '.$path.'/./send '.$code.' 1 0');
shell_exec('sudo '.$path.'/./send '.$code.' 1 0');
shell_exec('sudo script/10.sh');
echo "<script type='text/javascript'>alert('$name1 ausgeschalten');</script>";
echo "<script type='text/javascript'>window.location.href='index.php';</script>";
}
if(isset($_POST['sent21'])){
shell_exec('sudo '.$path.'/./send '.$code.' 2 1');
shell_exec('sudo '.$path.'/./send '.$code.' 2 1');
shell_exec('sudo script/21.sh');
echo "<script type='text/javascript'>alert('$name2 angeschalten');</script>";
echo "<script type='text/javascript'>window.location.href='index.php';</script>";
}
if(isset($_POST['sent20'])){
shell_exec('sudo '.$path.'/./send '.$code.' 2 0');
shell_exec('sudo '.$path.'/./send '.$code.' 2 0');
shell_exec('sudo script/20.sh');
echo "<script type='text/javascript'>alert('$name2 ausgeschalten');</script>";
echo "<script type='text/javascript'>window.location.href='index.php';</script>";
}
if(isset($_POST['sent31'])){
shell_exec('sudo '.$path.'/./send '.$code.' 3 1');
shell_exec('sudo '.$path.'/./send '.$code.' 3 1');
shell_exec('sudo script/31.sh');
echo "<script type='text/javascript'>alert('$name3 angeschalten');</script>";
echo "<script type='text/javascript'>window.location.href='index.php';</script>";
}
if(isset($_POST['sent30'])){
shell_exec('sudo '.$path.'/./send '.$code.' 3 0');
shell_exec('sudo '.$path.'/./send '.$code.' 3 0');
shell_exec('sudo script/30.sh');
echo "<script type='text/javascript'>alert('$name3 ausgeschalten');</script>";
echo "<script type='text/javascript'>window.location.href='index.php';</script>";
}
if(isset($_POST['kette1'])){
shell_exec('sudo script/kette1.sh');
echo "<script type='text/javascript'>alert('$name4 angeschalten');</script>";
echo "<script type='text/javascript'>window.location.href='index.php';</script>";
}
if(isset($_POST['kette0'])){
shell_exec('sudo script/kette0.sh');
echo "<script type='text/javascript'>alert('$name4 ausgeschalten');</script>";
echo "<script type='text/javascript'>window.location.href='index.php';</script>";
}
?>