Skip to content

Commit 8f780e3

Browse files
authored
Add files via upload
1 parent 0ea4bc5 commit 8f780e3

31 files changed

+2190
-1301
lines changed

AAA_DECODE.ino

Lines changed: 187 additions & 107 deletions
Large diffs are not rendered by default.

AAA_HOMEPAGE.H

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
2+
const char ECU_HOMEPAGE [] PROGMEM = R"=====(
3+
<!DOCTYPE html><html><head><meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1'><title>ESP-ECU</title><link rel="icon" type="image/x-icon" href="/favicon.ico" /><link rel='stylesheet' type='text/css' href='/STYLESHEET_HOME'><style>body { background-color: #EEE;}span {padding: 6px;}table, th, td {border: 2px solid blue; font-size:16px; padding:6px; text-align:center; border-collapse:collapse;backgound-color:#dfff80;}tr {background-color:#ccffcc;}td { width:70px; }.btn { background-color: #199319; color: white; padding: 5px 22px; border-radius:6px;}.btn:hover {background: #eeeF; color:black;} @media only screen and (max-width: 800px) {th, td { width:60px; font-size:11px;}tr {height:35px;} .btn { padding: 5px 18px; font-size:10px;}}</style>
4+
<script type="text/javascript" src="SECURITY"></script>
5+
<script type='text/javascript'>
6+
var term,table_row;window.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&(getGeneral(),setTimeout(getAll,300))}));var cnt=0,totalEn=0;function loadScript(){getGeneral(),setTimeout(getAll,300)}function celbgc(e){e.startsWith("e")||e.startsWith("i")?document.getElementById(e).style="background-color:#c6ff1a":document.getElementById(e).style="background-color:#a6a6a6"}function getAll(){totalEn=0;for(let e=0;e<cnt;e++)term="get.Power?inv="+e,table_row="inv"+e,getData(e)}function getData(e){var t=new XMLHttpRequest;t.onreadystatechange=function(){if(4==this.readyState&&200==this.status){var t=this.responseText,n=JSON.parse(t),l=n.eN,o="r"+String(e);document.getElementById(o).style.display="table-row";var a="i"+String(e);document.getElementById(a).innerHTML="<a href='/details?inv="+String(e)+"'><button class='btn'>"+String(e)+"</button</a>";for(let t=0;t<4;t++)a="p"+String(e)+t,"n/e"==n.p[t]?celbgc(a):"n/a"==n.p[t]?document.getElementById(a).innerHTML=n.p[t]:document.getElementById(a).innerHTML=n.p[t].toFixed(1);celbgc(a="e"+String(e)),"n/a"!=l?(cnt>1&&(totalEn+=parseFloat(l),celbgc("e9"),document.getElementById("r9").style.display="table-row",document.getElementById("e9").innerHTML=totalEn.toFixed(2)),document.getElementById(a).innerHTML=l.toFixed(2)):document.getElementById(a).innerHTML=l,document.getElementById("noOutput").style.display="none",document.getElementById("4channel").style.display="block";const d=(new Date).toString();document.getElementById("time").innerHTML=d.substr(16,8)}},t.open("GET",term,!0),t.send()}function getGeneral(){var e=new XMLHttpRequest;e.onreadystatechange=function(){if(4==this.readyState&&200==this.status){var e=this.responseText,t=JSON.parse(e);cnt=t.cnt,console.log("getGeneral cnt = "+cnt);var n="polling from "+t.ps+" to "+t.pe;document.getElementById("times").innerHTML=n;var l=t.st,o=t.sl;0==t.rm&&(document.getElementById("ml").style.display="block"),"11"==l?document.getElementById("busy").style.display="block":(document.getElementById("busy").style.display="none",document.getElementById("failed").style.display="none"),"0"!=l&&"25"!=l||(document.getElementById("failed").style.display="block");var a=document.getElementById("maindiv");document.getElementById("sleep");"1"==o?(a.style.background="grey",document.getElementById("noOutput").style.display="none"):a.style.background="linear-gradient(#e8edc8, #c8eaed)"}},e.open("GET","get.General",!0),e.send()}if(window.EventSource){var source=new EventSource("/events");source.addEventListener("open",(function(e){console.log("Events Connected")}),!1),source.addEventListener("error",(function(e){e.target.readyState!=EventSource.OPEN&&console.log("Events Disconnected")}),!1),source.addEventListener("message",(function(e){console.log("message",e.data),"getall"==e.data&&getAll(),"general"==e.data&&getGeneral(),"reload"==e.data&&(getGeneral(),setTimeout(getAll,300))}),!1)}
7+
</script></head><body onload='loadScript()'><div id='msect'><ul><li id='ml' style='float:right; display:none'><a id='haha' href='/MENU'>menu</a></li></ul></div><div id='msect'><center><h3>ESP ECU</h3></div><div id='msect'><div class='divstijl' id='maindiv'><center><p><span id='times'></span></p><h4>POWER / ENERGY @ <span id='time'></span></h4><div id='noOutput' style='display:block'><h4 style='color:red'>waiting for output</h4></div><div id='4channel' style='display:none;'><center><table><tr style='Background-color:lightblue; font-weight:bold; text-align:center; border:4px solid black;'><td>inverter<td>panel 0<td>panel 1<td>panel 2<td>panel 3<td>kWh</td></tr><tr id='r0' style='display:none;'><td id='i0'></td><td id='p00'></td><td id='p01'></td><td id='p02'></td><td id='p03'></td><td id='e0'></td></tr><tr id='r1' style='display:none;'><td id='i1'></td><td id='p10'></td><td id='p11'></td><td id='p12'></td><td id='p13'></td><td id='e1'></td></tr><tr id='r2' style='display:none;'><td id='i2'></td><td id='p20'></td><td id='p21'></td><td id='p22'></td><td id='p23'></td><td id='e2'></td></tr><tr id='r3' style='display:none;'><td id='i3'></td><td id='p30'></td><td id='p31'></td><td id='p32'></td><td id='p33'></td><td id='e3'></td></tr><tr id='r4' style='display:none;'><td id='i4'></td><td id='p40'></td><td id='p41'></td><td id='p42'></td><td id='p43'></td><td id='e4'></td></tr><tr id='r5' style='display:none;'><td id='i5'></td><td id='p50'></td><td id='p51'></td><td id='p52'></td><td id='p53'></td><td id='e5'></td></tr><tr id='r6' style='display:none;'><td id='i6'></td><td id='p60'></td><td id='p61'></td><td id='p62'></td><td id='p63'></td><td id='e6'></td></tr><tr id='r7' style='display:none;'><td id='i7'></td><td id='p70'></td><td id='p71'></td><td id='p72'></td><td id='p73'></td><td id='e7'></td></tr><tr id='r8' style='display:none;'><td id='i8'></td><td id='p80'></td><td id='p81'></td><td id='p82'></td><td id='p83'></td><td id='e8'></td></tr><tr id='r9' style='display:none;'><td colspan='5' style='text-align:right;'>total of all inverters&nbsp;</td><td id='e9'></td></tr></table></div><p>Powered by Hansiart</p><div id='busy'><span style='color:red;'><h3>checking / initialyzing zigbee network...</h3></span><br></div><div id='failed' style='display:none;'><span style='color:red;'><h3>the zigbee module is not working.</h3></span><br></div></center></div></div></body></html>
8+
)=====";
9+
10+
11+
12+
13+
// this is the original javascript. Made compact via https://www.digitalocean.com/community/tools/minify
14+
/*
15+
const char JAVA_SCRIPT[] PROGMEM = R"=====(
16+
window.addEventListener('visibilitychange', () =>{
17+
if (document.visibilityState === 'visible') {
18+
//window.location.reload();}
19+
getGeneral();
20+
setTimeout(getAll, 300);
21+
}
22+
})
23+
24+
var term;
25+
var table_row;
26+
var cnt = 0;
27+
var totalEn = 0;
28+
29+
function loadScript() {
30+
getGeneral();
31+
//console.log("getGeneral done, now getAll()");
32+
setTimeout(getAll, 300);
33+
}
34+
function celbgc(cel) {
35+
if(cel.startsWith("e") || cel.startsWith("i")) {
36+
document.getElementById(cel).style = "background-color:#c6ff1a"; }
37+
else {document.getElementById(cel).style = "background-color:#a6a6a6";
38+
}
39+
}
40+
41+
function getAll() {
42+
totalEn = 0;
43+
//console.log("getAll count = " + cnt);
44+
for (let i = 0; i < cnt; i++) {
45+
term = "get.Power?inv=" + i;
46+
table_row = "inv" + i;
47+
getData(i);
48+
}
49+
50+
}
51+
52+
function getData(invnr) {
53+
var xhttp = new XMLHttpRequest();
54+
xhttp.onreadystatechange = function() {
55+
if (this.readyState == 4 && this.status == 200) {
56+
var antwoord = this.responseText;
57+
//console.log("inverter = " + invnr);
58+
var obj = JSON.parse(antwoord);
59+
//cnt = obj.cnt;
60+
//console.log("cnt = " + cnt);
61+
var eN = obj.eN;
62+
63+
var regel = "r" + String(invnr);
64+
document.getElementById(regel).style.display="table-row";
65+
var cel = "i" + String(invnr);
66+
//document.getElementById(cel).innerHTML = String(invnr);
67+
document.getElementById(cel).innerHTML = "<a href='/details?inv=" + String(invnr) + "'><button class='btn'>" + String(invnr) + "</button</a>";
68+
var cel;
69+
for (let z=0; z < 4 ; z++) {
70+
//console.log("obj.p[z] = " + obj.p[z]);
71+
cel = "p" + String(invnr) + z;
72+
if (obj.p[z] == "n/e" ) {
73+
celbgc(cel);
74+
}
75+
else
76+
if (obj.p[z] == "n/a" ) {document.getElementById(cel).innerHTML = obj.p[z];}
77+
else {
78+
document.getElementById(cel).innerHTML = obj.p[z].toFixed(1);
79+
}
80+
}
81+
82+
cel = "e" + String(invnr);
83+
celbgc(cel);
84+
85+
if(eN != "n/a") {
86+
if(cnt > 1){
87+
totalEn = totalEn + parseFloat(eN);
88+
celbgc("e9");
89+
document.getElementById("r9").style.display="table-row";
90+
document.getElementById("e9").innerHTML = totalEn.toFixed(2);
91+
}
92+
document.getElementById(cel).innerHTML = eN.toFixed(2);
93+
} else {
94+
document.getElementById(cel).innerHTML = eN;
95+
}
96+
97+
document.getElementById("noOutput").style.display = "none";
98+
document.getElementById("4channel").style.display = "block";
99+
const d = new Date().toString();
100+
document.getElementById("time").innerHTML = d.substr(16,8);
101+
}
102+
}
103+
xhttp.open("GET", term, true);
104+
xhttp.send();
105+
}
106+
107+
function getGeneral() {
108+
// console.log("term = " + term);
109+
var xhttp = new XMLHttpRequest();
110+
xhttp.onreadystatechange = function() {
111+
if (this.readyState == 4 && this.status == 200) {
112+
var antwoord = this.responseText;
113+
// console.log("answer = " + antwoord);
114+
var obj = JSON.parse(antwoord);
115+
cnt = obj.cnt;
116+
console.log("getGeneral cnt = " + cnt);
117+
var times = "polling from " + obj.ps + " to " + obj.pe;
118+
document.getElementById("times").innerHTML=times;
119+
var st = obj.st;
120+
var sl = obj.sl;
121+
var rem = obj.rm;
122+
if(rem == 0) {document.getElementById("ml").style.display = "block";} // hide menu link
123+
if(st == "11") {
124+
document.getElementById("busy").style.display = "block";
125+
} else {
126+
document.getElementById("busy").style.display = "none";
127+
document.getElementById("failed").style.display = "none";
128+
}
129+
if(st == "0" || st == "25") {
130+
document.getElementById("failed").style.display = "block";
131+
}
132+
var main = document.getElementById("maindiv")
133+
var slp = document.getElementById("sleep")
134+
if(sl == "1") {
135+
main.style.background="grey";
136+
document.getElementById("noOutput").style.display = "none";
137+
} else {
138+
main.style.background="linear-gradient(#e8edc8, #c8eaed)";
139+
}
140+
}
141+
}
142+
xhttp.open("GET", "get.General", true);
143+
xhttp.send();
144+
145+
}
146+
147+
148+
if (!!window.EventSource) {
149+
var source = new EventSource('/events');
150+
151+
source.addEventListener('open', function(e) {
152+
console.log("Events Connected");
153+
}, false);
154+
source.addEventListener('error', function(e) {
155+
if (e.target.readyState != EventSource.OPEN) {
156+
console.log("Events Disconnected");
157+
}
158+
}, false);
159+
160+
source.addEventListener('message', function(e) {
161+
console.log("message", e.data);
162+
if(e.data == "getall") {
163+
getAll();
164+
}
165+
if(e.data == "general") {
166+
getGeneral();
167+
}
168+
if (e.data == "reload") {
169+
//window.location.reload(1);
170+
getGeneral();
171+
setTimeout(getAll, 300);
172+
}
173+
}, false);
174+
}
175+
176+
)=====";
177+
*/

