thomasloven / lovelace-auto-entities

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

FR: allow entity_id for numeric state trigger #242

Closed Mariusthvdb closed 2 years ago

Mariusthvdb commented 2 years ago

please consider allowing a config like:

        filter:
          include:
            - entity_id: sensor.*_actueel
              state: '> input_number.power_threshold' # or states('input_number.power_threshold')

which would prevent some more complex templating (including iterating over all states.sensor.), like:

        filter:
          template: >
            {% set threshold = states('input_number.power_threshold')|float %}
            {% set ns = namespace(above_threshold=[]) %}
            {% for s in states.sensor
             |selectattr('entity_id', 'search', '_actueel')
             if s.state|float > threshold %}
            {% set ns.above_threshold = ns.above_threshold + [s.entity_id] %}
            {% endfor %}
            {{ns.above_threshold}}

https://www.home-assistant.io/docs/automation/trigger/#numeric-state-trigger allow us to do that since some time, would be great if auto-entities could follow suit in that regard.

thomasloven commented 2 years ago

Templates are very heavy lifting for the frontend. That's why there's only a single template filter which will have to do everything.

Mariusthvdb commented 2 years ago

maybe I didnt phrase correctly, but I didnt mean to ask for templating, I was thinking to these numeric triggers:

automation:
  trigger:
    - platform: numeric_state
      entity_id: sensor.temperature

to be used as:

        filter:
          include:
            - state: '> input_number.power_threshold'

bw, I am seeing a lot of:

Unhandled Promise Rejection: TypeError: t.startsWith is not a function. (In 't.startsWith("$$")', 't.startsWith' is undefined)
Schermafbeelding 2022-02-20 om 17 03 19

and I havent found a specific card yet, because it throws on many views....

as simple as:

  - type: custom:auto-entities
    card:
      type: entities
      title: Hue groups
      show_header_toggle: false
    show_empty: false
    filter:
      include:
        - attributes:
            is_hue_group: true

yep thats is, all config with attributes are erroring:

      exclude:
        - attributes:
            last_triggered: null

or

          not:
            attributes:
              current: 0