@ -51,7 +51,7 @@
< / div >
< div class = "row mb-3" >
< div class = "col-12 col-sm-3 my-2" > Interval [s]< / div >
< div class = "col-12 col-sm-9" > < input type = "text " name = "serIntvl" pattern = "[0-9]+ " title = "Invalid input" / > < / div >
< div class = "col-12 col-sm-9" > < input type = "number " name = "serIntvl" title = "Invalid input" / > < / div >
< / div >
< / fieldset >
< / div >
@ -274,7 +274,7 @@
< / div >
< div class = "row mb-3" >
< div class = "col-12 col-sm-3 my-2" > Topic< / div >
< div class = "col-12 col-sm-9" > < input type = "text" name = "mqttTopic" pattern = "[A-Za-z0-9./#$%&=+ _- ]+" title = "Invalid input" / > < / div >
< div class = "col-12 col-sm-9" > < input type = "text" name = "mqttTopic" pattern = "[\-\+ A-Za-z0-9\ .\ /#\ $%&=_]+" title = "Invalid input" / > < / div >
< / div >
< p class = "des" > Send Inverter data in a fixed interval, even if there is no change. A value of '0' disables the fixed interval. The data is published once it was successfully received from inverter. (default: 0)< / p >
< div class = "row mb-3" >
@ -373,7 +373,6 @@
< / div >
{#HTML_FOOTER}
< script type = "text/javascript" >
var highestId = 0;
var maxInv = 0;
var ts = 0;
@ -479,7 +478,7 @@
[1, "high active"],
];
const re = /1[1,3][2,4,6,8][1,2,4].*/;
const re = /1[0, 1,3][2,4,6,8][1,2,4].*/;
window.onload = function() {
for(it of document.getElementsByClassName("s_collapsible")) {
@ -500,9 +499,7 @@
}
document.getElementById("btnAdd").addEventListener("click", function() {
if(highestId < = (maxInv-1)) {
ivHtml(JSON.parse('{"enabled":true,"name":"","serial":"","channels":6,"ch_max_pwr":[0,0,0,0,0,0],"ch_name":["","","","","",""],"ch_yield_cor":[0,0,0,0,0,0]}'), highestId);
}
ivHtml(JSON.parse('{"enabled":true,"name":"","serial":"","channels":6,"ch_max_pwr":[0,0,0,0,0,0],"ch_name":["","","","","",""],"ch_yield_cor":[0,0,0,0,0,0]}'));
});
function apiCbWifi(obj) {
@ -572,12 +569,8 @@
}
function delIv() {
var id = this.id.substring(0,4);
var e = document.getElementsByName(id + "Addr")[0];
e.value = "";
e.dispatchEvent(new Event("keyup"));
e.dispatchEvent(new Event("change"));
document.getElementsByName(id + "Name")[0].value = "";
var id = this.id.substring(0, this.id.length-3);
document.getElementById(id).remove();
}
function mlCb(id, des, chk=false) {
@ -597,16 +590,30 @@
]);
}
function ivHtml(obj, id) {
highestId = id + 1;
if(highestId == maxInv)
function getFreeId() {
var id = 0;
while(id < maxInv ) {
if(null == document.getElementById("inv" + id))
return id;
id++;
}
return null;
}
function ivHtml(obj) {
var id = getFreeId();
if(null == id) {
setHide("btnAdd", true);
return;
}
var iv = document.getElementById("inverter");
var iv = ml("div", {id: "inv" + id}, null);
document.getElementById("inverter").appendChild(iv);
iv.appendChild(des("Inverter " + id));
id = "inv" + id;
var addr = inp(id + "Addr", obj["serial"], 12, ["text"], null, "text", "[0-9]+", "Invalid input");
var addr = ml("input", {name: id + "Addr", class: "text", type: "number", max: 138999999999, value: obj["serial"]}, null);
iv.append(
mlCb(id + "Enable", "Communication Enable", obj["enabled"]),
mlE("Serial Number (12 digits)*", addr)
@ -629,6 +636,7 @@
if((serial.charAt(1) == 0) || (serial.charAt(1) == 1) || (serial.charAt(1) == 3)) {
if((serial.charAt(3) == 1) || (serial.charAt(3) == 2) || (serial.charAt(3) == 4)) {
switch(serial.charAt(2)) {
default:
case "2": max = 1; break;
case "4": max = 2; break;
case "6": max = 4; break;
@ -651,12 +659,12 @@
})
});
iv.append(mlE("Name*", inp(id + "Name", obj["name"], 16, ["text"], null, "text", "[A-Za-z0-9./#$%& =+ _- ]+", "Invalid input")));
iv.append(mlE("Name*", inp(id + "Name", obj["name"], 16, ["text"], null, "text", "[\\-\\+ A-Za-z0-9.\\ /#$%& =_]+", "Invalid input")));
for(var j of [
["ModPwr", "ch_max_pwr", "Max Module Power (Wp)", 4, "[0-9]+"],
["ModName", "ch_name", "Module Name", 15, null],
["YieldCor", "ch_yield_cor", "Yield Total Correction [kWh]", 8, "[0-9- \.]+"]]) {
["YieldCor", "ch_yield_cor", "Yield Total Correction [kWh]", 8, "[\\- 0-9\.]+"]]) {
var cl = (re.test(obj["serial"])) ? "" : " hide";
@ -679,7 +687,7 @@
);
}
var del = inp(id+"del", "X", 0, ["btn", "btnDel"], id+"del", "button" );
var del = ml("input", {class: "btn btnDel", type: "button", id: id+"del", value: "X"}, null );
del.addEventListener("click", delIv);
iv.append(mlE("Delete", del));
}
@ -727,10 +735,10 @@
}
function parseIv(obj) {
maxInv = obj["max_num_inverters"];
for(var i = 0; i < obj.inverter.length ; i + + )
ivHtml(obj.inverter[i], i );
ivHtml(obj.inverter[i]);
ivGlob(obj);
maxInv = obj["max_num_inverters"];
}
function parseMqtt(obj) {
@ -829,7 +837,7 @@
ml("div", {class: "col-4 col-sm-9"}, en)
])
);
pins = [['csb', 'pinCsb'], ['fcsb', 'pinFcsb'], ['irq ', 'pinGpio3']];
pins = [['csb', 'pinCsb'], ['fcsb', 'pinFcsb'], ['gpio3 ', 'pinGpio3']];
for(p of pins) {
e.append(
ml("div", {class: "row mb-3"}, [
@ -909,7 +917,8 @@
[2, [1,1,0,0,0,0]], //SH1106_128X64
[3, [1,1,1,1,0,0]], //PCD8544_84X48 /nokia5110
[4, [1,1,0,0,0,0]], //SSD1306_128X32
[5, [1,1,0,0,0,0]], //SSD1306_64X48
[5, [1,1,0,0,0,0]], //SSD1306_128x64
[6, [1,1,0,0,0,0]], //SSD1309_128x64
[10, [1,1,1,1,1,1]] //ePaper
])
for(var i = 0; i < pins.length ; i + + ) {