This commit is contained in:
2024-10-14 00:08:40 +02:00
parent dbfba56f66
commit 1462d52e13
4572 changed files with 2658864 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?php
require "func.php";
require "config.php";
if (isset($_GET["action"])) {
# Status lesen
if ($_GET["action"] === "getstatus") {
$state = load('state.php');
for ($i=0; $i<$switches; $i++) {
$j=$i+1;
echo "$j:'$state[$i]';";
}
}
# Last state change lesen
if ($_GET["action"] === "getchanged") {
if (file_exists("changed")) {
echo "changed";
} else {
echo "unchanged";
}
unlink ("changed");
}
if ($_GET["action"] === "setstatus") {
$a=['', '', '', '', '', ''];
for ($i=0; $i < $switches; $i++) {
$j=$i+1;
if ($_GET["oos$j"] === "on") {
$a[$i]="checked";
}
}
save("state.php", $a);
}
}

View File

@@ -0,0 +1,2 @@
<?php
return '1';

View File

@@ -0,0 +1,2 @@
<?php
$switches=6;

View File

@@ -0,0 +1,13 @@
<?php
function load($path)
{
return require $path;
}
function save($path, $array)
{
$content = '<?php' . PHP_EOL . 'return ' . var_export($array, true) . ';';
return is_numeric(file_put_contents($path, $content));
}

View File

