thomasloven / lovelace-auto-entities

🔹Automatically populate the entities-list of lovelace cards
MIT License
1.19k stars 111 forks source link

FR: add entity_id to numeric state filter #399

Open Mariusthvdb opened 7 months ago

Mariusthvdb commented 7 months ago

so we can do:

      - type: custom:auto-entities
        card:
          type: entities
          card_mod: *mod
        filter:
          include:
            - entity_id: sensor.*_actueel
            - state: < input_number.power_threshold

aware we can do template filters, but for those, the card_mod stylings are near impossible...

adding a simple numeric state_filter would greatly facilitate a scenario like above, and allow for very dynamic configurations, and at the same time be able to use card_mod.

      - type: custom:auto-entities
        card:
          type: entities
          card_mod: *mod
        filter:
          include:
            - entity_id: sensor.*_actueel
              options:
                card_mod:
                  style: |
                    :host {
                        --paper-item-icon-color: {% set state = states(config.entity)|int(-5) %}
                            {% if state == 'unknown'%} gray
                            {% elif state > 2000 %} purple
                            {% elif state > 1000 %} maroon
                            {% elif state > 450 %} darkred
                            {% elif state > 300 %} firebrick
                            {% elif state > 0 %} gold
                            {% else %} var(--no-power-color)
                            {% endif %}
                    }
          exclude:
            - state: > input_number.power_threshold
Quentame commented 2 months ago

As done in the entity-filter badge and card, and conditional card, by ... myself 😅 Check https://github.com/home-assistant/frontend/pull/19182

It was released in 2024.4.0, but not present in the release note 😞