From 66f50dcc70b6de57b01d95bbf50471ea3abcb720 Mon Sep 17 00:00:00 2001 From: wez3 Date: Sat, 7 Jan 2017 19:21:05 +0100 Subject: [PATCH] Allow different domoticz type fields to be used at the top_tiles. --- example.conf | 6 +++--- static/js/domoboard.js | 4 ++-- templates/top_tiles.html | 15 +++++++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/example.conf b/example.conf index ddb27e0..ad18ebf 100644 --- a/example.conf +++ b/example.conf @@ -32,11 +32,11 @@ [[top_tiles]] Temperatuur tuin = 31, fire Temperatuur auto = 22, car - Stroomverbruik TV = 13, plug + Stroomverbruik TV = 13, plug, Usage Temperatuur Eindhoven = 54, fire Temperatuur tuin BMP = 55, fire - Totaal Playstation = 25, plug - Totaal slaapkamer lamp = 12, plug + Totaal Playstation = 25, plug, Usage + Totaal slaapkamer lamp = 12, plug, CounterToday Temperatuur raspberry = 1, car [[line_charts]] Temperatuur Slaapkamer = 14, month, temp diff --git a/static/js/domoboard.js b/static/js/domoboard.js index e1abd05..22a0f6a 100644 --- a/static/js/domoboard.js +++ b/static/js/domoboard.js @@ -57,7 +57,7 @@ function refreshSwitches(updateSwitches, block) { } // Top tiles functions -function refreshTopTiles(updateDivs, block, tilesPreviousArray) { +function refreshTopTiles(updateDivs, block, tilesPreviousArray, updateDivsTypeArray) { if (tilesPreviousArray.length == 0) { for(var i = 0; i < updateDivs.length; i++){ tilesPreviousArray.push(-1); @@ -69,7 +69,7 @@ function refreshTopTiles(updateDivs, block, tilesPreviousArray) { requestAPI(url, function(d) { var obj = JSON.parse(d); if (obj.result != undefined) { - var data = obj.result[0].Data; + var data = obj.result[0][updateDivsTypeArray[i]]; } else { var data = "-"; } diff --git a/templates/top_tiles.html b/templates/top_tiles.html index 0e370cf..bdc038a 100644 --- a/templates/top_tiles.html +++ b/templates/top_tiles.html @@ -5,7 +5,7 @@
{{k}} -
{{v[2]}}
+
{% endfor %} @@ -14,15 +14,22 @@ $(document).ready(function() { var updateDivs_block_{{count}}=[]; var tilesPreviousArray_{{count}}=[]; + var updateDivsType_block_{{count}} = []; {% for k, v in blockArray[count]["top_tiles"].iteritems() %} updateDivs_block_{{count}}.push("{{v[0]}}"); + {% set data = v[2] %} + {% if data is defined %} + updateDivsType_block_{{count}}.push("{{v[2]}}"); + {% else %} + updateDivsType_block_{{count}}.push("Data"); + {% endif %} {% endfor %} - tilesPreviousArray_{{count}} = refreshTopTiles(updateDivs_block_{{count}}, "top_tiles_block_{{count}}_", tilesPreviousArray_{{count}}); + + tilesPreviousArray_{{count}} = refreshTopTiles(updateDivs_block_{{count}}, "top_tiles_block_{{count}}_", tilesPreviousArray_{{count}}, updateDivsType_block_{{count}}); + tilesPreviousArray_{{count}} = setInterval(refreshTopTiles, 9000, updateDivs_block_{{count}}, "top_tiles_block_{{count}}_", tilesPreviousArray_{{count}}, updateDivsType_block_{{count}}); for (var i in updateDivs_block_{{count}}) { $("#top_tiles_block_{{count}}_" + updateDivs_block_{{count}}[i]).removeClass("loading"); } - tilesPreviousArray_{{count}} = setInterval(refreshTopTiles, 9000, updateDivs_block_{{count}}, "top_tiles_block_{{count}}_", tilesPreviousArray_{{count}}); }); -