Commit 28848b2f authored by Peter-Bernd Otte's avatar Peter-Bernd Otte

Merge branch 'mqtt' of gitlab.rlp.net:pbotte/compact-slowcontrol into mqtt

parents 03db006f 4b9df2de
<?php
function PrintLightStatus($fTempStr, $fTopic) {
$fTopicOrig = $fTopic;
$fTopic = str_replace("/", "-", $fTopic);
$fTopic = str_replace("$", "-", $fTopic);
$fTopic = str_replace("<", "-", $fTopic);
$fTopic = str_replace(">", "-", $fTopic);
echo " <div class=\"ui-grid-a\">";
echo " <div class=\"ui-block-a\" style=\"width=90%\">$fTempStr <span id=\"Zeit$fTopic\"></span>";
echo "</div>";
echo " <div class=\"ui-block-b\" style=\"width=10%\">";
?> <select name="slider<?php echo $fTopic?>" id="slider<?php echo $fTopic?>" data-theme="" data-role="slider">
<option value="off">Aus</option>
<option value="on">Ein</option>
</select>
<?php
echo " </div>";
echo " </div>";
echo " <script>
$('#slider$fTopic').on('slidestop', function(event, ui) {
console.log(\"switch request: ".$fTopic."\");
var NeuerZustand = 0;
if ($('#slider$fTopic').val() == \"on\") NeuerZustand = 1;
console.log('set to '+NeuerZustand);
AktualisierungFaellig = 5;
var jqxhr".abs($fTopic)." = $.get(\"http://\"+ window.location.hostname+\":8000/$fTopicOrig/set?\"+NeuerZustand, function() {
console.log(\"success: $fTopic / $fTopicOrig: \"+NeuerZustand);
AktualisierungFaellig = 5;
});
});
</script>";
}
function PrintDimLightStatus($fTempStr, $fTopic) {
$fTopicOrig = $fTopic;
$fTopic = str_replace("/", "-", $fTopic);
$fTopic = str_replace("$", "-", $fTopic);
$fTopic = str_replace("<", "-", $fTopic);
$fTopic = str_replace(">", "-", $fTopic);
echo " <div data-role=\"fieldcontain\" id=\"test$fTopic\">";
echo " <label for=\"slider$fTopic\">$fTempStr <span id=\"Zeit$fTopic\"></span></label>";
echo " <input id=\"slider$fTopic\" type=\"range\" name=\"slider$fTopic\" value=\"50\" min=\"0\" max=\"100\" ";
echo " data-highlight=\"true\">";
echo " </div>";
echo " <script>
$('#test$fTopic').on('slidestart', function(event, ui) {
AktualisierungFaellig = 5;
});
$('#test$fTopic').on('slidestop', function(event, ui) {
AktualisierungFaellig = 5;
console.log(\"dimm request: ".$fTopic."\");
var NeuerZustand = $('#slider$fTopic').val() / 100;
var jqxhr".abs($fTopic)." = $.get(\"http://\"+ window.location.hostname+\":8000/$fTopicOrig/set?\"+NeuerZustand, function() {
console.log(\"success: $fTopic / $fTopicOrig: \"+NeuerZustand);
// var jqxhr".abs($fTopic)." = $.get(\"changeStatus.php?newQ=-1&ActiveTab=&SenderID=".$fTopic."&Data=\"+$('#slider$fTopic').val(), function() {
// console.log(\"success: $fTopic ON: \"+$('#slider$fTopic').val()+\"%\");
AktualisierungFaellig = 5;
});
});
</script>";
}
function PrintWindowStatus($fTempStr, $fTopic) {
$fTopic = str_replace("/", "-", $fTopic);
$fTopic = str_replace("$", "-", $fTopic);
$fTopic = str_replace("<", "-", $fTopic);
$fTopic = str_replace(">", "-", $fTopic);
echo "<form>";
echo " <fieldset data-role=\"controlgroup\" data-type=\"horizontal\" data-mini=\"true\">";
echo " <legend>$fTempStr <span id=\"Update$fTopic\"></span> <span id=\"LastUpdate$fTopic\"></span></legend>";
echo " <input type=\"radio\" name=\"radio-$fTopic\" id=\"radio-choice-h-2a\" value=\"0\" >";
echo " <label for=\"radio-choice-h-2a\">geschlossen</label>";
echo " <input type=\"radio\" name=\"radio-$fTopic\" id=\"radio-choice-h-2b\" value=\"1\">";
echo " <label for=\"radio-choice-h-2b\">gekippt</label>";
echo " </fieldset>";
echo "</form>";
}
function PrintDoorStatus($fTempStr, $fTopic) {
$fTopic = str_replace("/", "-", $fTopic);
$fTopic = str_replace("$", "-", $fTopic);
$fTopic = str_replace("<", "-", $fTopic);
$fTopic = str_replace(">", "-", $fTopic);
echo "<form>";
echo " <fieldset data-role=\"controlgroup\" data-type=\"horizontal\" data-mini=\"true\">";
echo " <legend>$fTempStr <span id=\"Update$fTopic\"></span> <span id=\"LastUpdate$fTopic\"></span></legend>";
echo " <input type=\"radio\" name=\"radio-$fTopic\" id=\"radio-choice-h-2a\" value=\"0\" >";
echo " <label for=\"radio-choice-h-2a\">geschlossen</label>";
echo " <input type=\"radio\" name=\"radio-$fTopic\" id=\"radio-choice-h-2b\" value=\"1\">";
echo " <label for=\"radio-choice-h-2b\">gekippt</label>";
echo " <input type=\"radio\" name=\"radio-$fTopic\" id=\"radio-choice-h-2c\" value=\"2\">";
echo " <label for=\"radio-choice-h-2c\">offen</label>";
echo " </fieldset>";
echo "</form>";
}
?>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="user-scalable=no, width=device-width" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<META NAME="viewport" CONTENT="width=device-width">
<!-- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>-->
<link rel="stylesheet" href="includes/jquerymobile-1.4.2/jquery.mobile-1.4.2.min.css" />
<script src="includes/jquery-1.9.1.min.js"></script>
<script src="includes/jquerymobile-1.4.2/jquery.mobile-1.4.2.min.js"></script>
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<meta name="viewport" content="width = 300, initial-scale = 1.0">
<title>Status und mehr</title>
</head>
<body>
<script>
var AktualisierungFaellig = -1; //Wenn diese Variable <0 dann werden die Relais Werte übernommen
//To check whether a ID exists
jQuery.fn.exists = function(){return this.length>0;}
//if ($(selector).exists()) {
// // Do something
//}
</script>
<?php
function PrintPanel() {
echo ' <div data-role="panel" id="panel2" data-position="left" data-display="overlay"
data-theme="a">
<ul data-role="listview" data-divider-theme="h" data-inset="false">
<li data-theme="c"><a href="#page0" data-transition="slide">Übersicht</a></li>
<li data-theme="a"><a href="#page1" data-transition="slide">Lüftung</a></li>
<li data-theme="b"><a href="#page2" data-transition="slide">Obergeschoss</a></li>
<li data-theme="b"><a href="#page3" data-transition="slide">Mitte</a></li>
<li data-theme="a"><a href="#page4" data-transition="slide">Großeltern</a></li>
<li data-theme="a"><a href="#page5" data-transition="slide">Untergeschoss</a></li>
<li data-theme="a"><a href="#page6" data-transition="slide">Außen/Garage</a></li>
<li data-theme="a"><a href="#page7" data-transition="slide">Technik</a></li>
<li data-theme="c"><a href="#page8" data-transition="slide">Stromverbrauch</a></li>
<li data-theme="c"><a href="#page9" data-transition="slide">Rauchmelder</a></li>
</ul>
</div>';
}
?>
<div data-role="page" data-control-title="Home" id="page0">
<?php PrintPanel(); ?>
<div data-theme="a" data-role="header" data-position="fixed">
<a data-role="button" href="#page0" data-icon="bars" data-iconpos="left" class="ui-btn-left">Auswahl</a>
<h3>Übersicht</h3>
</div>
<div data-role="content">
<div class="ui-grid-b">
<div class="ui-block-a">
<a href="#page1" data-controltype="image">
<div style="width: 100%; height: 100%; position: relative; border: 0px solid #b8b8b8;">
<img src="images/bauelemente.png" alt="image" style="display: block; margin-left: auto; margin-right: auto">
</div>
<p style="text-align: center;">Lüftung<br><span id="Zustandszaehler0">?</span></p>
</a>
</div>
<div class="ui-block-b">
<a href="#page2" data-controltype="image">
<div style="width: 100%; height: 100%; position: relative; border: 0px solid #b8b8b8;">
<img src="images/schlafzimmer.png" alt="image" style="display: block; margin-left: auto; margin-right: auto">
</div>
<p style="text-align: center;">Oben<br><span id="Zustandszaehler1">?</span></p>
</a>
</div>
<div class="ui-block-c">
<a href="#page3" data-controltype="image">
<div style="width: 100%; height: 100%; position: relative; border: 0px solid #b8b8b8;">
<img src="images/wohnzimmer.png" alt="image" style="display: block; margin-left: auto; margin-right: auto">
</div>
<p style="text-align: center;">Mitte<br><span id="Zustandszaehler2">?</span></p>
</a>
</div>
<div class="ui-block-a">
<a href="#page4" data-controltype="image">
<div style="width: 100%; height: 100%; position: relative; border: 0px solid #b8b8b8;">
<img src="images/badmoebel.png" alt="image" style="display: block; margin-left: auto; margin-right: auto">
</div>
<p style="text-align: center;">Großeltern<br><span id="Zustandszaehler3">?</span></p>
</a>
</div>
<div class="ui-block-b">
<a href="#page5" data-controltype="image">
<div style="width: 100%; height: 100%; position: relative; border: 0px solid #b8b8b8;">
<img src="images/bauelemente.png" alt="image" style="display: block; margin-left: auto; margin-right: auto">
</div>
<p style="text-align: center;">Unten<br><span id="Zustandszaehler4">?</span></p>
</a>
</div>
<div class="ui-block-c">
<a href="#page6" data-controltype="image">
<div style="width: 100%; height: 100%; position: relative; border: 0px solid #b8b8b8;">
<img src="images/innentueren.png" alt="image" style="display: block; margin-left: auto; margin-right: auto">
</div>
<p style="text-align: center;">Außen/Garage<br><span id="Zustandszaehler5">?</span></p>
</a>
</div>
<div class="ui-block-a">
<a href="#page7" data-controltype="image">
<div style="width: 100%; height: 100%; position: relative; border: 0px solid #b8b8b8;">
<img src="images/buero-praxis.png" alt="image" style="display: block; margin-left: auto; margin-right: auto">
</div>
<p style="text-align: center;">Technik<br><span id="Zustandszaehler6">?</span></p>
</a>
</div>
<div class="ui-block-b">
<a href="#page8" data-controltype="image">
<div style="width: 100%; height: 100%; position: relative; border: 0px solid #b8b8b8;">
<img src="images/buero-praxis.png" alt="image" style="display: block; margin-left: auto; margin-right: auto">
</div>
<p style="text-align: center;">Stromverbrauch<br><span id="Zustandszaehler7">?</span></p>
</a>
</div>
<div class="ui-block-c">
<a href="#page9" data-controltype="image">
<div style="width: 100%; height: 100%; position: relative; border: 0px solid #b8b8b8;">
<img src="images/buero-praxis.png" alt="image" style="display: block; margin-left: auto; margin-right: auto">
</div>
<p style="text-align: center;">Rauchmelder<br><span id="Zustandszaehler8">?</span></p>
</a>
</div>
</div>
</div>
</div>
<div data-role="page" data-control-title="Lüftung" id="page1">
<?php PrintPanel(); ?>
<div data-theme="a" data-role="header" data-position="fixed">
<a data-role="button" href="#page0" data-icon="bars" data-iconpos="left" class="ui-btn-left">Auswahl</a>
<h3>Lüftung <span id="UpdateStatus"></span>
</h3>
</div>
<div data-role="content">
<div data-role="fieldcontain">
<?php
PrintDimLightStatus("Bad Decke","homie/fsr-og-control/bad/dimmer/deckenlampeBadOG");
PrintLightStatus("Flur OG Decke","homie/fsr-og-control/flurOG/relais/deckenlampeFlurOG");
PrintLightStatus("Lüftung Bypass Auf","homie/fsr-og-control/flurOG/relais/lüftungBypassAuf");
PrintLightStatus("Lüftung Bypass Zu","homie/fsr-og-control/flurOG/relais/lüftungBypassZu");
PrintLightStatus("Lüftung WZ Auf","homie/fsr-og-control/flurOG/relais/lüftungWZAuf");
PrintLightStatus("Lüftung WZ Zu","homie/fsr-og-control/flurOG/relais/lüftungWZZu");
PrintLightStatus("Flur OG Steckdosen","homie/fsr-og-control/flurOG/relais/steckdosenFlur");
PrintDimLightStatus("Janosch Decke","homie/fsr-og-control/janoschsZimmer_ehemals_PeterZimmer/dimmer/deckenlampeJanoschOG");
PrintDimLightStatus("Pauline Decke","homie/fsr-og-control/paulineZimmer/dimmer/deckenlampePaulineOG");
PrintDimLightStatus("Schlafzimmer Decke","homie/fsr-og-control/schlafzimmer/dimmer/deckenlampeSZOG");
PrintLightStatus("Spitzboden","homie/fsr-og-control/spitzboden/relais/lampe");
PrintDimLightStatus("WZ Gaube Decke","homie/fsr-og-control/wohnzimmer/dimmer/deckenlampeGaubeOG");
PrintDimLightStatus("WZ Decke West","homie/fsr-og-control/wohnzimmer/dimmer/deckenlampeWestOG");
PrintLightStatus("WZ Steckdosen 3er 2","homie/fsr-og-control/wohnzimmer/relais/steckdoseWohnzimmerOG3er2");
PrintLightStatus("WZ Steckdosen 3er 3","homie/fsr-og-control/wohnzimmer/relais/steckdoseWohnzimmerOG3er3");
PrintLightStatus("WZ Steckdosen 3er rechts","homie/fsr-og-control/wohnzimmer/relais/steckdoseWohnzimmerOG3errechts");
PrintLightStatus("WZ Steckdosen Alle anderen","homie/fsr-og-control/wohnzimmer/relais/steckdoseWohnzimmerOGAlleanderen");
PrintLightStatus("WZ Steckdosen Ecke","homie/fsr-og-control/wohnzimmer/relais/steckdoseWohnzimmerOGEcke");
PrintWindowStatus("Badfenster", "homie/enocean/bad/fenster/dachfenster");
PrintWindowStatus("Kindergatter OG", "homie/enocean/flurOG/unknown/kindergatter");
PrintDoorStatus("Küche EG Terrassentüre Süd", "homie/enocean/kücheWohnbereich/fenster/terrassentüreSüd");
PrintDoorStatus("Küche EG Terrassentüre West", "homie/enocean/kücheWohnbereich/fenster/terrassentüreWest");
PrintWindowStatus("Haustüre", "homie/enocean/flurUG/fenster/haustüre");
PrintDoorStatus("WZ OG Türe re", "homie/enocean/wohnzimmer/fenster/türere");
PrintDoorStatus("Küche GE Türe", "homie/enocean/kücheGE/fenster/türe");
PrintDoorStatus("Duschbad GE Fenster", "homie/enocean/duschbadGE/fenster/badfensterGE");
PrintDoorStatus("Schlafzimmer OG Fenster li", "homie/enocean/schlafzimmer/fenster/türeli");
PrintDoorStatus("Duschbad UG Fenster", "homie/enocean/duschbadUG/fenster/fenster");
?>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$.ajaxSetup({ cache: false });
});
function isInt(n) {
return typeof n === 'number' && n % 1 == 0;
}
$(function () {
setInterval(function () {
//console.log('AktualisierungFaellig: '+AktualisierungFaellig);
if (AktualisierungFaellig>=0) AktualisierungFaellig--;
//console.log("location.port"+location.port);
var jqxhr = $.getJSON( "http://"+ window.location.hostname+":8000", function() {
// console.log("success: "+Date.now());
})
.done(function(data) {
var currentdate = new Date();
var datetime = currentdate.getDate() + "." + (currentdate.getMonth()+1) + ". "
+ currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds();
$.each(data, function(k, value) {
tsk = (k).replace(new RegExp('/','g'),"-").replace(new RegExp('\\$','g'),"-").replace(new RegExp('\\<','g'),"-").replace(new RegExp('\\>','g'),"-");
ts = ("input[name='radio-"+tsk+"']");
if ( $( ts ).length) {
if( $(ts).is(':visible') ) { //if object on visible page
if ( (value.type == "FTKE") || (value.type == "FTK") || (value.type == "FHF") ) {
$("#Update"+tsk).html("(updated "+Math.round(((Date.now()/1000)-value.time)/60*10)/10 + 'min)');
$(ts+"[value='"+value.v+"']").prop("checked",true);
$(ts).checkboxradio("refresh");
}
}
}
ts = ("#slider"+tsk);
//Nur, wenn eine gewisse MindestZeit verstrichen ist, sollen wieder die Relais Update passieren
if ((AktualisierungFaellig < 0) && ( $( ts ).length)) {
//console.log(value);
if( $(ts).is(':visible') ) { //if object on visible page
//console.log(value);
if ( (value.type == "relais") ) {
if ( $("#slider"+tsk).is(':visible') ) { //if object on visible page
//console.log("#slider"+value2.IP);
$("#slider"+tsk).slider();
$("#slider"+tsk).slider('enable');
$("#Zeit"+tsk).html("(updated "+Math.round(((Date.now()/1000)-value.time)/60*10)/10 + 'min)');
if (value.v == 0) {
$("#slider"+tsk).val('off').slider('refresh');
} else {
$("#slider"+tsk).val('on').slider('refresh');
}
}
}
if ( (value.type == "dimmer") ) {
if ( $("#slider"+tsk).is(':visible') ) { //if object on visible page
$("#slider"+tsk).slider('enable');
$("#Zeit"+tsk).html("(updated "+Math.round(((Date.now()/1000)-value.time)/60*10)/10 + 'min)');
//$("#slider"+tsk).val(value.v); //$("#slider"+tsk).slider('refresh');
$("#slider"+tsk).val(value.v*100).slider('refresh');
}
}
}
}
})
$("#UpdateStatus").html("Update OK ("+datetime+")");
})
.fail(function() {
var currentdate = new Date();
var datetime = currentdate.getDate() + "." + (currentdate.getMonth()+1) + ". "
+ currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds();
$("#UpdateStatus").html("Error while updating ("+datetime+")");
});
}, 1000);
});
</script>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment