Skip to content

Animation System

Quick Start

Triggering Animations with Rules

yaml
rules:
  - id: high_temp_alert
    when:
      entity: sensor.cpu_temp
      above: 75
    apply:
      animations:
        - tag: temp_widgets
          preset: alert_pulse
          loop: true

Simple Entity Change Animation

yaml
overlays:
  - id: light_icon
    animations:
      - trigger: on_entity_change
        entity: light.bedroom
        to_state: "on"
        preset: glow
        duration: 500

Using Datasource Processors

yaml
data_sources:
  temp_sensor:
    entity_id: sensor.temperature
    processors:
      - type: unit_conversion
        key: celsius
        from_unit: fahrenheit
        to_unit: celsius

overlays:
  - id: temp_display
    text: "{ds:temp_sensor.celsius:.1f}°C"

Animation System Architecture

The LCARdS animation system consists of several integrated components:

┌─────────────────────────────────────────────────────────────┐
│                     Animation Triggering                     │
├─────────────────────┬───────────────────┬───────────────────┤
│   RulesEngine       │  TriggerManager   │  ActionHelpers    │
│ (Complex Conditions)│ (Entity Changes)  │ (User Interactions)│
└──────────┬──────────┴─────────┬─────────┴──────────┬────────┘
           │                    │                    │
           └────────────────────┼────────────────────┘

                       ┌────────▼─────────┐
                       │ AnimationManager │
                       │  - playAnimation │
                       │  - stopAnimations│
                       │  - Scope mgmt    │
                       └────────┬─────────┘

                    ┌───────────┴────────────┐
                    │                        │
           ┌────────▼──────────┐   ┌────────▼─────────┐
           │ AnimationRegistry │   │  anime.js v4     │
           │ (Preset Caching)  │   │ (Execution)      │
           └───────────────────┘   └──────────────────┘

Component Responsibilities

  • RulesEngine: Evaluates complex conditions and triggers animations on rule match/unmatch
  • TriggerManager: Manages overlay-specific animation triggers (on_entity_change, on_datasource_change)
  • ActionHelpers: Handles interactive triggers (on_tap, on_hover, on_hold, on_double_tap)
  • AnimationManager: Central orchestrator for animation execution and lifecycle
  • AnimationRegistry: Caches animation instances for performance
  • anime.js v4: Low-level animation execution engine

Trigger Types

TriggerHandlerScopeUse Case
on_loadTriggerManagerSingle overlayInitial render animations
on_tapActionHelpersSingle overlayUser tap interactions
on_holdActionHelpersSingle overlayUser hold interactions
on_hoverActionHelpersSingle overlayMouse hover effects
on_double_tapActionHelpersSingle overlayDouble-tap actions
on_entity_changeTriggerManagerSingle overlaySimple state reactions
on_datasource_changeAnimationManagerSingle overlayDatasource value changes
Rule-basedRulesEngineMulti-overlayComplex conditions, cross-card

Feature Comparison

Rule-Based vs Entity Change

FeatureRule-BasedEntity Change
ConfigurationIn rules arrayIn overlay.animations
TargetingMulti-overlay (tag, type, ID, pattern)Single overlay (implicit)
ConditionsFull RulesEngine logicState transitions only
Auto-stopYes (on unmatch)No
Cross-cardYesNo
Best forComplex logic, coordinationSimple reactions

Debugging

Enable debug logging to see animation execution:

javascript
window.lcards.setGlobalLogLevel('debug');

Look for key log messages:

  • [RulesEngine] 🎬 Executing N animation(s) for rule: X
  • [RulesEngine] 🛑 Stopping animations for rule: X
  • [TriggerManager] 🎬 Triggering animation for overlay on entity change
  • [AnimationManager] 📊 Datasource change: X

See Also