- Posts: 12
- Thank you received: 0
Please Log in or Create an account to join the conversation.
function getModuleData(module){
var data = {
icon: "",
status: "",
timestamp: "",
rawvalue: "",
unit: "",
rawvalue1: ""
};
data.icon = "user/" + Eiot.Data.ProfileId + "/images/dimmer.png";
var ic = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Settings.Icon1");
if (ic != null && ic != "" && ic != "undefined")
data.icon = "user/" + Eiot.Data.ProfileId + "/images/" + ic.Value;
var level = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.Parameter1");
if (level != null) {
data.unit = level.Unit;
data.timestamp = level.Timestamp;
data.rawvalue = level.Value;
var value = Math.round(level.Value.replace(",", ".") * 100) / 100;
if (isNaN(value)) value = level.Value;
data.status = data.status + ((level.Description == "") ? "" : level.Description + ": ") + value + ((level.Unit == "") ? "" : " " + level.Unit)+ "<br>";
}
var level1 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.Parameter2");
if (level1 != null) {
data.rawvalue1 = level1.Value;
if (data.timestamp < level1.Timestamp)
data.timestamp = level1.Timestamp;
var offText = "OFF";
var o1 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Settings.StatusText2");
if (o1 != null)
offText = o1.Value;
var level = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.Parameter2");
if (!(level != null && level.Value == "1"))
data.status = offText+ "<br>";
}
if (module.Parameters != null) {
if (module.Parameters.length > 2)
for (var p = 2; p < module.Parameters.length; p++) {
if (module.Parameters[p].Name.substring(0, 7) == "Sensor.") {
data.status = data.status + ((module.Parameters[p].Description == "") ? module.Parameters[p].Name : module.Parameters[p].Description) + ": " + module.Parameters[p].Value + ((module.Parameters[p].Unit == "") ? "" : " " + module.Parameters[p].Unit) + "<br>";
if (data.timestamp < module.Parameters[p].Timestamp)
data.timestamp = module.Parameters[p].Timestamp;
}
}
}
return data;
}
Please Log in or Create an account to join the conversation.
bmwmilos wrote: So it seems I did something wrong in my other account and even though I deleted all of the modules and module groups,something remained and causes a problem.
Now the module is working ok and it would be great if it would be added to the app.
The module code is:Well,this is only function getModuleData but the rest is ok.function getModuleData(module){ var data = { icon: "", status: "", timestamp: "", rawvalue: "", unit: "", rawvalue1: "" }; data.icon = "user/" + Eiot.Data.ProfileId + "/images/dimmer.png"; var ic = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Settings.Icon1"); if (ic != null && ic != "" && ic != "undefined") data.icon = "user/" + Eiot.Data.ProfileId + "/images/" + ic.Value; var level = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.Parameter1"); if (level != null) { data.unit = level.Unit; data.timestamp = level.Timestamp; data.rawvalue = level.Value; var value = Math.round(level.Value.replace(",", ".") * 100) / 100; if (isNaN(value)) value = level.Value; data.status = data.status + ((level.Description == "") ? "" : level.Description + ": ") + value + ((level.Unit == "") ? "" : " " + level.Unit)+ "<br>"; } var level1 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.Parameter2"); if (level1 != null) { data.rawvalue1 = level1.Value; if (data.timestamp < level1.Timestamp) data.timestamp = level1.Timestamp; var offText = "OFF"; var o1 = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Settings.StatusText2"); if (o1 != null) offText = o1.Value; var level = Eiot.WebApp.Utility.GetModulePropertyByName(module, "Sensor.Parameter2"); if (!(level != null && level.Value == "1")) data.status = offText+ "<br>"; } if (module.Parameters != null) { if (module.Parameters.length > 2) for (var p = 2; p < module.Parameters.length; p++) { if (module.Parameters[p].Name.substring(0, 7) == "Sensor.") { data.status = data.status + ((module.Parameters[p].Description == "") ? module.Parameters[p].Name : module.Parameters[p].Description) + ": " + module.Parameters[p].Value + ((module.Parameters[p].Unit == "") ? "" : " " + module.Parameters[p].Unit) + "<br>"; if (data.timestamp < module.Parameters[p].Timestamp) data.timestamp = module.Parameters[p].Timestamp; } } } return data; }
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
bmwmilos wrote: I am waiting eagerly for the new app.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.