Hi,
I am working on a new project. For lack of the ability to do real programming, obviously I stuck at the moment.
I want to control a LED-dim-program on a esp8266 and therefore I have to make a webinterface to input the user values.
I have test this and this sucessfully but I am not able to put things together to get my own working interface.
First, I have made the html-page.
<!DOCTYPE html>
<html>
<head>
<title>illumination fish tank</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="icon" type="image/png" href="favicon.png">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
</head>
<body>
<div class="topnav">
<h1>illumination fish tank <i class="fas fa-cogs"></i></h1>
</div>
<div class="card-grid">
<div class="card">
<p class="card-title">setup automated illumination</p>
<form>
<b>switch automated illumination on and off.</b><br><br>
<input type="checkbox" id="state" name="switch" value="on" checked>
<label for="state">on/off</label>
<br>
<br><b>if switched on, set sunrise and sunset time (24h format)</b></br><br>
<label for="steps">sunrise (format: hh:mm)</label>
<input type="time" id="sunrise" name="sunrise"><br><br>
<label for="steps">sunset (format: hh:mm)</b></label>
<input type="time" id="sunset " name="sunset">
</form>
<button onclick="submitForm()">save</button>
</div>
</div>
<br><br>
<div class="card-grid">
<div class="card">
<p class="card-title">actual illumination value</p>
<select name="illumination value">
<option value="0">off</option>
<option value="20">25%</option>
<option value="50">50%</option>
<option value="75">75%</option>
<option value="100">100%</option>
<option selected value="90">Default</option>
</select>
<button onclick="submitForm()">set action</button>
</div>
</div>
</body>
<script src="script.js"></script>
</html>
It looks like this at the moment:

So it is not that complicate.
If someone want's to setup the upper part of the form, he can fill the fields and submit by clicking save.
If you want to change the illumination value, you can choose from a drop down list and click set action.
I have saved that together with a script:

So the really big problems are the script and maybe the c++ codepart in the arduino/esp8266 to get the data.
I do not really have a script yet only this scrap
var gateway = `ws://${window.location.hostname}/ws`;
var websocket;
window.addEventListener('load', onload);
var direction;
function onload(event) {
initWebSocket();
}
function getValues(){
websocket.send("getValues");
}
function initWebSocket() {
console.log('Trying to open a WebSocket connection…');
websocket = new WebSocket(gateway);
websocket.onopen = onOpen;
websocket.onclose = onClose;
websocket.onmessage = onMessage;
}
function onOpen(event) {
console.log('Connection opened');
getValues();
}
function onClose(event) {
console.log('Connection closed');
setTimeout(initWebSocket, 2000);
}
function submitForm(){
}
function onMessage(event) {
console.log(event.data);
direction = event.data;
var myObj = JSON.parse(event.data);
var keys = Object.keys(myObj);
}
So, who of you great guys
- and I really mean you are great because in the german section of this forum the helpful answers are rare; people there are focused to correct my spelling (even if I am natural speaker in german) and start some discussion which does not fit to my problems-
who of you have time and want to help me in this project? I hope there is anyone out there.
Greetings
Sven