AAA_INVERTERS.ino

Lines changed: 29 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@ const char INVCONFIG_START[] PROGMEM = R"=====(
33
<title>ESP-ECU</title>
44
<meta name="viewport" content="width=device-width, initial-scale=1">
55
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
6-
<link rel="stylesheet" type="text/css" href="/STYLESHEET">
6+
<link rel="stylesheet" type="text/css" href="/STYLESHEET_HOME">
7+
<link rel="stylesheet" type="text/css" href="/STYLESHEET_SUBS">
78
<script type='text/javascript'>
89
9-
function helpfunctie() {
10-
document.getElementById("help").style.display = "block";
11-
}
12-
function sl() {
13-
document.getElementById("help").style.display = "none";
14-
}
1510
function showSubmit() {
1611
document.getElementById("sub").style.display = "block";
1712
}
@@ -38,32 +33,19 @@ div.overlay {
3833
line-height: 300px;
3934
}
4035
</style>
36+
<script>
37+
function cl() {
38+
window.location.href='/MENU';
39+
}
40+
</script>
4141
</head>
4242
<body onload='%LOADBAG%'>
4343
44-
<div id='msect'>
45-
<div id="help">
46-
<span class='close' onclick='sl();'>&times;</span><h3>INVERTER SETTINGS HELP</h3>
47-
<b>you can add max 9 inverters.</b><br><br>
48-
<b>name</b><br>
49-
Enter a meaningfull name or the position of the inverter.
50-
<br><br><b>inverter serialnr:</b><br>
51-
You can find the serialnr stickered on the inverter.
52-
<br><br><b>panels:</b><br>
53-
Check which panels are connected.
54-
<br><br><b>pair:</b><br>
55-
link your inverter to this ECU in order to make the zigbee communication possible.<br>
56-
When paired you will see the obtained inverter ID in the status field.
57-
You can find more information in the log or information page.
58-
<br><br>
59-
</div>
60-
</div>
61-
6244
<center>
6345
6446
<div id='msect'>
6547
<ul>
66-
<li><a href='/MENU'>done</a></li>
48+
<li id='fright'><span class='close' onclick='cl();'>&times;</span>
6749
<li><a href='/INV?welke=0' style='display:%none'0%>inv. 0</a></li>
6850
<li><a href='/INV?welke=1' style='display:%none'1%>inv. 1</a></li>
6951
<li><a href='/INV?welke=2' style='display:%none'2%>inv. 2</a></li>
@@ -94,7 +76,6 @@ div.overlay {
9476
<li><a href='#' onclick='delFunction("/SW=BACK")'>delete</a></li>
9577
</div>
9678
<li><a href='#' onclick='helpfunctie()'>help</a></li>
97-
9879
<li id='sub'><a href='#' onclick='submitFunction("/SW=BACK")'>save</a></li>
9980
10081
</div>
@@ -179,9 +160,8 @@ void handleInverterconfig(AsyncWebServerRequest *request)
179160
// we only collect the data for this specific inverter
180161
// read the serverargs and copy the values into the variables
181162

182-
DebugPrintln("we are in handleInverterconfig");
183-
//Serial.println("inverterCount initial = " + String(inverterCount));
184-
//Serial.println("iKeuze = " + String(iKeuze));
163+
//("we are in handleInverterconfig");
164+
185165
// collect the serverarguments
186166
strcpy(Inv_Prop[iKeuze].invLocation, request->arg("il").c_str());
187167
strcpy(Inv_Prop[iKeuze].invSerial, request->arg("iv").c_str());
@@ -217,8 +197,8 @@ void handleInverterconfig(AsyncWebServerRequest *request)
217197

218198
basisConfigsave(); // save inverterCount
219199
#ifdef DEBUG
220-
DebugPrintln("\ninverterCount after edit (saved) = " + String(inverterCount));
221-
DebugPrintln("list of the files we have after edit");
200+
//("\ninverterCount after edit (saved) = " + String(inverterCount));
201+
//("list of the files we have after edit");
222202
printInverters();
223203
#endif
224204

@@ -239,7 +219,7 @@ void handleInverterdel(AsyncWebServerRequest *request)
239219
// we only collect the data for this specific inverter
240220
// read the serverargs and copy the values into the variables
241221

242-
DebugPrintln("we are in handleInverterdel");
222+
//("we are in handleInverterdel");
243223
//Serial.println("inverterCount initial = " + String(inverterCount));
244224
//Serial.println("iKeuze = " + String(iKeuze));
245225

@@ -249,7 +229,7 @@ void handleInverterdel(AsyncWebServerRequest *request)
249229
if(LittleFS.exists(bestand) ) LittleFS.remove(bestand);
250230

251231
//Serial.println("list of the files we have after removed one");
252-
printInverters();
232+
//printInverters();
253233
inverterCount -= 1;
254234
basisConfigsave(); // save inverterCount
255235
// // now we may have a gap in the file order
@@ -264,19 +244,19 @@ void handleInverterdel(AsyncWebServerRequest *request)
264244
actionFlag = 10;
265245
}
266246

