Improve Webflash

This commit is contained in:
iranl
2025-04-13 21:46:26 +02:00
parent cc118edbfb
commit ea192d3c0d
5 changed files with 111 additions and 51 deletions

View File

@@ -1,37 +1,104 @@
<!DOCTYPE html>
<title>Nuki Hub web installer</title>
<html>
<html lang="en" class="">
<head>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/>
<title>Install NukiHub</title>
<style>
div,input,select{padding:5px;font-size:1em;}
input{width:100%;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;background:#dddddd;color:#000000;}
input[type=checkbox],input[type=radio]{width:1em;margin-right:6px;vertical-align:-1px;}
input[type=range]{width:99%;}
select{width:100%;background:#dddddd;color:#000000;}
body{text-align:center;font-family:verdana,sans-serif;background:#252525;}
button{border:0;border-radius:0.3rem;background:#1fa3ec;color:#faffff;line-height:2.4rem;font-size:1.2rem;width:100%;-webkit-transition-duration:0.4s;transition-duration:0.4s;cursor:pointer;}
button:hover{background:#0e70a4;}
a{color:#1fa3ec;text-decoration:none;}
.pick-variant{margin-bottom:16px;}
</style>
<script type="module" src="https://unpkg.com/esp-web-tools/dist/web/install-button.js?module"></script>
<script>
window.addEventListener("load", function(event) {
const button = document.querySelector("esp-web-install-button");
const selectEl = document.querySelector("#pick-variant-selector");
<body>
<h1>Nuki Hub</h1>
<div id="main" style="display: none;">
<br>
<script
type="module"
src="https://unpkg.com/esp-web-tools/dist/web/install-button.js?module">
</script>
<esp-web-install-button id="installButton" manifest="https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/webflash_manifest.json"></esp-web-install-button>
<br><br><br><br>
Note: If flashing doesn't work, press and hold the "BOOT" switch, then click "Install".
</div>
<div id="notSupported" style="display: none;">
Your browser does not support the Web Serial API. Try a different browser like Chrome, Opera, Edge.
</div>
<script>
if(navigator.serial){
document.getElementById("notSupported").style.display = 'none';
document.getElementById("main").style.display = 'block';
} else {
document.getElementById("notSupported").style.display = 'block';
document.getElementById("main").style.display = 'none';
}
</script>
</body>
</html>
fetch("https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/dummy.bin").then(function(response) {
if (!response.ok) {
throw new Error("Not 2xx response", {cause: response});
}
else {
for (let i = 0; i < selectEl.options.length; i++) {
const text = selectEl.options[i].value;
if (text == '') {
selectEl.remove(i);
i--;
}
}
}
}).catch(function(err) {
for (let i = 0; i < selectEl.options.length; i++) {
const text = selectEl.options[i].value;
if (text.includes('/beta/')) {
selectEl.remove(i);
i--;
}
}
});
try{
button.manifest = "https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/webflash_manifest.json";
selectEl.addEventListener("change", () => {
button.manifest = selectEl.value;
});
}
catch(e){
console.log(e);
}
},{ once: true });
</script>
</head>
<body>
<div style='display:inline-block;color:#eaeaea;min-width:340px;'>
<h1>Install NukiHub</h1>
<div class='pick-variant'>
<ol style='text-align:left'>
<li>Connect the ESP device to your computer</br>using USB or serial-to-USB adapter</li></br>
<li>Select the firmware variant suitable for</br>your device</li></br>
<li>Click "Connect" and select the correct port</br>or find help if <a href="https://github.com/technyon/nuki_hub" target='_blank' style='color:#aaa;'>no device found</a></li>
</ol>
</br>
</br>
<div id="URL_based_input" class="collapsible">
<select id="pick-variant-selector">
<optgroup label="Release version">
<option label="NukiHub Default (ESP32, ESP32-C3, ESP32-C6, ESP32-S3, ESP32-P4)" value="https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/webflash_manifest.json"></option>
<option label="NukiHub ESP32-S3 OCTAL PSRAM" value="https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/webflash_manifest_s3octal.json"></option>
<option label="NukiHub ESP32-SOLO1" value="https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/webflash_manifest_solo1.json"></option>
<option label="NukiHub GL-S10" value="https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/webflash_manifest_gls10.json"></option>
</optgroup>
<optgroup label="Beta version">
<option class="beta" label="NukiHub Default (ESP32, ESP32-C3, ESP32-C6, ESP32-S3, ESP32-P4)" value="https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/webflash_manifest.json"></option>
<option class="beta" label="NukiHub ESP32-S3 OCTAL PSRAM" value="https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/webflash_manifest_s3octal.json"></option>
<option class="beta" label="NukiHub GL-S10" value="https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/webflash_manifest_gls10.json"></option>
<option class="beta" label="NukiHub ESP32-SOLO1" value="https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/webflash_manifest_solo1.json"></option>
<option class="beta" label="No Beta available" disabled value=""></option>
</optgroup>
<optgroup label="Development version">
<option label="NukiHub Default (ESP32, ESP32-C3, ESP32-C6, ESP32-S3, ESP32-P4)" value="https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/webflash_manifest.json"></option>
<option label="NukiHub ESP32-S3 OCTAL PSRAM" value="https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/webflash_manifest_s3octal.json"></option>
<option label="NukiHub ESP32-SOLO1" value="https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/webflash_manifest_solo1.json"></option>
<option label="NukiHub GL-S10" value="https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/webflash_manifest_gls10.json"></option>
</optgroup>
</select>
</div>
</br>
<esp-web-install-button id="inst" style='text-align:center'>
<i slot="unsupported">Your browser does not support Web Serial.</br>Open this page in Google Chrome or</br>Microsoft Edge instead.</i>
</esp-web-install-button>
</div>
<div style='text-align:right;font-size:11px;'>
<hr/>
<a href="https://esphome.github.io/esp-web-tools/" target='_blank' style='color:#aaa;'>NukiHub Installer inspired by Tasmota and ESP Web Tools</a>
</div>
</div>
</body>
</html>