diff --git a/public_html/admin/index.php b/public_html/admin/index.php index c2e9c75..8980f78 100644 --- a/public_html/admin/index.php +++ b/public_html/admin/index.php @@ -626,7 +626,7 @@ select.filter-sel:focus{border-color:var(--cyan)}   -   +  
SCANNING...
@@ -1290,23 +1290,45 @@ function filterHATable() { } function renderHATable(entities) { - if (!entities.length) { document.getElementById('ha-tbl').innerHTML='
NO ENTITIES
'; return; } - const domainColors = {light:'#ffcc00',switch:'#00d4ff',binary_sensor:'#39ff14',sensor:'#9b9bff',media_player:'#ff8800',alarm_control_panel:'#ff3333',camera:'#888'}; - let rows = entities.map(e => { - const on = ['on','home','open','playing','mowing','active'].includes(e.state); + const avail = entities.filter(e => e.state !== 'unavailable' && e.state !== 'unknown'); + if (!avail.length) { document.getElementById('ha-tbl').innerHTML='
NO ENTITIES
'; return; } + const domainColors = {light:'#ffcc00',switch:'#00d4ff',media_player:'#ff8800',alarm_control_panel:'#ff3333',scene:'#00d4ff',lawn_mower:'#39ff14',water_heater:'#ff8800',fan:'#9b9bff'}; + const domainIcon = {light:'\u{1F4A1}',switch:'\u{1F50C}',scene:'\u{1F3AC}',media_player:'\u{1F4FA}',alarm_control_panel:'\u{1F512}',lawn_mower:'\u{1F33F}',water_heater:'\u{1F321}',fan:'\u{1F4A8}'}; + let rows = avail.map(e => { + const on = ['on','home','open','playing','mowing','armed_home','armed_away','armed_night','active'].includes(e.state); + const isScene = e.domain === 'scene'; const dc = domainColors[e.domain] || 'var(--dim)'; + const icon = domainIcon[e.domain] || '•'; + const stateLabel = isScene ? '—' : (on ? 'ON' : 'OFF'); + const ctrl = isScene + ? `` + : ``; return ` - ${esc(e.domain)} + ${icon} + ${esc(e.domain)} ${esc(e.name||e.entity_id)} - ${esc(e.entity_id)} - ${esc(e.state)} + ${stateLabel} + ${ctrl} `; }).join(''); document.getElementById('ha-tbl').innerHTML = ` - + ${rows}
DOMAINNAMEENTITY IDSTATE
DOMAINNAMESTATECTRL
`; } +function haToggle(entityId, currentState, el) { + el.style.opacity = '0.5'; + apiPost('ha_toggle', {entity_id: entityId, state: currentState}, () => { + el.style.opacity = '1'; + loadHA(); + }); +} + // ── NEWS ────────────────────────────────────────────────────────────────────── async function loadNews() { document.getElementById('news-custom').innerHTML='
SCANNING...
';