#Using auto-entities to replicate card_mod

1 messages · Page 1 of 1 (latest)

real wing
#

So I was able to get this to work with auto entities for the most part. I did run into an issue (which I'll mention in a moment).

#
type: custom:auto-entities
card:
  type: entities
  title: Motion Detector Batteries
filter:
  include:
    - entity_id: 'sensor.*_motion_detector_battery_level'
      options:
        card_mod:
          style:
            hui-generic-entity-row $: |
              .state {
                color: 
                  {% set s = states(config.entity) | int(0) %}
                  {% if(s >= 80) %} green
                  {% elif(s >= 60) %} yellowgreen
                  {% elif(s >= 40) %} yellow
                  {% elif(s >= 20) %} darkorange
                  {% elif(s >= 0) %} red
                  {% else %} inherit
                  {% endif %}
                }
  exclude: 
    - state: "unavailable"
    - hidden_by: "user"
sort:
  method: state
  numeric: true
  reverse: true```
#

The problem I ran into was if I tried to use a list of entity_ids, the options section would only work on the last entity. I just used a wildcard with the entity_id, but there are a lot of options that you can use to show just the entities that you want. Looking at the docs, if you just want to feed the card a list of, say, 6 entities, I think the template: method would probably work best. I just don't know enough about trying to write a template to get that to work. #templates-archived would be a better place to ask. Look at the two examples at the bottom of the doc.