Why use index numbers for user variables where the variable name will do? Sensors need to be replaced from time to time, and some even need to be replaced with new Domoticz devices after battery replacement. The following small change in frontpage.js (last line adds
$.PageArray[ii][0] === item.Name || to the original if-statement) enables use of both the device name (item.Name) or device index (item.idx):
Code: Select all
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.Name || $.PageArray[ii][0] === item.idx ) {
... and frontpage_settings.js can then use the device names OR index numbers as follows
Code: Select all
.
.
['168','Status', 'cell11', 'Garageport','0','0'],
['Hovedstue Temp','Temp', 'cell12', 'Stue','1','0'],
['Kj\u00f8kken Temp','Temp', 'cell13', 'Kjøkken','1','0'],
.
.
I find this a lot easier than looking up index numbers...