391e615893
Flask-App + mobile Web UI für Diagnose vor Ort ohne HAOS/MQTT. Pi 3B: eth0 → ShineLAN-X (DHCP), wlan0 → Hotspot "ShineDiag". Browser auf http://10.0.1.1: Modell wählen, alle Sensoren auslesen, Rohdaten-Register-Dump, Export als JSON. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
281 lines
10 KiB
HTML
281 lines
10 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
<title>ShineDiag</title>
|
|
<style>
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
body { font-family: system-ui, sans-serif; background: #0f172a; color: #e2e8f0; min-height: 100vh; }
|
|
|
|
header { background: #1e293b; padding: 16px 20px; border-bottom: 1px solid #334155;
|
|
display: flex; align-items: center; gap: 12px; }
|
|
header svg { flex-shrink: 0; }
|
|
header h1 { font-size: 1.2rem; font-weight: 700; color: #f8fafc; }
|
|
header p { font-size: .75rem; color: #94a3b8; }
|
|
|
|
main { padding: 16px; max-width: 640px; margin: 0 auto; }
|
|
|
|
.card { background: #1e293b; border: 1px solid #334155; border-radius: 12px;
|
|
padding: 16px; margin-bottom: 16px; }
|
|
.card h2 { font-size: .85rem; font-weight: 600; color: #94a3b8;
|
|
text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }
|
|
|
|
label { display: block; font-size: .8rem; color: #94a3b8; margin-bottom: 4px; margin-top: 10px; }
|
|
input, select {
|
|
width: 100%; padding: 10px 12px; border-radius: 8px;
|
|
border: 1px solid #334155; background: #0f172a; color: #f1f5f9;
|
|
font-size: .9rem;
|
|
}
|
|
input:focus, select:focus { outline: 2px solid #3b82f6; border-color: transparent; }
|
|
|
|
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
|
|
|
|
button { width: 100%; padding: 12px; border-radius: 8px; border: none; cursor: pointer;
|
|
font-size: .95rem; font-weight: 600; margin-top: 14px; transition: opacity .15s; }
|
|
button:disabled { opacity: .4; cursor: not-allowed; }
|
|
.btn-primary { background: #3b82f6; color: #fff; }
|
|
.btn-primary:hover:not(:disabled) { background: #2563eb; }
|
|
.btn-raw { background: #475569; color: #e2e8f0; }
|
|
.btn-raw:hover:not(:disabled) { background: #334155; }
|
|
.btn-export { background: #059669; color: #fff; }
|
|
.btn-export:hover:not(:disabled) { background: #047857; }
|
|
|
|
.status { display: flex; align-items: center; gap: 8px; padding: 10px 12px;
|
|
border-radius: 8px; font-size: .85rem; margin-top: 12px; }
|
|
.status.ok { background: #052e16; color: #4ade80; border: 1px solid #166534; }
|
|
.status.error { background: #1c0a09; color: #f87171; border: 1px solid #7f1d1d; }
|
|
.status.info { background: #0c1a2e; color: #60a5fa; border: 1px solid #1e3a5f; }
|
|
|
|
.sensor-table { width: 100%; border-collapse: collapse; margin-top: 4px; }
|
|
.sensor-table th { text-align: left; font-size: .75rem; color: #64748b;
|
|
padding: 6px 8px; border-bottom: 1px solid #334155; }
|
|
.sensor-table td { padding: 8px; font-size: .85rem; border-bottom: 1px solid #1e293b; }
|
|
.sensor-table tr:last-child td { border-bottom: none; }
|
|
.sensor-table .val { font-weight: 600; color: #f1f5f9; text-align: right; }
|
|
.sensor-table .unit { color: #64748b; font-size: .75rem; text-align: right; }
|
|
.sensor-name { color: #cbd5e1; }
|
|
|
|
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
|
|
.tab { flex: 1; padding: 8px; border-radius: 6px; border: 1px solid #334155;
|
|
background: transparent; color: #94a3b8; font-size: .8rem; cursor: pointer; }
|
|
.tab.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }
|
|
|
|
.raw-table { width: 100%; border-collapse: collapse; font-family: monospace; font-size: .8rem; }
|
|
.raw-table th { text-align: left; color: #64748b; padding: 4px 8px;
|
|
border-bottom: 1px solid #334155; }
|
|
.raw-table td { padding: 5px 8px; border-bottom: 1px solid #1e293b; color: #cbd5e1; }
|
|
.raw-table td:first-child { color: #60a5fa; }
|
|
|
|
#results { display: none; }
|
|
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #ffffff44;
|
|
border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
|
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<header>
|
|
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="#f59e0b" stroke-width="2">
|
|
<circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/>
|
|
<line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/>
|
|
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/>
|
|
<line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/>
|
|
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/>
|
|
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
|
|
</svg>
|
|
<div>
|
|
<h1>ShineDiag</h1>
|
|
<p>Vor-Ort Diagnose via ShineLAN-X</p>
|
|
</div>
|
|
</header>
|
|
|
|
<main>
|
|
<div class="card">
|
|
<h2>Verbindung</h2>
|
|
|
|
<label>ShineLAN-X IP</label>
|
|
<input id="ip" type="text" value="10.0.0.100" placeholder="10.0.0.100">
|
|
|
|
<div class="row">
|
|
<div>
|
|
<label>Port</label>
|
|
<input id="port" type="number" value="502">
|
|
</div>
|
|
<div>
|
|
<label>Modbus-Adresse</label>
|
|
<input id="slave" type="number" value="1" min="1" max="247">
|
|
</div>
|
|
</div>
|
|
|
|
<label>Wechselrichter-Modell</label>
|
|
<select id="model"></select>
|
|
|
|
<button class="btn-primary" id="btnScan" onclick="scan()">
|
|
Auslesen
|
|
</button>
|
|
</div>
|
|
|
|
<div class="card" id="results">
|
|
<div class="tabs">
|
|
<button class="tab active" onclick="showTab('sensors')">Sensoren</button>
|
|
<button class="tab" onclick="showTab('raw')">Rohdaten</button>
|
|
</div>
|
|
|
|
<div id="statusMsg"></div>
|
|
|
|
<div id="tabSensors">
|
|
<table class="sensor-table">
|
|
<thead><tr><th>Sensor</th><th style="text-align:right">Wert</th><th style="text-align:right">Einheit</th></tr></thead>
|
|
<tbody id="sensorBody"></tbody>
|
|
</table>
|
|
<button class="btn-export" id="btnExport" onclick="exportJson()" style="margin-top:12px">
|
|
Export JSON
|
|
</button>
|
|
</div>
|
|
|
|
<div id="tabRaw" style="display:none">
|
|
<div class="row" style="margin-bottom:10px">
|
|
<div>
|
|
<label>Start-Register</label>
|
|
<input id="rawStart" type="number" value="0" min="0">
|
|
</div>
|
|
<div>
|
|
<label>Anzahl</label>
|
|
<input id="rawCount" type="number" value="100" min="1" max="125">
|
|
</div>
|
|
</div>
|
|
<button class="btn-raw" onclick="rawScan()">Register lesen</button>
|
|
<div style="overflow-x:auto; margin-top:12px">
|
|
<table class="raw-table">
|
|
<thead><tr><th>Addr</th><th>Hex</th><th>Dez</th><th>Signed</th></tr></thead>
|
|
<tbody id="rawBody"></tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<script>
|
|
let lastScan = null;
|
|
|
|
async function loadModels() {
|
|
const res = await fetch('/api/models');
|
|
const data = await res.json();
|
|
const sel = document.getElementById('model');
|
|
sel.innerHTML = '';
|
|
for (const [id, m] of Object.entries(data)) {
|
|
const opt = document.createElement('option');
|
|
opt.value = id;
|
|
opt.textContent = `${m.name} (${m.sensor_count} Sensoren)`;
|
|
sel.appendChild(opt);
|
|
}
|
|
}
|
|
|
|
function showTab(tab) {
|
|
document.getElementById('tabSensors').style.display = tab === 'sensors' ? '' : 'none';
|
|
document.getElementById('tabRaw').style.display = tab === 'raw' ? '' : 'none';
|
|
document.querySelectorAll('.tab').forEach((t, i) =>
|
|
t.classList.toggle('active', (i === 0) === (tab === 'sensors')));
|
|
}
|
|
|
|
function setStatus(msg, type) {
|
|
const el = document.getElementById('statusMsg');
|
|
el.innerHTML = `<div class="status ${type}">${msg}</div>`;
|
|
}
|
|
|
|
async function scan() {
|
|
const btn = document.getElementById('btnScan');
|
|
btn.disabled = true;
|
|
btn.innerHTML = '<span class="spinner"></span> Verbinde…';
|
|
document.getElementById('results').style.display = 'block';
|
|
setStatus('Verbinde mit ShineLAN-X…', 'info');
|
|
|
|
try {
|
|
const res = await fetch('/api/scan', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({
|
|
ip: document.getElementById('ip').value,
|
|
port: parseInt(document.getElementById('port').value),
|
|
slave: parseInt(document.getElementById('slave').value),
|
|
model: document.getElementById('model').value,
|
|
})
|
|
});
|
|
const data = await res.json();
|
|
|
|
if (!data.ok) {
|
|
setStatus('⚠ ' + (data.error || 'Fehler'), 'error');
|
|
return;
|
|
}
|
|
|
|
lastScan = data;
|
|
setStatus(`✓ ${data.manufacturer} ${data.model} — ${data.sensors.length} Sensoren gelesen`, 'ok');
|
|
|
|
const tbody = document.getElementById('sensorBody');
|
|
tbody.innerHTML = '';
|
|
for (const s of data.sensors) {
|
|
const val = s.value !== null ? s.value : '—';
|
|
const tr = document.createElement('tr');
|
|
tr.innerHTML = `
|
|
<td class="sensor-name">${esc(s.name)}</td>
|
|
<td class="val">${val}</td>
|
|
<td class="unit">${esc(s.unit || '')}</td>`;
|
|
tbody.appendChild(tr);
|
|
}
|
|
} catch (e) {
|
|
setStatus('⚠ Netzwerkfehler: ' + e.message, 'error');
|
|
} finally {
|
|
btn.disabled = false;
|
|
btn.textContent = 'Auslesen';
|
|
}
|
|
}
|
|
|
|
async function rawScan() {
|
|
setStatus('Lese Register…', 'info');
|
|
try {
|
|
const res = await fetch('/api/raw', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({
|
|
ip: document.getElementById('ip').value,
|
|
port: parseInt(document.getElementById('port').value),
|
|
slave: parseInt(document.getElementById('slave').value),
|
|
start: parseInt(document.getElementById('rawStart').value),
|
|
count: parseInt(document.getElementById('rawCount').value),
|
|
})
|
|
});
|
|
const data = await res.json();
|
|
if (!data.ok) { setStatus('⚠ ' + data.error, 'error'); return; }
|
|
|
|
const tbody = document.getElementById('rawBody');
|
|
tbody.innerHTML = '';
|
|
for (const r of data.registers) {
|
|
const tr = document.createElement('tr');
|
|
tr.innerHTML = `<td>${r.addr}</td><td>${r.hex}</td><td>${r.dec}</td><td>${r.signed}</td>`;
|
|
tbody.appendChild(tr);
|
|
}
|
|
setStatus(`✓ ${data.registers.length} Register gelesen`, 'ok');
|
|
} catch (e) {
|
|
setStatus('⚠ ' + e.message, 'error');
|
|
}
|
|
}
|
|
|
|
function exportJson() {
|
|
if (!lastScan) return;
|
|
const blob = new Blob([JSON.stringify(lastScan, null, 2)], {type: 'application/json'});
|
|
const a = document.createElement('a');
|
|
a.href = URL.createObjectURL(blob);
|
|
a.download = `shinediag_${new Date().toISOString().slice(0,19).replace(/:/g,'-')}.json`;
|
|
a.click();
|
|
}
|
|
|
|
function esc(s) {
|
|
return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
|
}
|
|
|
|
loadModels();
|
|
</script>
|
|
</body>
|
|
</html>
|