Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Domoticz Tablet</title>
- <link href='http://fonts.googleapis.com/css?family=Orbitron:700' rel='stylesheet' type='text/css'>
- <link href='http://fonts.googleapis.com/css?family=Arimo' rel='stylesheet' type='text/css'>
- <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
- <link rel="stylesheet" href="frontpage.css">
- </head>
- <body bgcolor="#000">
- <div id="cnt">
- <div>
- <div id="frame">
- <div id="cell1">--</div><div id="desc_cell1">cell1</div>
- <div id="cell2">--</div><div id="desc_cell2">cell2</div>
- </div>
- <div id="frame">
- <div id="cell3"></div><div id="desc_cell3">cell3</div>
- </div>
- <div id="frame">
- <div id="cell4">--</div><div id="desc_cell4">cell4</div>
- <div id="cell5">--</div><div id="desc_cell5">cell5</div>
- </div>
- </div>
- <div>
- <div id="frame">
- <div id="cell6">--</div><div id="desc_cell6">cell6</div>
- </div>
- <div id="frame">
- <div id="cell7">--</div><div id="desc_cell7">cell7</div>
- </div>
- <div id="frame">
- <div id="cell8">--</div><div id="desc_cell8">cell8</div>
- </div>
- <div id="frame">
- <div id="cell9">--</div><div id="desc_cell9">cell9</div>
- </div>
- <div id="frame">
- <div id="cell10">--</div><div id="desc_cell10">cell10</div>
- </div>
- </div>
- <div>
- <div id="frame">
- <div id="cell11">--</div><div id="desc_cell11">cell11</div>
- </div>
- <div id="frame">
- <div id="cell12">--</div><div id="desc_cell12">cell12</div>
- </div>
- <div id="frame">
- <div id="cell13">--</div><div id="desc_cell13">cell12</div>
- </div>
- <div id="frame">
- <div id="cell14">--</div><div id="desc_cell14">cell14</div>
- </div>
- <div id="frame">
- <div id="cell15">--</div><div id="desc_cell15">cell15</div>
- </div>
- </div>
- <div>
- <div id="frame">
- <div id="cell16">--</div><div id="desc_cell16">cell16</div>
- </div>
- <div id="frame">
- <div id="cell17">--</div><div id="desc_cell17">cell17</div>
- </div>
- <div id="frame">
- <div id="cell18">--</div><div id="desc_cell18">cell18</div>
- </div>
- <div id="frame">
- <div id="cell19">--</div><div id="desc_cell19">cell19</div>
- </div>
- <div id="frame">
- <div id="cell20">--</div><div id="desc_cell20">cell20</div>
- </div>
- </div>
- </div>
- <script type="text/javascript" charset="utf-8">
- function RefreshData()
- {
- clearInterval($.refreshTimer);
- var jurl=$.domoticzurl+"/json.htm?type=devices&plan="+$.roomplan+"&jsoncallback=?";
- $.getJSON(jurl,
- {
- format: "json"
- },
- function(data) {
- if (typeof data.result != 'undefined') {
- $.each(data.result, function(i,item){
- for( var ii = 0, len = $.PageArray.length; ii < len; ii++ ) {
- if( $.PageArray[ii][0] === item.idx ) { // Domoticz idx number
- var vtype= $.PageArray[ii][1]; // Domotitcz type (like Temp, Humidity)
- var vlabel= $.PageArray[ii][2]; // cell number from HTML layout
- var vdesc= $.PageArray[ii][3]; // description
- var vattr= $.PageArray[ii][4]; // extra css attributes
- var valarm= $.PageArray[ii][5]; // alarm value to turn text to red
- var vdata= item[vtype]; // current value
- if (typeof vdata == 'undefined') {
- vdata="??";
- } else {
- // remove too much text
- vdata=new String(vdata).split("Watt",1)[0];
- vdata=new String(vdata).split("kWh",1)[0];
- vdata=new String(vdata).split("m3",1)[0];
- vdata=new String(vdata).split(" Level:",1)[0];
- vdata=new String(vdata).replace("Set","On");
- }
- if (vdata == 'Sunny' ) {
- vdata=new String(vdata).replace( "Sunny","<img src=icons/sun.png width=204 height=204>");
- }
- if (vdata == 'Partly Cloudy' ) {
- vdata=new String(vdata).replace( "Partly Cloudy","<img src=icons/partlycloudy.png width=204 height=204>");
- }
- if (vdata == 'Cloudy' ) {
- vdata=new String(vdata).replace( "Cloudy","<img src=icons/cloudy.png width=204 height=204>");
- }
- if (vdata == 'Clear' ) {
- vdata=new String(vdata).replace( "Clear","<img src=icons/clear.png width=204 height=204>");
- }
- if (vdata == 'Rain' ) {
- vdata=new String(vdata).replace( "Rain","<img src=icons/rain.png width=204 height=204>");
- }
- if (vdata == 'Snow' ) {
- vdata=new String(vdata).replace( "Snow","<img src=icons/snow.png width=204 height=204>");
- }
- if (vdata == 'Fog' ) {
- vdata=new String(vdata).replace( "Fog","<img src=icons/fog.png width=204 height=204>");
- }
- if (vdata == 'Hail' ) {
- vdata=new String(vdata).replace( "Hail","<img src=icons/hail.png width=204 height=204>");
- }
- if (vdata == 'Thunderstom' ) {
- vdata=new String(vdata).replace( "Thunderstorm","<img src=icons/thunderstorm.png width=204 height=204>");
- }
- if (vdata == 'Sleet' ) {
- vdata=new String(vdata).replace( "Sleet","<img src=icons/sleet.png width=204 height=204>");
- }
- if(item.idx == '1' || item.idx == '5'){
- vdata=new String(vdata).split("%",1)[0];
- vdata=Math.round(vdata);
- }
- if(item.idx == '107'){
- vdata=Math.round(vdata * 10) / 10;
- }
- if(item.idx == '30' || item.idx == '38'){
- vdata= vdata + ' ';
- }
- // create switchable value when item is switch
- switchclick='';
- if (vdata == 'Off' ) {
- switchclick = 'onclick="SwitchToggle('+item.idx+', \'On\');"';
- }
- if (vdata == 'On' ) {
- switchclick = 'onclick="SwitchToggle('+item.idx+', \'Off\');"';
- }
- // if alarm threshold is defined, make value red
- //alarmcss='';
- //if (typeof valarm != 'undefined') {
- // if ( eval(vdata + valarm)) { // note orig: vdata > alarm
- // alarmcss=';color:red;';
- // }
- //}
- // if switch is on, make green, if off, make red
- alarmcss='';
- if (vdata == 'On' || vdata == 'On ') { // note orig: vdata > alarm
- alarmcss=';color:green;';
- vdata = 'Aan';
- }
- if (vdata == 'Off' || vdata == 'Off ') { // note orig: vdata > alarm
- alarmcss=';color:red;';
- vdata = 'Uit';
- }
- if(item.idx == '107' && vdata > 40){
- vdata='Aan';
- alarmcss=';color:green;';
- }
- if(item.idx == '107' && vdata < 40 && vdata > 0.9){
- vdata='Uit';
- alarmcss=';color:red;';
- }
- if(item.idx == '107' && vdata < 40 && vdata > 0.9){
- vdata='Uit';
- alarmcss=';color:red;';
- }
- if (vdata > 3 && vdata < 13) { // note orig: vdata > alarm
- alarmcss=';background-color:#FF0000;width:100%; height:100%;';
- }
- if (vdata > 25 && vdata <50) { // note orig: vdata > alarm
- alarmcss=';color:#FFA500;';
- }
- if (vdata > 50 && vdata <75) { // note orig: vdata > alarm
- alarmcss=';color:#FF0000;';
- }
- if (vdata > 75 && vdata <100) { // note orig: vdata > alarm
- alarmcss=';color:#FF00FF;';
- }
- // if extra css attributes
- if (typeof vattr == 'undefined') {
- $('#'+vlabel).html('<div '+switchclick+' style='+alarmcss+'>'+vdata+'</div>');
- } else {
- $('#'+vlabel).html( '<div '+switchclick+' style='+vattr+alarmcss+'>'+vdata+'</div>');
- }
- $('#desc_'+vlabel).html(vdesc);
- }
- }
- });
- }
- });
- $.refreshTimer = setInterval(RefreshData, 8000);
- }
- // ############################################################################################################
- // #### vvvvv USER VALUES below vvvvv #######
- // ############################################################################################################
- $(document).ready(function() {
- $.roomplan=2; // define roomplan in Domoticz and create items below.
- $.domoticzurl="http://192.168.0.100:8080";
- //format: idx, value, label, description, [override css], [alarm value]
- $.PageArray = [
- ['1', 'Data', 'cell1', 'Memory RPi (%)'],
- ['5', 'Data', 'cell2', 'CPU RPi (%)'],
- ['31', 'ForecastStr', 'cell3', 'Forecast'],
- ['107', 'CounterToday', 'cell4', 'Pomp verbr. (kWh)',],
- ['107', 'Usage', 'cell5', 'Pomp',],
- ['11', 'Status', 'cell6', 'Lamp voor',],
- ['14', 'Status', 'cell7', 'Lamp lage kast',],
- ['10', 'Status', 'cell8', 'Lamp achter'],
- ['13', 'Status', 'cell9', 'Lamp subwoofer'],
- ['12', 'Status', 'cell10', 'Lamp hoge kast'],
- ['30', 'Status', 'cell11', 'iPhone Marco'],
- ['74', 'Level', 'cell12', 'Spots uitbouw %'],
- ['74', 'Status', 'cell13', 'Spots uitbouw'],
- ['40', 'Status', 'cell14', 'Spots voortuin'],
- ['103', 'Status', 'cell15', 'Spots achtertuin'],
- ['38', 'Status', 'cell16', 'iPhone Karin'],
- ['31', 'Temp', 'cell17', 'Buiten (°C)'],
- ['31', 'Humidity', 'cell18', 'Humidity (%)'],
- ['8', 'Status', 'cell19', 'Slaapkamer'],
- ['16', 'Status', 'cell20', 'Badkamer'],
- ];
- // ############################################################################################################
- // #### ^^^^^ USER VALUES above ^^^^^ #######
- // ############################################################################################################
- RefreshData();
- });
- function SwitchToggle(idx, switchcmd)
- {
- console.log('function called');
- $.ajax({
- url: "json.htm?type=command¶m=switchlight" + "&idx=" + idx + "&switchcmd=" + switchcmd + "&level=0",
- async: false,
- dataType: 'json',
- success: function(){
- console.log('SUCCES');
- },
- error: function(){
- console.log('ERROR');
- }
- });
- RefreshData();
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement