<!DOCTYPE html>
<html lang="de">
<head>
<title>Jalousiensteuerung mit digitalSTROM</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">
<meta name="author" content="Moritz Franckenstein [webmaster@maf-soft.de]">
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
//TODO
///json/apartment/getConsumption
///json/device/setOutputValue?dsid=x&offset=0&value=255
$(function(){
$('#loading').text('Bitte warten...');
$.ajaxSetup({ cache: false });
$.getJSON('/json/apartment/getDevices', function(data){
var items = [];
items.push('<tr><td/><td/><td/><td><input type="button" value="alle" onClick="DoPosAlle()"></td><td/></tr>');
$.each(data.result, function(key, val){
if (val.productID == 3292 && val.isPresent)
items.push('<tr><td>' + val.name + '</td>'
+ '<td><input type="button" value="↑" onClick="DoAuf(\''+ val.id+ '\')">'
+ '<input type="button" value="stop" onClick="DoStop(\''+ val.id+ '\')">'
+ '<input type="button" value="↓" onClick="DoAb(\''+ val.id+ '\')"></td>'
+ '<td><input type="button" value="sonne" onClick="DoSc2(\''+ val.id+ '\')"></td>'
+ '<td><input type="button" value="position" onClick="DoPos(\''+ val.id+ '\')"></td>'
+ '<td id="'+ val.id+ '"> </td></tr>');
});
items.sort();
$('<table/>', { html: items.join('') }).appendTo('body');
$('#loading').remove();
});
});
function DoAuf(dsid){
$('#'+ dsid).text('Anfrage läuft...');
$.get('/json/device/turnOn', { dsid: dsid }, function(data){
$('#'+ dsid).text(data.ok ? 'ok' : 'Fehler!');
});
}
function DoStop(dsid){
$('#'+ dsid).text('Anfrage läuft...');
$.get('/json/device/callScene', { dsid: dsid, sceneNumber: 15 }, function(data){
$('#'+ dsid).text(data.ok ? 'ok' : 'Fehler!');
});
}
function DoAb(dsid){
$('#'+ dsid).text('Anfrage läuft...');
$.get('/json/device/turnOff', { dsid: dsid }, function(data){
$('#'+ dsid).text(data.ok ? 'ok' : 'Fehler!');
});
}
function DoSc2(dsid){ //Stimmung 4: Sonnenschutzstellung
$('#'+ dsid).text('Anfrage läuft...');
$.get('/json/device/callScene', { dsid: dsid, sceneNumber: 19 }, function(data){
$('#'+ dsid).text(data.ok ? 'ok' : 'Fehler!');
});
}
function DoPos(dsid){
$('#'+ dsid).text('Anfrage läuft...');
$.get('/json/device/getOutputValue', { dsid: dsid, offset: 0 }, function(data){
$('#'+ dsid).text((data.ok ? data.result.value : 'Fehler!'));
});
}
function DoPosAlle(){
$('tr>td[id]').each(function(index, value){
DoPos(value.id);
});
}
</script>
</head>
<body>
<p id="loading">Wird geladen...</p>
</body>
</html>