Skip to content

Technical Overview

fastender edited this page Jul 2, 2025 · 1 revision

Technical Overview & Architecture

This page provides a detailed look into the technical implementation of the Fast Search Card.

Summary

The code defines a web component (FastSearchCard) that acts as an all-in-one solution for searching, visualizing, and controlling Home Assistant entities. It goes far beyond a simple search bar, functioning more like a mini-application within a Home Assistant dashboard.


Key Features & Technical Implementation

Client-Side Search Engine (MiniSearch)

  • Implementation: The file begins by embedding a complete, compact JavaScript class called MiniSearch. This is a lightweight full-text search library.
  • How it Works: Instead of sending a request to the Home Assistant server for every search, the card loads all relevant entities once, builds a local search index in the browser, and performs all search queries directly on the client. This is the reason for its high speed.
  • Features:
    • Fuzzy Search: Finds results even with minor typos.
    • Field Boosting: Gives certain fields higher priority in the search (e.g., device name > area).
    • Dual-Index System: Two separate indexes are created: one for standard entities and a more complex one for custom items, which can also search the content of Markdown notes.

Design & User Interface (UI)

  • Spatial UI Aesthetic: The CSS uses modern techniques like backdrop-filter: blur() to create a "glassmorphism" effect.
  • Fluid Animations: The card makes extensive use of CSS Animations and the Web Animations API (element.animate(...)) to make transitions and interactions feel fluid.
  • Interactive Controls: A custom CircularSlider class is used to create the interactive circular sliders.

Flexibility & Data Management

  • Auto-Discovery: The discoverEntities method iterates through hass.states to automatically find entities based on the configuration rules.
  • custom_mode: A powerful feature that allows processing and displaying data from various sources (template_sensor, mqtt, static). The parse... methods are responsible for transforming this data into a unified format.
  • Markdown Editor: For mqtt data sources, a complete Markdown editor is rendered, which saves changes back via the mqtt.publish service with retain: true.

Detail View & Device Controls

  • Modular Controls: The getDeviceControlsHTML method acts as a switch, calling a specific get...ControlsHTML function depending on the entity's domain (light, climate, etc.).
  • Deep Integration: The card calls not only simple turn_on/turn_off services but also specific services like climate.set_temperature, light.turn_on with brightness_pct or kelvin, and media_player.play_media for the Music Assistant integration.
  • State Management: A large number of state variables in the constructor (e.g., isDetailView, activeCategory, isFilterOpen) manage the complex behavior and presentation of the UI.
Clone this wiki locally