### Python Virtual Environment Setup Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/tests/README.md Sets up a Python virtual environment and installs project dependencies, including test requirements and Playwright browsers. ```bash python -m venv .venv source .venv/bin/activate pip install -e '.[test]' playwright install --with-deps chromium ``` -------------------------------- ### Choose Selector Filter Configuration Example Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/README.md Example of a filter configuration using the choose selector for an area, as seen after visual editor upgrade. ```yaml type: custom:auto-entities card: type: entities title: Test Areas filter: include: - options: {} area: area: kitchen active_choice: area exclude: [] ``` -------------------------------- ### Entities Card Configuration Example Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/08-configuration-reference.md Example of configuring the 'card' parameter to use a standard entities card. The 'entities' parameter should be omitted as auto-entities will populate it. ```yaml card: type: entities title: My Lights show_header_toggle: false ``` -------------------------------- ### Basic Auto-Entities Card Configuration Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/00-START-HERE.md A simple example of an auto-entities card configuration that displays a list of all lights, sorted by their friendly name. This is a common starting point for users. ```yaml type: custom:auto-entities card: type: entities title: My Lights filter: include: - domain: light # Match all lights sort: method: friendly_name # Sort by name ``` -------------------------------- ### Legacy Filter Configuration Example Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/README.md Example of a legacy filter configuration for an area. ```yaml type: custom:auto-entities card: type: entities title: Test Areas filter: include: - options: {} area: kitchen exclude: [] ``` -------------------------------- ### Wildcard Matching Examples Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/02-filter-system.md Use '*' to match multiple characters in string patterns for entity IDs, names, or device names. ```yaml filter: include: - entity_id: 'light.*' # All lights - name: '* temperature' # Ends with temperature - device: 'Device *' # Starts with Device ``` -------------------------------- ### Integrator TypeScript Example for Filter Creation Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/README.md Shows how integrators can use the 'auto-entities/filter' module to programmatically create filters. This example retrieves a filter for 'light' domain entities and applies it to Home Assistant states. ```typescript import { get_filter } from 'auto-entities/filter'; const filter = await get_filter(hass, { domain: 'light' }); const matches = Object.keys(hass.states).filter(filter); ``` -------------------------------- ### Example using Jinja2 template to filter entities Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/README.md Demonstrates using a Jinja2 template within the 'filter.template' field to dynamically select entities. This example selects all 'light' entities that are currently 'on'. ```yaml type: custom:auto-entities card: type: entities filter: template: | {% for light in states.light %} {% if light.state == "on" %} {{ light.entity_id}}, {% endif %} {% endfor %} ``` -------------------------------- ### Example Auto Entities Configuration Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/05-types-and-interfaces.md Demonstrates a typical configuration structure for the custom:auto-entities card, showcasing nested options for entities, filtering, sorting, and renaming. ```yaml type: custom:auto-entities card: type: entities title: My Card entities: - light.kitchen filter: include: - domain: light sort: method: friendly_name rename: method: remove_device exclude: - state: unavailable sort: - method: domain - method: friendly_name ignore_case: true rename: type: entity show_empty: false ``` -------------------------------- ### Static Entities List Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/08-configuration-reference.md Example of providing a static list of entities to be included before filtering. Can include entity IDs or more detailed configurations. ```yaml entities: - light.kitchen - light.bedroom - entity_id: light.hallway name: Main Hall ``` -------------------------------- ### Attribute Path Examples Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/02-filter-system.md Use ':' as a separator to access nested attributes for filtering. Supports numerical indexing for lists. ```yaml filter: include: - attributes: hs_color:1: '>30' # hs_color saturation > 30 my_data:nested:value: 'test' # my_data.nested.value == 'test' ``` -------------------------------- ### Multi-Level Sort (Domain, then Name) Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/08-configuration-reference.md Apply multiple sorting methods sequentially. This example sorts first by domain and then by friendly name, ignoring case for the name sort. ```yaml type: custom:auto-entities card: type: entities filter: include: - not: domain: zone exclude: - state: unavailable sort: - method: domain - method: friendly_name ignore_case: true ``` -------------------------------- ### Example Usage of getCardController Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/07-card-controllers.md Shows how to use the `getCardController` factory function to obtain the appropriate controller for a given card type and host element, and how to call its `afterCardUpdated` method. ```typescript const controller = getCardController('history-graph', this); if (controller) { await controller.afterCardUpdated(); } ``` -------------------------------- ### Alternative Jinja2 template for filtering entities Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/README.md A more concise Jinja2 template example using Home Assistant's template filters to select all 'light' entities that are 'on'. ```yaml template: "{{states.light | selectattr('state', '==', 'on') | map(attribute='entity_id') | list}}" ``` -------------------------------- ### getConfigEntries Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/06-helpers-and-utilities.md Gets Home Assistant config entries (integrations) with optional filtering. This function also utilizes a window-level cache for performance. ```APIDOC ## getConfigEntries(hass: HassObject, filterType?: string, filterValue?: any): Promise> ### Description Gets Home Assistant config entries (integrations) with optional filtering. This function also utilizes a window-level cache for performance. ### Parameters #### Path Parameters - **hass** (HassObject) - Required - Home Assistant state object - **filterType** (string) - Optional - Optional filter field (e.g., "domain") - **filterValue** (any) - Optional - Value to filter by ### Return `Promise>` — Config entries keyed by entry_id ### Example ```typescript // Get all config entries const allEntries = await getConfigEntries(hass); // Get entries for a specific domain const mobileAppEntries = await getConfigEntries(hass, 'domain', 'mobile_app'); ``` ``` -------------------------------- ### Configure tap action options for entities Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/08-configuration-reference.md Pass specific configuration options to the underlying card for matched entities. This example sets a tap action to toggle a scene entity. ```yaml filter: include: - domain: scene options: tap_action: action: call-service service: scene.turn_on service_data: entity_id: this.entity_id ``` -------------------------------- ### Detailed filter configuration with multiple rules Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/08-configuration-reference.md An example showcasing a comprehensive filter configuration. It includes entities by domain, state, and attributes, and demonstrates options for sorting, renaming, and tap actions. ```yaml filter: include: - domain: light state: "on" attributes: brightness: ">50" sort: method: friendly_name rename: method: remove_device options: tap_action: action: toggle type: entity # Or divider / section ``` -------------------------------- ### Include and exclude entities Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/08-configuration-reference.md Define both inclusion and exclusion rules for entities. This example includes all lights but excludes those that are unavailable or hidden by the user. ```yaml filter: include: - domain: light exclude: - state: unavailable - hidden_by: user ``` -------------------------------- ### Regular Expression Matching Examples Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/02-filter-system.md Enclose patterns in '/' to use regular expressions for matching entity IDs or names. Supports case-insensitive matching. ```yaml filter: include: - entity_id: '/^light\.[ab].*$/' # Light entities starting with a or b - name: '/^.* [Ll]ight.*$/' # Name contains "light" (case-insensitive) ``` -------------------------------- ### Filter entities using a Jinja2 template (all on lights) Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/08-configuration-reference.md Use a Jinja2 template to dynamically filter entities. This example selects all 'light' domain entities that are currently 'on'. ```yaml filter: template: | {%- for light in states.light -%} {%- if light.state == 'on' -%} {{ light.entity_id }}, {%- endif -%} {%- endfor -%} ``` -------------------------------- ### Include entities by domain and area Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/08-configuration-reference.md Configure filters to include entities based on their domain and optionally their area. This example includes all lights and all switches located in the kitchen. ```yaml filter: include: - domain: light - domain: switch area: kitchen ``` -------------------------------- ### Example Usage of findInTree Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/07-card-controllers.md Illustrates how to use the `findInTree` utility method to search for elements within the card's DOM, including a type-safe variant. ```typescript // Find all ha-entity elements const entity = this.findInTree(this.host.card.shadowRoot, el => el.tagName === 'HA-ENTITY'); // Type-safe variant const entity = this.findInTree(this.host.card.shadowRoot, (el): el is HTMLElement => el.tagName === 'HA-ENTITY'); ``` -------------------------------- ### Filter entities using a concise Jinja2 template (all on lights) Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/08-configuration-reference.md A more compact Jinja2 template for filtering entities. This example achieves the same result as the previous one by selecting 'on' lights and mapping to their entity IDs. ```yaml filter: template: "{{ states.light | selectattr('state', '==', 'on') | map(attribute='entity_id') | list | join(',') }}" ``` -------------------------------- ### Dynamic Filtering Rules Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/08-configuration-reference.md Example of using the 'filter' option to dynamically include and exclude entities based on domain and state. ```yaml filter: include: - domain: light exclude: - state: unavailable ``` -------------------------------- ### Pagination with Sorting Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/03-sorting-system.md Applies pagination to the sorted results, returning a specific subset of entities. Use 'first' to set the starting index and 'count' for the number of items. ```yaml sort: method: last_changed reverse: true first: 0 # Skip 0 items (start from beginning) count: 10 # Take only 10 items ``` -------------------------------- ### Numerical Comparison Examples Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/02-filter-system.md Quote strings containing comparison operators for numerical attribute filtering. Supports greater than/less than or equal to. ```yaml filter: include: - attributes: brightness: '>= 100' # Brightness 100 or higher battery_level: '< 20' # Battery below 20% ``` -------------------------------- ### Editor Schema Example Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/09-editor-system.md Defines the UI schema for generating form fields using Home Assistant's ha-form element. ```typescript const schema = [ { type: "grid", schema: [ { name: "card", selector: { object: {} } }, { name: "card_param", selector: { text: {} } }, { name: "card_as_row", selector: { boolean: {} } }, ] }, // ... more schema groups ]; ``` -------------------------------- ### Use templates for filtering Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/00-START-HERE.md This example demonstrates using a Jinja2 template within the filter configuration to dynamically select entities. It iterates through all 'light' states and includes their entity IDs. ```yaml filter: template: | {% for light in states.light %} {{ light.entity_id }}, {% endfor %} ``` -------------------------------- ### Append State with JS Template (Example) Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/04-rename-system.md Demonstrates appending the current state value in parentheses using a JavaScript template expression. Requires `eval_js: true`. ```yaml rename: method: friendly_name append: " (${state})" eval_js: true # "Temperature" → "Temperature (23.5)" ``` -------------------------------- ### Example Override of afterCardUpdated Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/07-card-controllers.md Demonstrates how to override the `afterCardUpdated` lifecycle hook to perform post-update logic, such as waiting for the DOM to settle and applying special styling. ```typescript async afterCardUpdated(): Promise { // Wait for the underlying card's DOM to settle await this.host.updateComplete; // Apply special styling or configuration const element = this.findInTree(this.host.card.shadowRoot, el => el.tagName === 'CUSTOM-ELEMENT'); if (element) { element.doSpecialThing(); } } ``` -------------------------------- ### Getting the Configuration Editor Element Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/01-auto-entities-card.md Retrieves the configuration editor component for the AutoEntities card, which can be appended to the DOM for visual configuration. ```typescript const editor = AutoEntities.getConfigElement(); document.body.appendChild(editor); ``` -------------------------------- ### Getting the Default Stub Configuration Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/01-auto-entities-card.md Provides a minimal default configuration object for creating a new AutoEntities card instance, including empty entities and filters. ```typescript const defaultConfig = AutoEntities.getStubConfig(); // Returns: // { // card: { type: 'entities' }, // filter: { include: [], exclude: [] } // } ``` -------------------------------- ### State extraction example Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/03-sorting-system.md Shows how the 'state' method accesses the raw state string of an entity. For translated states, the 'state_translated' method should be used. ```typescript // Raw state value (untranslated) entity.state // "on", "off", "42", etc. // For translated states, use rename instead: rename: method: state_translated ``` -------------------------------- ### Select Selector Configuration Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/09-editor-system.md Example of a 'select' type selector for dropdown choices, such as selecting a domain or device manufacturer. It includes the type, name, and options for the select element. ```typescript { type: "select", name: "domain", selector: { select: { options: [...] } } } ``` -------------------------------- ### Custom Editor Component Example Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/09-editor-system.md Illustrates how to create a custom editor component by extending `LitElement`, using decorators for properties and state, and emitting a `config-changed` event. This is the basic structure for adding new editor functionalities. ```typescript import { LitElement, html } from "lit"; import { property, state } from "lit/decorators.js"; class AutoEntitiesMyEditor extends LitElement { @property() hass: any; @property() config: any; @state() _myConfig: any; render() { return html`...`; } private configChanged() { this.dispatchEvent(new CustomEvent("config-changed", { detail: { config: this._myConfig } })); } } customElements.define("auto-entities-my-editor", AutoEntitiesMyEditor); ``` -------------------------------- ### Custom Card Controller Implementation Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/07-card-controllers.md An example of creating a custom card controller by extending `CardController`. It demonstrates overriding `afterCardUpdated` to manipulate DOM elements within the card's shadow root and includes a placeholder for cleanup logic in `dispose`. ```typescript // src/card-controllers/my-card.ts import { CardController, CardControllerHost } from "./base"; export class MyCardController extends CardController { async afterCardUpdated(): Promise { if (!this.host.card?.shadowRoot) return; // Find elements and apply fixes const elements = this.host.card.shadowRoot.querySelectorAll('[data-entity]'); elements.forEach(el => { // Apply custom logic }); } dispose(): void { // Cleanup if needed } } ``` -------------------------------- ### Evaluate JavaScript Template in Entity Config Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/06-helpers-and-utilities.md Example of using `eval_js: true` to process entity configuration with template variables like `entity_id`, `entity`, `device`, `area`, `state`, and `state_translated`. Useful for dynamic service data and options. ```yaml filter: include: - domain: light options: tap_action: action: call-service service: light.turn_on eval_js: true service_data: entity_id: "`${entity_id}`" brightness: "{{ state.attributes.brightness ?? 100 }}" ``` -------------------------------- ### Conditional Area Prefix with JS (Example) Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/04-rename-system.md Shows how to conditionally prepend the area name followed by a colon and space if the area is set, using a JavaScript template expression. Requires `eval_js: true`. ```yaml rename: method: friendly_name prepend: "${area ? area + ': ' : ''}" eval_js: true # "Kitchen" area: "Kitchen: Temperature" # No area: "Temperature" ``` -------------------------------- ### Filter entities using a Jinja2 template with entity objects Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/08-configuration-reference.md This Jinja2 template example demonstrates how to retrieve entity objects and format them. It selects entities within the 'bedroom' area and includes their device names. ```yaml filter: template: | [{% for e in area_entities("bedroom") %} {'entity': '{{e}}', 'name': 'Bedroom {{device_attr(e, "name")}}'}, {% endfor %}] ``` -------------------------------- ### Object Selector Configuration Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/09-editor-system.md Example of an 'object' type selector used for nested configurations like card options. It defines the type, name, and the selector configuration. ```typescript { type: "object", name: "card", selector: { object: {} } } ``` -------------------------------- ### Pagination (Top 10 Recently Updated) Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/08-configuration-reference.md Limit the number of displayed entities using the 'count' option in the sort configuration. This example shows the top 10 most recently updated entities. ```yaml type: custom:auto-entities card: type: entities title: Recent Changes filter: include: - {} # All entities sort: method: last_updated reverse: true count: 10 ``` -------------------------------- ### Wildcard Matching in Auto-Entities Filters Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/README.md Illustrates the use of wildcard characters ('*') for flexible string matching in entity filters. Examples show matching entity IDs, names, and device names. ```yaml entity_id: "light.*" # All lights name: "Kitchen *" # Starts with Kitchen device: "* iPhone" # Ends with iPhone ``` -------------------------------- ### Regular Expression Matching in Auto-Entities Filters Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/README.md Demonstrates using JavaScript regular expressions (enclosed in '/') for advanced pattern matching in filters. Examples include matching entity IDs and names with specific patterns. ```yaml name: "/^[Ll]ight.*$/" # Light/light prefix entity_id: "/sensor\.[a-z]+/" # sensor.xxx ``` -------------------------------- ### Get most recently updated lights, sorted by name Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/03-sorting-system.md Retrieves the top 5 most recently updated lights and then sorts them by friendly name. Combines temporal sorting with alphabetical sorting. ```yaml sort: - method: last_updated reverse: true count: 5 # Top 5 most recently updated - method: friendly_name ``` -------------------------------- ### User YAML Configuration for Auto-Entities Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/README.md Example of how a user configures the auto-entities card in their dashboard YAML. It specifies the card type and an include filter for light entities, with sorting by friendly name. ```yaml type: custom:auto-entities card: type: entities filter: include: - domain: light sort: method: friendly_name ``` -------------------------------- ### Scene Launcher Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/10-complete-examples.md Display all scenes as buttons with one-click activation using the 'scene.turn_on' service. Ideal for quick scene recall. ```yaml type: custom:auto-entities card: type: glance title: Scenes columns: 4 filter: include: - domain: scene options: tap_action: action: call-service service: scene.turn_on service_data: entity_id: this.entity_id sort: method: friendly_name ignore_case: true ``` -------------------------------- ### Numerical Comparison Filters in Auto-Entities Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/README.md Shows how to use string values with comparison operators (>, <, >=, <=) to filter entities based on numerical states or attributes. Examples include state values and battery levels. ```yaml state: ">= 100" # State >= 100 attributes: battery: "< 20" # Battery < 20% ``` -------------------------------- ### Get Home Assistant Labels Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/06-helpers-and-utilities.md Retrieves the Home Assistant label registry. The first call makes a WebSocket request; subsequent calls return cached values until invalidated. ```typescript const labels = await getLabels(hass); const label = labels['label_kitchen']; // { // label_id: 'label_kitchen', // name: 'Kitchen', // color: '#FF5722', // ... // } ``` -------------------------------- ### Time-Based Filtering in Auto-Entities Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/README.md Illustrates filtering entities based on time using the 'X ago' syntax. Examples show filtering by last updated, last changed, and last triggered times within specified durations. ```yaml last_updated: "< 15 ago" # Updated within 15 minutes last_changed: "> 2 h ago" # Changed more than 2 hours ago last_triggered: "< 1 d ago" # Triggered within 1 day ``` -------------------------------- ### Turn on scenes by clicking them Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/README.md Configures a glance card to allow users to turn on scene entities by clicking them. Uses 'tap_action' to call the 'scene.turn_on' service with the entity ID. ```yaml type: custom:auto-entities card: type: glance filter: include: - domain: scene options: tap_action: action: call-service service: scene.turn_on service_data: # Note the magic value this.entity_id here entity_id: this.entity_id ``` -------------------------------- ### CardController Registry Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/07-card-controllers.md Provides a factory function to get the appropriate card controller based on the card type. ```APIDOC ## CardController Registry ### `getCardController(type: string | undefined, host: CardControllerHost): CardController | undefined` Factory function that returns the appropriate controller for a card type. **Location:** `src/card-controllers/index.ts` **Parameters:** | Parameter | Type | Description | |-----------|------|-------------| | type | `string | undefined` | Card type (from card config) | | host | `CardControllerHost` | Host element | **Return:** `CardController | undefined` — Controller instance, or undefined for standard cards **Supported Types:** | Type | Controller | Purpose | |------|-----------|---------| | `"history-graph"` | `HistoryGraphCardController` | Handle history-graph workaround | | `"map"` | `MapCardController` | Handle map card workaround | | (others) | `undefined` | No special handling needed | **Example:** ```typescript const controller = getCardController('history-graph', this); if (controller) { await controller.afterCardUpdated(); } ``` --- ``` -------------------------------- ### getDevices Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/06-helpers-and-utilities.md Gets the Home Assistant device registry indexed by device_id. This function utilizes a window-level cache for performance, making an initial WebSocket request and returning cached values for subsequent calls until invalidated. ```APIDOC ## getDevices(hass: HassObject): Promise> ### Description Gets the Home Assistant device registry indexed by device_id. This function utilizes a window-level cache for performance, making an initial WebSocket request and returning cached values for subsequent calls until invalidated. ### Parameters #### Path Parameters - **hass** (HassObject) - Required - Home Assistant state object ### Return `Promise>` — Registry entries keyed by device_id ### Example ```typescript const devices = await getDevices(hass); const device = devices['abc123']; ``` ``` -------------------------------- ### Multi-level Sort with Pagination Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/README.md When using multi-level sorting, pagination options like 'count' are applied based on the first element in the sort array. This example shows sorting by last changed and then by friendly name, limiting to the 10 most recently changed. ```yaml sort: - method: last_changed reverse: true count: 10 # show only the 10 most recently changed - method: friendly_name ignore_case: true ``` -------------------------------- ### Media Players with Custom Actions Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/10-complete-examples.md Display media players and configure custom tap actions, such as turning them on with a single click. Useful for quick media control. ```yaml type: custom:auto-entities card: type: entities title: Media filter: include: - domain: media_player exclude: - state: unavailable sort: method: friendly_name ignore_case: true options: secondary_info: state tap_action: action: call-service service: media_player.turn_on service_data: entity_id: this.entity_id ``` -------------------------------- ### Hide Card When No Entities Match Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/08-configuration-reference.md Example of setting 'show_empty' to false to hide the card when no entities match the filter criteria. ```yaml show_empty: false # Hide card when no lights are on filter: include: - domain: light state: "on" ``` -------------------------------- ### Developer JavaScript Configuration for Auto-Entities Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/README.md Demonstrates how a developer programmatically creates and configures the auto-entities card using JavaScript. It includes setting the configuration, Home Assistant reference, and appending to the DOM. ```typescript // Create element const card = document.createElement('auto-entities'); // Set configuration card.setConfig({ card: { type: 'entities' }, filter: { include: [{ domain: 'light' }] } }); // Set Home Assistant reference card.hass = hassObject; // Add to DOM document.body.appendChild(card); ``` -------------------------------- ### Time-Based Filtering Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/10-complete-examples.md Filter entities based on time using supported units (m, h, d). Examples show 'less than' and 'more than' time ago. ```yaml # Supported units: m (minutes), h (hours), d (days) last_updated: "< 15" # 15 minutes ago last_changed: "> 2 h ago" # More than 2 hours ago last_triggered: "< 1 d ago" # Less than 1 day ago ``` -------------------------------- ### AutoEntities component main entry point Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/00-START-HERE.md This file serves as the main entry point for the AutoEntities component. Refer to the documentation for detailed usage. ```typescript src/main.ts ← AutoEntities component ``` -------------------------------- ### Show all lights that are currently on Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/README.md Displays a glance card listing all lights that are in the 'on' state. Includes a toggle action for each light. Note that 'on' and 'off' states must be quoted in YAML. ```yaml type: custom:auto-entities show_empty: false card: type: glance title: Lights on filter: include: - domain: light state: "on" # Remember that "on" and "off" are magic in yaml, and must always be quoted options: tap_action: action: toggle ``` -------------------------------- ### Show all lights sorted by name Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/00-START-HERE.md This snippet demonstrates how to display all entities of the 'light' domain, sorted alphabetically by their friendly name. It uses the 'entities' card type and specifies a sorting method. ```yaml type: custom:auto-entities card: type: entities title: Lights filter: include: - domain: light sort: method: friendly_name ``` -------------------------------- ### Boolean Selector Configuration Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/09-editor-system.md Example of a 'boolean' type selector, typically used for toggle switches. It defines the type, name, and the boolean selector. ```typescript { type: "boolean", name: "reverse", selector: { boolean: {} } } ``` -------------------------------- ### File Organization Overview Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/INDEX.md This snippet outlines the file structure of the Auto-Entities project, indicating the purpose and approximate size of each documentation file. ```text /workspace/home/output/ ├── README.md (11 KB) Main entry point ├── INDEX.md (this file) ├── 01-auto-entities-card.md (7.6 KB) Component class ├── 02-filter-system.md (9.3 KB) Filtering rules ├── 03-sorting-system.md (7.9 KB) Sorting logic ├── 04-rename-system.md (9.5 KB) Renaming logic ├── 05-types-and-interfaces.md (12 KB) Type definitions ├── 06-helpers-and-utilities.md (13 KB) Support functions ├── 07-card-controllers.md (8.1 KB) Card integration ├── 08-configuration-reference.md (12 KB) YAML reference ├── 09-editor-system.md (9.6 KB) Visual editor └── 10-complete-examples.md (12 KB) Real examples Total: 12 files, 132+ KB of comprehensive documentation ``` -------------------------------- ### Object Attribute Filtering Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/README.md Access nested values within object attributes using colon-separated keys or indexes. This example filters lights by their saturation value. ```yaml filter: include: - attributes: hs_color:1: ">30" ``` -------------------------------- ### Recommended Implementation of dispose Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/07-card-controllers.md Provides a recommended implementation for the `dispose` method, which is crucial for cleaning up resources like subscriptions, timers, and event listeners when the controller is no longer needed. ```typescript dispose(): void { // Clean up subscriptions, timers, event listeners, etc. if (this.subscription) { this.subscription.unsubscribe(); } if (this.updateTimer) { clearInterval(this.updateTimer); } } ``` -------------------------------- ### Template-Based Custom Names Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/08-configuration-reference.md Generate entity names dynamically using Jinja2 templates. This example iterates through entities in a specified area and assigns custom names. ```yaml type: custom:auto-entities card: type: entities title: Bedrooms filter: template: | [{% for e in area_entities("master_bedroom") %} { 'entity': '{{e}}', 'name': '{{ device_attr(e, "name") | default(state_attr(e, "friendly_name")) }}' }, {% endfor %}] ``` -------------------------------- ### MDI Icon Selector Configuration Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/_autodocs/09-editor-system.md Example of a 'select' type selector specifically for choosing Material Design Icons (MDI). It uses the 'mdi' selector type. ```typescript { type: "select", name: "icon", selector: { mdi: {} } } ``` -------------------------------- ### Basic Auto-Entities Card Configuration Source: https://github.com/lint-free-technology/lovelace-auto-entities/blob/master/README.md This is a basic configuration for the auto-entities card. It shows how to specify the card type, the card to populate, and a list of entities. It also demonstrates the use of filters for including and excluding entities. ```yaml type: custom:auto-entities card: card_param: entities: - - filter: template: