feat: HA smart home control improvements

- stats_cache: swap interesting domains to controllable-only (remove sensors/binary_sensors)
- stats_cache: filter pre-release/camera/HA-addon switches from entity list
- index.html: add visual toggle switch buttons per entity
- index.html: fix scene activation (was returning early; now calls scene/turn_on)
- index.html: remove 8-per-domain cap on entity display
- index.html: add domain icons and unavailable state handling
- index.html: alarm panel arm/disarm toggle logic
This commit is contained in:
2026-05-31 05:05:44 +00:00
parent ca3ae31826
commit 499adadc6d
2 changed files with 71 additions and 16 deletions
+20 -3
View File
@@ -133,13 +133,30 @@ if (HA_TOKEN !== 'YOUR_HA_TOKEN_HERE' && strpos(HA_URL, '10.48.200.X') === false
$states = $statesRaw ? json_decode($statesRaw, true) : [];
$config = $configRaw ? json_decode($configRaw, true) : [];
$interesting = ['light','switch','sensor','climate','binary_sensor','cover',
'media_player','camera','alarm_control_panel','lock','fan','input_boolean'];
// Controllable domains only — skip read-only sensors to keep list manageable
$interesting = ['light','switch','scene','media_player','alarm_control_panel',
'lawn_mower','water_heater','fan','lock','cover','climate','input_boolean'];
// Switches that are HA internals / camera settings, not physical devices
$skipKeywords = ['pre_release','_record','_ftp_','_push_','_hub_ringtone',
'_siren_on','_email_on','_manual_record','_infrared_',
'do_not_disturb','matter_server','zerotier','mariadb',
'spotify_connect','file_editor','ssh_web','uptime_kuma',
'folding_home','music_assistant','get_hacs','mealie',
'mosquitto','social_to','esphome_device','motion_detection',
'front_yard_record','down_hill_record','camera1_record',
'back_yard_record','nvr_','assist_microphone','cec_scanner',
'kiosker','hacs_pre','adguard'];
$grouped = [];
foreach (($states ?? []) as $entity) {
$domain = explode('.', $entity['entity_id'])[0];
if (!in_array($domain, $interesting)) continue;
if (strpos($entity['entity_id'], 'adguard') !== false) continue;
if ($domain === 'switch') {
$skip = false;
foreach ($skipKeywords as $kw) {
if (strpos($entity['entity_id'], $kw) !== false) { $skip = true; break; }
}
if ($skip) continue;
}
if (!isset($grouped[$domain])) $grouped[$domain] = [];
$grouped[$domain][] = [
'entity_id' => $entity['entity_id'],