267-
void printInverters() {
268-
Serial.println(F(" ****** excisting inverter files ******"));
269-
for (int x=0; x < inverterCount+1; x++)
270-
{
271-
String bestand = "/Inv_Prop" + String(x) + ".str";
272-
273-
if(LittleFS.exists(bestand))
274-
{
275-
Serial.print(F("filename: ")); Serial.println(bestand);
276-
printStruct(bestand);
277-
}
278-
}
279-
}
247+
//void printInverters() {
248+
// Serial.println(F(" ****** excisting inverter files ******"));
249+
// for (int x=0; x < inverterCount+1; x++)
250+
// {
251+
// String bestand = "/Inv_Prop" + String(x) + ".str";
252+
//
253+
// if(LittleFS.exists(bestand))
254+
// {
255+
// Serial.print(F("filename: ")); Serial.println(bestand);
256+
// printStruct(bestand);
257+
// }
258+
// }
259+
//}
280260

281261
// say we have
282262
// Inv_prop0.str
@@ -310,7 +290,7 @@ bool found = false;
310290
found = true;
311291
LittleFS.rename(bestand_2, bestand_1); // file 2 becomes file 1
312292
//Serial.println("renamed " + bestand_1);
313-
printInverters();
293+
// printInverters();
314294
}
315295
}
316296
// we remove the last file
@@ -424,7 +404,7 @@ int verklikker = 0;
424404
if (Inv_Prop[iKeuze].conPanels[3]) { toSend.replace("#4check", "checked");}
425405
}
426406

427-
if(String(Inv_Prop[iKeuze].invID) != "0x0000")
407+
if(String(Inv_Prop[iKeuze].invID) != "0000")
428408
{
429409
toSend.replace("unpaired", String(Inv_Prop[iKeuze].invID) );
430410
}

0 commit comments

Comments
 (0)