@@ -0,0 +1,160 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>power.andregeissler.de</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta http-equiv="refresh" content="30">
<link rel="shortcut icon" href="images/favicon.ico">
<style type="text/css">
/* <![CDATA[ */
.onoffswitch {
position: relative; width: 100px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
border: 2px solid #999999; border-radius: 20px;
}
.onoffswitch-inner {
display: block; width: 200%; margin-left: -100%;
-moz-transition: margin 0.3s ease-in 0s; -webkit-transition: margin 0.3s ease-in 0s;
-o-transition: margin 0.3s ease-in 0s; transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
display: block; float: left; width: 50%; height: 35px; padding: 0; line-height: 35px;
font-size: 15px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}
.onoffswitch-inner:before {
content: "AN";
padding-left: 10px;
background-color: #00FF00; color: #000000;
}
.onoffswitch-inner:after {
content: "AUS";
padding-right: 10px;
background-color: #FF0000; color: #000000;
text-align: right;
}
.onoffswitch-switch {
display: block; width: 20px; margin: 7.5px;
background: #FFFFFF;
border: 2px solid #999999; border-radius: 20px;
position: absolute; top: 0; bottom: 0; right: 61px;
-moz-transition: all 0.3s ease-in 0s; -webkit-transition: all 0.3s ease-in 0s;
-o-transition: all 0.3s ease-in 0s; transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
input[type=submit] {padding:5px 10px; background:#ccc; none;
cursor:pointer;
-webkit-border-radius: 5px;
border: 2px solid #999999;
border-radius: 20px;
height: 35px;
width: 100px;
}
/* ]]> */
</style>
</head>
<body>
<?php
require "config.php";
require "func.php";
if (isset($_GET[device])) {
$name=$_GET[device];
}
if($_POST["save"] === "yes") {
$a=['', '', '', '', '', ''];
for ($i=0; $i < $switches; $i++) {
$j=$i+1;
if ($_POST["oos$j"] === "on") {
$a[$i]="checked";
}
}
for ($i=0; $i < $switches; $i++) {
$l[]=$_POST["ool$i"];
}
save("label.php", $l);
save("state.php", $a);
save("changed", "1");
file_put_contents("timer", $_POST['timerareacontent']);
}
$state = load("state.php");
$label = load("label.php");
$timerfilecontent = file_get_contents("timer");
?>
<form action="index.php?device=<?php echo $name ?>" method="post">
<table border="0" width="300px">
<tr>
<td colspan="3">
<?php print "<b>$name</b>"; ?>
</td>
</tr>
<tr>
<td>Port</td>
<td>Beschreibung</td>
<td align="center">Zustand</td>
</tr>
<?php
for ($i = 0; $i < $switches; $i++) {
$j=$i+1;
echo "
<tr>
<td>
$j
</td>
<td>
<input type='text' size='15' name='ool$i' value='$label[$i]'>
</td>
<td align='center'>
<div class='onoffswitch'>
<input type='checkbox' name='oos$j' class='onoffswitch-checkbox' id='myonoffswitch$j' $state[$i]>
<label class='onoffswitch-label' for='myonoffswitch$j'>
<span class='onoffswitch-inner'></span>
<span class='onoffswitch-switch'></span>
</label>
</div>
</td>
</tr>
";
}
?>
<tr>
<td></td><td></td>
<td align="center">
<input type="submit" value="Speichern"/>
<input type="hidden" name="device" value="<?php echo $name ?>">
<input type="hidden" name="save" value="yes">
</td>
</tr>
<tr>
<td colspan="3">
<textarea name="timerareacontent" cols="45" rows="29">
<?php echo "$timerfilecontent"; ?>
</textarea>
</td>
</tr>
</table>
</form>
<form action="/index.php" method="post" target="_top">
<input type="hidden" name="delete" value="yes">
<input type="hidden" name="path" value="<?php echo dirname(__FILE__)?>">
<input type="submit" value="Entfernen"/>
</form>
</body>
</html>

View File

@@ -0,0 +1,9 @@
<?php
return array (
0 => 'USB Loader (always on)',
1 => 'Tools',
2 => 'Light',
3 => 'Dryer',
4 => 'Temperature',
5 => 'Power cycle at 00:01',
);

View File

@@ -0,0 +1,9 @@
<?php
return array (
0 => 'checked',
1 => '',
2 => 'checked',
3 => 'checked',
4 => 'checked',
5 => '',
);

View File

@@ -0,0 +1,55 @@
###START
# Ausgang,on|off,hh:mm|always
# bsp
# 6,off,00:00
# 6,on,00:01
# 1,on,always
# usb (1)
1,on,always
# Werkzeuge (2)
# licht (3)
# Trockner (4)
4,off,02:00
# Temperatur (5)
5,on,always
# Port ohne Gerät, Nachts für eine Minute abschalten (6)
6,off,00:00
6,on,00:01
# auto on/off Frühschicht
#3,on,05:00
#4,on,05:00
#3,off,05:30
#4,off,05:30
#3,on,15:30
#4,on,15:30
#3,off,16:30
#4,off,16:30
# auto on/off Mittelschicht
3,on,07:25
4,on,07:25
3,off,07:40
4,off,07:40
3,on,17:40
4,on,17:40
3,off,18:20
4,off,18:20
# auto on/off Spätschicht
#3,on,11:00
#4,on,11:00
#3,off,11:30
#4,off,11:30
#3,on,21:40
#4,on,21:40
#3,off,22:20
#4,off,22:20
###ENDE

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@@ -0,0 +1,87 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>power.andregeissler.de</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="shortcut icon" href="images/favicon.ico">
<style type="text/css">
/* <![CDATA[ */
<!--
ul#navigation {
margin: 0px;
padding: 0px;
list-style-type: none;
}
ul#navigation li {
padding: 0px;
margin: 0px;
display: inline;
}
ul#navigation li a:link {
border: 1px solid #000;
background-color: #CCCCCC;
padding: 2px 5px 2px 5px;
font-size: 12px;
color: #000;
font-family: Arial, Helvetica, sans-serif;
text-decoration: none;
font-weight: bold;
}
ul#navigation li a:visited {
border: 1px solid #000;
background-color: #CCCCCC;
padding: 2px 5px 2px 5px;
font-size: 12px;
color: #000;
font-family: Arial, Helvetica, sans-serif;
text-decoration: none;
font-weight: bold;
}
ul#navigation li a:hover {
border: 1px solid #000;
background-color: #333333;
padding: 2px 5px 2px 5px;
color: #fff;
}
font#act {
color: #0a0;
}
ul#content li {
margin-top: 20px;
}
body {
width: 770px;
}
-->
</style>
</head>
<body>
<ul id="navigation">
<li><a href="index.php">Ger&auml;teliste</a></li>
<li><a href="add.php"><font id="act">Hinzuf&uuml;gen</font></a></li>
<li><a href="deviceview.php">Ger&auml;teansicht</a></li>
</ul>
<br>
<form action="index.php" target="_top" method="post">
NAME <input type="text" name="name" value="name"><br>
PORTS <select name=port>
<option value="1">1</option>
<option value="3">3</option>
<option value="6">6</option>
</select>
<input type="hidden" name="add" value="yes">
<input type="submit" value="Anlegen"/>
</form>
</body>
</html>

