https://www.letscontrolit.com/wiki/inde ... _Dashboard
and
viewtopic.php?t=7038
What I want to create is a simple page for setting my thermostat, which is a Level Control plugin via a mini dashboard, that also shows the current temperature which is updates every minute.
I do get either the Level Control setting from [thermostat#getLevel] working OR the current temperature updated via the json and the script.
Code: Select all
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=width=device-width, initial-scale=1">
<STYLE>
* {
font-family: sans-serif;
font-size: 16pt;
}
.button {
margin: 4px;
padding: 4px 16px;
background-color: #07D;
color: #FFF;
text-decoration: none;
border-radius: 4px
}
table {
border-collapse: collapse;
width: 100%;
}
th,
td,
h1 {
text-align: center;
padding: 8px;
}
</style>
<head>
<script onload="setInterval()">
var tempVarInterval = 1000;
setInterval(async function () {
response = await fetch("/json?view=sensorupdate");
myJson = await response.json();
tempVar = myJson.Sensors[12].TaskValues[0].Value;
document.getElementById("tempId").innerHTML = tempVar;
}, 1000);
</script>
</head>
<body>
<h1 style="color:Red; font-size:30px;">Temperatuur</h1>
<div style="overflow-x:auto;">
<table>
<tr>
<th>Huidige</th>
<th id="tempId">t</th>
</tr>
<tr>
<th>Thermostaat </th>
<th>[thermostat#getLevel]</th>
</tr>
<tr>
<th><a class='button link' href="thermostat.esp?cmd=event,tempup">Hoger</a></th>
</tr>
<tr>
<th><a class='button link' href="thermostat.esp?cmd=event,tempdown">Lager</a></th>
</tr>
</table>
</div>
</body>
</html>
When I call the file dashboardt.htm, the script updates the id="tempId piece but the [thermostat#getLevel] simply shows "[thermostat#getLevel]" instead of becoming the current pluging setting.
To add: it does seem to work on my laptop with chrome and the file called thermostat.esp but not on my iPhone.
And yes, I want it on my iPhone since that is the most easy remote-control.
From what I understand, the [thermostat#getLevel] is only rendered if the page is ending with .esp.
And on my iPhone an .esp file does not run the script?
EDIT:
It does seem to come from this piece in the LoadFromFS.cpp:
Code: Select all
if (path.endsWith(F(".src"))) { path = path.substring(0, path.lastIndexOf(".")); }
else if (path.endsWith(F(".htm")) || path.endsWith(F(".html")) || path.endsWith(F(".htm.gz")) || path.endsWith(F(".html.gz"))) { dataType = F("text/html"); }
else if (path.endsWith(F(".css")) || path.endsWith(F(".css.gz"))) { dataType = F("text/css"); }
else if (path.endsWith(F(".js")) || path.endsWith(F(".js.gz"))) { dataType = F("application/javascript"); }
else if (path.endsWith(F(".png")) || path.endsWith(F(".png.gz"))) { dataType = F("image/png"); }
else if (path.endsWith(F(".gif")) || path.endsWith(F(".gif.gz"))) { dataType = F("image/gif"); }
else if (path.endsWith(F(".jpg")) || path.endsWith(F(".jpg.gz"))) { dataType = F("image/jpeg"); }
else if (path.endsWith(F(".ico"))) { dataType = F("image/x-icon"); }
else if (path.endsWith(F(".svg"))) { dataType = F("image/svg+xml"); }
else if (path.endsWith(F(".json"))) { dataType = F("application/json"); }
else if (path.endsWith(F(".txt")) ||
path.endsWith(F(".dat"))) { dataType = F("application/octet-stream"); }
#ifdef WEBSERVER_CUSTOM
else if (path.endsWith(F(".esp"))) { return handle_custom(path); }
#endif
However, I think I should not just modify this to also handle .htm / .html files in that same way...
Would it be wise to add something to the top of this list that makes a path that endsWith "mycustom.htm" also a custom file?
(and then call my file mycustom.htm)