From 772fc48d004c5266070c8272981b3c6a639cffce Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Sat, 30 May 2026 04:46:29 +0000 Subject: [PATCH] HA tab: add ALL / ON ONLY toggle filter --- public_html/admin/index.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/public_html/admin/index.php b/public_html/admin/index.php index 327df95..09c0819 100644 --- a/public_html/admin/index.php +++ b/public_html/admin/index.php @@ -572,6 +572,8 @@ select.filter-sel:focus{border-color:var(--cyan)}
DOMAIN: +   +  
@@ -1132,9 +1134,22 @@ async function loadHA() { renderHATable(_haEntities); } +let _haOnlyOn = false; + +function setHAOnlyOn(onlyOn, btn) { + _haOnlyOn = onlyOn; + document.getElementById('ha-all-btn').classList.toggle('active', !onlyOn); + document.getElementById('ha-on-btn').classList.toggle('active', onlyOn); + filterHATable(); +} + function filterHATable() { const q = document.getElementById('ha-search')?.value.toLowerCase() || ''; - renderHATable(q ? _haEntities.filter(e => (e.name||'').toLowerCase().includes(q)||(e.entity_id||'').toLowerCase().includes(q)) : _haEntities); + const ON_STATES = ['on','home','open','playing','mowing','active','idle']; + let list = _haEntities; + if (_haOnlyOn) list = list.filter(e => ON_STATES.includes(e.state)); + if (q) list = list.filter(e => (e.name||'').toLowerCase().includes(q)||(e.entity_id||'').toLowerCase().includes(q)); + renderHATable(list); } function renderHATable(entities) {