View File

@@ -0,0 +1,9 @@
<?php
$dirs = array_filter(glob('*'), 'is_dir');
foreach ($dirs as $dir) {
if ($dir === "template") { continue; }
if ($dir === "images") { continue; }
print "<a href='$dir/index.php?device=$dir' target='iframe'><font size=+1>$dir</font></a><br>\n";
}
?>

View File

@@ -0,0 +1,83 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>power.andregeissler.de</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="shortcut icon" href="images/favicon.ico">
<style type="text/css">
/* <![CDATA[ */
<!--
ul#navigation {
margin: 0px;
padding: 0px;
list-style-type: none;
}
ul#navigation li {
padding: 0px;
margin: 0px;
display: inline;
}
ul#navigation li a:link {
border: 1px solid #000;
background-color: #CCCCCC;
padding: 2px 5px 2px 5px;
font-size: 12px;
color: #000;
font-family: Arial, Helvetica, sans-serif;
text-decoration: none;
font-weight: bold;
}
ul#navigation li a:visited {
border: 1px solid #000;
background-color: #CCCCCC;
padding: 2px 5px 2px 5px;
font-size: 12px;
color: #000;
font-family: Arial, Helvetica, sans-serif;
text-decoration: none;
font-weight: bold;
}
ul#navigation li a:hover {
border: 1px solid #000;
background-color: #333333;
padding: 2px 5px 2px 5px;
color: #fff;
}
font#act {
color: #0a0;
}
ul#content li {
margin-top: 20px;
}
body {
width: 770px;
}
-->
</style>
</head>
<body>
<ul id="navigation">
<li><a href="index.php">Ger&auml;teliste</a></li>
<li><a href="add.php">Hinzuf&uuml;gen</a></li>
<li><a href="deviceview.php"><font id="act">Ger&auml;teansicht</font></a></li>
</ul>
<br>
<h3>mPower Pro (EU)</h3>
<img width="150px" src="ubnt_mpowerpro_main.jpg">
<h3>mPower Main (EU)</h3>
<img width="150px" src="UBNT_mPower_main.jpg">
<h3>mPower mini (EU)</h3>
<img width="150px" src="UBNT_mPowerMini_main.jpg">
</body>
</html>

View File

@@ -0,0 +1,102 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>power.andregeissler.de</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="shortcut icon" href="images/favicon.ico">
<style type="text/css">
/* <![CDATA[ */
<!--
ul#navigation {
margin: 0px;
padding: 0px;
list-style-type: none;
}
ul#navigation li {
padding: 0px;
margin: 0px;
display: inline;
}
ul#navigation li a:link {
border: 1px solid #000;
background-color: #CCCCCC;
padding: 2px 5px 2px 5px;
font-size: 12px;
color: #000;
font-family: Arial, Helvetica, sans-serif;
text-decoration: none;
font-weight: bold;
}
ul#navigation li a:visited {
border: 1px solid #000;
background-color: #CCCCCC;
padding: 2px 5px 2px 5px;
font-size: 12px;
color: #000;
font-family: Arial, Helvetica, sans-serif;
text-decoration: none;
font-weight: bold;
}
ul#navigation li a:hover {
border: 1px solid #000;
background-color: #333333;
padding: 2px 5px 2px 5px;
color: #fff;
}
font#act {
color: #0a0;
}
ul#content li {
margin-top: 20px;
}
body {
width: 350px;
}
-->
</style>
</head>
<body>
<?php
function delTree($dir) {
$files = array_diff(scandir($dir), array('.','..'));
foreach ($files as $file) {
(is_dir("$dir/$file") && !is_link($dir)) ? delTree("$dir/$file") : unlink("$dir/$file");
}
return rmdir($dir);
}
if($_POST["delete"] === "yes") {
delTree("$_POST[path]");
}
if($_POST["add"] === "yes") {
mkdir($_POST["name"]);
copy("template/api.php","$_POST[name]/api.php");
copy("template/label.php","$_POST[name]/label.php");
copy("template/func.php","$_POST[name]/func.php");
copy("template/state.php","$_POST[name]/state.php");
copy("template/index.php","$_POST[name]/index.php");
$myfile = fopen("$_POST[name]/config.php", "w");
fwrite($myfile, "<?php\n\$switches=$_POST[port];");
}
?>
<ul id="navigation">
<li><a href="index.php"><font id="act">Ger&auml;teliste</font></a></li>
<li><a href="add.php">Hinzuf&uuml;gen</a></li>
<li><a href="deviceview.php">Ger&auml;teansicht</a></li>
</ul>
<iframe src="devicelist.php" name="iframe" frameborder="0" width="380px" height="855px">
</iframe>
</body>
</html>

View File

@@ -0,0 +1,37 @@
<?php
require "func.php";
require "config.php";
if (isset($_GET["action"])) {
# Status lesen
if ($_GET["action"] === "getstatus") {
$state = load('state.php');
for ($i=0; $i<$switches; $i++) {
$j=$i+1;
echo "$j:'$state[$i]';";
}
}
# Last state change lesen
if ($_GET["action"] === "getchanged") {
if (file_exists("changed")) {
echo "changed";
} else {
echo "unchanged";
}
unlink ("changed");
}
if ($_GET["action"] === "setstatus") {
$a=['', '', '', '', '', ''];
for ($i=0; $i < $switches; $i++) {
$j=$i+1;
if ($_GET["oos$j"] === "on") {
$a[$i]="checked";
}
}
save("state.php", $a);
}
}

View File

@@ -0,0 +1,2 @@
<?php
$switches = 6;

View File

@@ -0,0 +1,13 @@
<?php
function load($path)
{
return require $path;
}
function save($path, $array)
{
$content = '<?php' . PHP_EOL . 'return ' . var_export($array, true) . ';';
return is_numeric(file_put_contents($path, $content));
}

View File

@@ -0,0 +1,160 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>power.andregeissler.de</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta http-equiv="refresh" content="30">
<link rel="shortcut icon" href="images/favicon.ico">
<style type="text/css">
/* <![CDATA[ */
.onoffswitch {
position: relative; width: 100px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
border: 2px solid #999999; border-radius: 20px;
}
.onoffswitch-inner {
display: block; width: 200%; margin-left: -100%;
-moz-transition: margin 0.3s ease-in 0s; -webkit-transition: margin 0.3s ease-in 0s;
-o-transition: margin 0.3s ease-in 0s; transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
display: block; float: left; width: 50%; height: 35px; padding: 0; line-height: 35px;
font-size: 15px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}
.onoffswitch-inner:before {
content: "AN";
padding-left: 10px;
background-color: #00FF00; color: #000000;
}
.onoffswitch-inner:after {
content: "AUS";
padding-right: 10px;
background-color: #FF0000; color: #000000;
text-align: right;
}
.onoffswitch-switch {
display: block; width: 20px; margin: 7.5px;
background: #FFFFFF;
border: 2px solid #999999; border-radius: 20px;
position: absolute; top: 0; bottom: 0; right: 61px;
-moz-transition: all 0.3s ease-in 0s; -webkit-transition: all 0.3s ease-in 0s;
-o-transition: all 0.3s ease-in 0s; transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
input[type=submit] {padding:5px 10px; background:#ccc; none;
cursor:pointer;
-webkit-border-radius: 5px;
border: 2px solid #999999;
border-radius: 20px;
height: 35px;
width: 100px;
}
/* ]]> */
</style>
</head>
<body>
<?php
require "config.php";
require "func.php";
if (isset($_GET[device])) {
$name=$_GET[device];
}
if($_POST["save"] === "yes") {
$a=['', '', '', '', '', ''];
for ($i=0; $i < $switches; $i++) {
$j=$i+1;
if ($_POST["oos$j"] === "on") {
$a[$i]="checked";
}
}
for ($i=0; $i < $switches; $i++) {
$l[]=$_POST["ool$i"];
}
save("label.php", $l);
save("state.php", $a);
save("changed", "1");
file_put_contents("timer", $_POST['timerareacontent']);
}
$state = load("state.php");
$label = load("label.php");
$timerfilecontent = file_get_contents("timer");
?>
<form action="index.php?device=<?php echo $name ?>" method="post">
<table border="0" width="300px">
<tr>
<td colspan="3">
<?php print "<b>$name</b>"; ?>
</td>
</tr>
<tr>
<td>Port</td>
<td>Beschreibung</td>
<td align="center">Zustand</td>
</tr>
<?php
for ($i = 0; $i < $switches; $i++) {
$j=$i+1;
echo "
<tr>
<td>
$j
</td>
<td>
<input type='text' size='15' name='ool$i' value='$label[$i]'>
</td>
<td align='center'>
<div class='onoffswitch'>
<input type='checkbox' name='oos$j' class='onoffswitch-checkbox' id='myonoffswitch$j' $state[$i]>
<label class='onoffswitch-label' for='myonoffswitch$j'>
<span class='onoffswitch-inner'></span>
<span class='onoffswitch-switch'></span>
</label>
</div>
</td>
</tr>
";
}
?>
<tr>
<td></td><td></td>
<td align="center">
<input type="submit" value="Speichern"/>
<input type="hidden" name="device" value="<?php echo $name ?>">
<input type="hidden" name="save" value="yes">
</td>
</tr>
<tr>
<td colspan="3">
<textarea name="timerareacontent" cols="45" rows="29">
<?php echo "$timerfilecontent"; ?>
</textarea>
</td>
</tr>
</table>
</form>
<form action="/index.php" method="post" target="_top">
<input type="hidden" name="delete" value="yes">
<input type="hidden" name="path" value="<?php echo dirname(__FILE__)?>">
<input type="submit" value="Entfernen"/>
</form>
</body>
</html>

View File

@@ -0,0 +1,9 @@
<?php
return array (
0 => 'Port 1',
1 => 'Port 2',
2 => 'Port 3',
3 => 'Port 4',
4 => 'Port 5',
5 => 'Port 6',
);

View File

@@ -0,0 +1,9 @@
<?php
return array (
0 => 'checked',
1 => 'checked',
2 => 'checked',
3 => 'checked',
4 => 'checked',
5 => 'checked',
);

View File

@@ -0,0 +1,55 @@
###START
# Ausgang,on|off,hh:mm|always
# bsp
# 6,off,00:00
# 6,on,00:01
# 1,on,always
# usb (1)
1,on,always
# Werkzeuge (2)
# licht (3)
# Trockner (4)
4,off,02:00
# Temperatur (5)
5,on,always
# Port ohne Gerät, Nachts für eine Minute abschalten (6)
6,off,00:00
6,on,00:01
# auto on/off Frühschicht
#3,on,05:00
#4,on,05:00
#3,off,05:30
#4,off,05:30
#3,on,15:30
#4,on,15:30
#3,off,16:30
#4,off,16:30
# auto on/off Mittelschicht
3,on,07:25
4,on,07:25
3,off,07:40
4,off,07:40
3,on,17:40
4,on,17:40
3,off,18:20
4,off,18:20
# auto on/off Spätschicht
#3,on,11:00
#4,on,11:00
#3,off,11:30
#4,off,11:30
#3,on,21:40
#4,on,21:40
#3,off,22:20
#4,off,22:20
###ENDE

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

View File

@@ -0,0 +1,95 @@
#!/usr/bin/perl
use feature "switch";
$USER="andre";
$PASS="mesh-assort2";
$HOST="power.andregeissler.de";
$DEVICE="Test";
$DEVICEIP="192.168.100.7";
$DEVICEUSER="admin";
$DEVICEPASS="admin";
$cmd="curl -s http://$USER:$PASS\@$HOST/$DEVICE/timer > /scripts/mFi/timer";
`$cmd`;
$cmd="dos2unix /scripts/mFi/timer";
`$cmd`;
open CTRL, "</scripts/mFi/timer";
@TIMER=<CTRL>;
close CTRL;
my $startfound=0;
my $endefound=0;
foreach (@TIMER) {
$startfound=1 if (/###START/);
$endefound=1 if (/###ENDE/);
}
exit if ($startfound == 0 || $endefound == 0);
@ports=();
@comms=();
$str="";
my $time=`date +"%H:%M"`;
chomp $time;
print "\ntime ($time)\n";
$cmd="curl -s http://$USER:$PASS\@$HOST/$DEVICE/api.php?action=getstatus";
print "get state via ($cmd)\n";
$result=`$cmd`;
chomp $result;
print "result ($result)\n";
next if ( $result eq "" );
@ports=split /;/, $result;
foreach $port (@ports) {
($dev, $state) = $port =~ /^([0-9]+):'(.*)'$/;
$ch="";
print "Check $dev\n";
$f=0;
foreach (@TIMER) {
chomp;
print ".";
if ($_ =~ /^$dev,off,$time$/) {
$f=1;
print "$dev off at $time\n";
$comm ="echo 0 > /dev/output$dev";
} elsif ($_ =~ /^$dev,on,$time$/) {
$f=1;
print "$dev on at $time\n";
$comm ="echo 1 > /dev/output$dev";
$ch="on";
} elsif ($_ =~ /^$dev,off,always$/) {
$f=1;
print "$dev always off\n";
$comm ="echo 0 > /dev/output$dev";
} elsif ($_ =~ /^$dev,on,always$/) {
$f=1;
print "$dev always on\n";
$comm ="echo 1 > /dev/output$dev";
$ch="on";
}
}
if ($f == 0) {
if ($state eq "checked") {
print "$dev on\n";
$comm="echo 1 > /dev/output$dev";
$ch="on";
} else {
print "$dev off\n";
$comm="echo 0 > /dev/output$dev";
}
}
$str .= "&oos$dev=$ch";
push(@comms, $comm);
}
$com=join(";", @comms);
$cmd="curl -s 'http://$USER:$PASS\@$HOST/$DEVICE/api.php?action=setstatus$str'";
print "set state via ($cmd)\n";
`$cmd`;
$cmd="expect /scripts/mFi/port.exp $DEVICEUSER $DEVICEIP $DEVICEPASS '$com'";
print "send commands to device\n";
`$cmd`;

View File

@@ -0,0 +1,18 @@
#!/bin/bash
export USER="andre"
export PASS="mesh-assort2"
export HOST="power.andregeissler.de"
export DEVICE="Test"
rm /scripts/mFi/cron
curl -s http://$USER:$PASS@$HOST/$DEVICE/timer > /scripts/mFi/cron_input
dos2unix /scripts/mFi/cron_input > /dev/null 2>&1
cat /scripts/mFi/cron_input | egrep "^ct" | awk '{print $2 " " $3 " " $4 " " $5 " " $6 " root /scripts/mFi/switch_port.sh " $7 " " $8 " >/dev/null 2>&1"}' >> /scripts/mFi/cron
rm /scripts/mFi/cron_input
#export CRON=`cat /scripts/mFi/cron`
#sed -s -i "/####mFi####.*####mFi####/####mFi\n$CRON\n####mFi####/m" /var/spool/cron/crontabs/root

View File

@@ -0,0 +1,10 @@
05 05 * * 1-5 root /scripts/mFi/switch_port.sh 3 on >/dev/null 2>&1
30 05 * * 1-5 root /scripts/mFi/switch_port.sh 3 off >/dev/null 2>&1
30 15 * * 1-5 root /scripts/mFi/switch_port.sh 3 on >/dev/null 2>&1
10 16 * * 1-5 root /scripts/mFi/switch_port.sh 3 off >/dev/null 2>&1
06 05 * * 1-5 root /scripts/mFi/switch_port.sh 4 on >/dev/null 2>&1
31 05 * * 1-5 root /scripts/mFi/switch_port.sh 4 off >/dev/null 2>&1
31 15 * * 1-5 root /scripts/mFi/switch_port.sh 4 on >/dev/null 2>&1
31 16 * * 1-5 root /scripts/mFi/switch_port.sh 4 off >/dev/null 2>&1
00 00 * * * root /scripts/mFi/switch_port.sh 6 off >/dev/null 2>&1
01 00 * * * root /scripts/mFi/switch_port.sh 6 on >/dev/null 2>&1

View File

@@ -0,0 +1,10 @@
05 05 * * 1-5 root /scripts/mFi/switch_port.sh 3 on >/dev/null 2>&1
30 05 * * 1-5 root /scripts/mFi/switch_port.sh 3 off >/dev/null 2>&1
30 15 * * 1-5 root /scripts/mFi/switch_port.sh 3 on >/dev/null 2>&1
10 16 * * 1-5 root /scripts/mFi/switch_port.sh 3 off >/dev/null 2>&1
06 05 * * 1-5 root /scripts/mFi/switch_port.sh 4 on >/dev/null 2>&1
31 05 * * 1-5 root /scripts/mFi/switch_port.sh 4 off >/dev/null 2>&1
31 15 * * 1-5 root /scripts/mFi/switch_port.sh 4 on >/dev/null 2>&1
31 16 * * 1-5 root /scripts/mFi/switch_port.sh 4 off >/dev/null 2>&1
00 00 * * * root /scripts/mFi/switch_port.sh 6 off >/dev/null 2>&1
01 00 * * * root /scripts/mFi/switch_port.sh 6 on >/dev/null 2>&1

View File

@@ -0,0 +1,8 @@
# ubiqiti mfi power steuerung
#3 * * * * /scripts/mFi/create_cron.sh > /dev/null 2>&1
#* * * * * /usr/bin/perl /scripts/mFi/control.pl > /dev/null 2>&1
#* * * * * sleep 15; /usr/bin/perl /scripts/mFi/control.pl > /dev/null 2>&1
#* * * * * sleep 30; /usr/bin/perl /scripts/mFi/control.pl > /dev/null 2>&1
#* * * * * sleep 45; /usr/bin/perl /scripts/mFi/control.pl > /dev/null 2>&1

View File

@@ -0,0 +1,16 @@
#!/usr/bin/expect -f
set timeout 10
set user [lindex $argv 0]
set host [lindex $argv 1]
set pass [lindex $argv 2]
set cmd [lindex $argv 3]
spawn ssh $user@$host -oKexAlgorithms=+diffie-hellman-group1-sha1 -caes256-cbc
expect "*?assword:*"
send -- "$pass\r"
sleep 5
send -- "$cmd\r"
sleep 2
send -- "exit\r"
expect eof

View File

@@ -0,0 +1,133 @@
#!/bin/bash
sleep 5
export USER="andre"
export PASS="mesh-assort2"
export HOST="power.andregeissler.de"
export DEVICE="Test"
export DEVICEIP="192.168.100.7"
export DEVICEUSER="admin"
export DEVICEPASS="admin"
export STATUS=`curl -s 'http://andre:mesh-assort2@power.andregeissler.de/Test/api.php?action=getstatus'`
s1=`echo $STATUS | awk -F';' '{print $1}' | grep -o checked`
s2=`echo $STATUS | awk -F';' '{print $2}' | grep -o checked`
s3=`echo $STATUS | awk -F';' '{print $3}' | grep -o checked`
s4=`echo $STATUS | awk -F';' '{print $4}' | grep -o checked`
s5=`echo $STATUS | awk -F';' '{print $5}' | grep -o checked`
s6=`echo $STATUS | awk -F';' '{print $6}' | grep -o checked`
if [ "$s1" == "checked" ]
then
s1=on
fi
if [ "$s2" == "checked" ]
then
s2=on
fi
if [ "$s3" == "checked" ]
then
s3=on
fi
if [ "$s4" == "checked" ]
then
s4=on
fi
if [ "$s5" == "checked" ]
then
s5=on
fi
if [ "$s6" == "checked" ]
then
s6=on
fi
if [ "$1" == "1" ]
then
if [ "$2" == "off" ]
then
val=""
comm="echo 0 > /dev/output1"
else
val="on"
comm="echo 1 > /dev/output1"
fi
s1=$val
fi
if [ "$1" == "2" ]
then
if [ "$2" == "off" ]
then
val=""
comm="echo 0 > /dev/output2"
else
val="on"
comm="echo 1 > /dev/output2"
fi
s2=$val
fi
if [ "$1" == "3" ]
then
if [ "$2" == "off" ]
then
val=""
comm="echo 0 > /dev/output3"
else
val="on"
comm="echo 1 > /dev/output3"
fi
s3=$val
fi
if [ "$1" == "4" ]
then
if [ "$2" == "off" ]
then
val=""
comm="echo 0 > /dev/output4"
else
val="on"
comm="echo 1 > /dev/output4"
fi
s4=$val
fi
if [ "$1" == "5" ]
then
if [ "$2" == "off" ]
then
val=""
comm="echo 0 > /dev/output5"
else
val="on"
comm="echo 1 > /dev/output5"
fi
s5=$val
fi
if [ "$1" == "6" ]
then
if [ "$2" == "off" ]
then
val=""
comm="echo 0 > /dev/output6"
else
val="on"
comm="echo 1 > /dev/output6"
fi
s6=$val
fi
str="&oos1=$s1&oos2=$s2&oos3=$s3&oos4=$s4&oos5=$s5&oos6=$s6"
export cmd="/usr/bin/curl -s 'http://andre:mesh-assort2@power.andregeissler.de/Test/api.php?action=setstatus$str'"
/bin/bash -c "$cmd"
expect /scripts/mFi/port.exp $DEVICEUSER $DEVICEIP $DEVICEPASS '$comm'

View File

@@ -0,0 +1,46 @@
###START
# Ausgang,on|off,hh:mm|always
# ct min hour dom month dow port on|off
# ct 25 07 * * 1-5 3 on
# auto on/off Frühschicht
ct 05 05 * * 1-5 3 on
ct 30 05 * * 1-5 3 off
ct 30 15 * * 1-5 3 on
ct 10 16 * * 1-5 3 off
ct 06 05 * * 1-5 4 on
ct 31 05 * * 1-5 4 off
ct 31 15 * * 1-5 4 on
ct 31 16 * * 1-5 4 off
# auto on/off Mittelschicht
#ct 25 07 * * 1-5 3 on
#ct 40 07 * * 1-5 3 off
#ct 40 17 * * 1-5 3 on
#ct 10 18 * * 1-5 3 off
#ct 26 07 * * 1-5 4 on
#ct 41 07 * * 1-5 4 off
#ct 41 17 * * 1-5 4 on
#ct 31 18 * * 1-5 4 off
# auto on/off Spätschicht
#ct 00 11 * * 1-5 3 on
#ct 30 11 * * 1-5 3 off
#ct 40 21 * * 1-5 3 on
#ct 10 22 * * 1-5 3 off
#ct 01 11 * * 1-5 4 on
#ct 31 11 * * 1-5 4 off
#ct 41 21 * * 1-5 4 on
#ct 31 22 * * 1-5 4 off
########################
1,on,always
5,on,always
ct 00 00 * * * 6 off
ct 01 00 * * * 6 on
###ENDE