🔹 Auto-entities - Automatically fill cards with entities

a yes, I forgot about that.
Ive managed to get it to work (and only did so because of the white stripping , without the {%- and others this wont work… )

next challenge is to build the button-card with its templates:

                  type: custom:button-card
                  aspect_ratio: 1/1
                  template:
                    - support_custom_ui
                    - styles_name_left
                    - styles_card
                    - styles_cf_notification
                    - styles_img_cell
                    - plot
                    - support_custom_ui_notification_border
                  styles:
                    card:
                      - background-color: var(--card-background-color)
                      - color: var(--primary-color)
                  custom_fields:
                    notification: >
                      [[[ return entity.state + 'W'; ]]]

adding only 1 template like

'template':'support_custom_ui' there is ok, but trying the list like:

                'template':
                  {'- support_custom_ui',
                   '- styles_name_left',
                   '- styles_card',
                   '- styles_cf_notification',
                   '- styles_img_cell',
                   '- plot',
                   '- support_custom_ui_notification_border'
                  }

doesnt work, same for the final styles: or custom_fields:… this is really tough in an auto-entities templates config.

threw all of these in an extra template:

custom_ui_hack_for_button_card_template:
  template:
    - support_custom_ui
    - styles_name_left
    - styles_card
    - styles_cf_notification
    - styles_img_cell
    - plot
    - support_custom_ui_notification_border
  styles:
    card:
      - background-color: var(--card-background-color)
      - color: var(--primary-color)

and that works ok :wink: now how to get the notification in the button-card. Tried to throw that in the same hack template:

custom_ui_hack_for_button_card_template:
  aspect_ratio: 1/1
  template:
    - support_custom_ui
    - styles_name_left
    - styles_card
    - styles_cf_notification
    - styles_img_cell
    - plot
    - support_custom_ui_notification_border
  styles:
    card:
      - background-color: var(--card-background-color)
      - color: var(--primary-color)
  custom_fields:
    notification: >
      [[[ var unit = (entity.entity_id.includes('_actueel')) ? ' W' : ' %';
          return entity.state + unit; ]]]

et voilá:

advantage over the config-template-card: it auto-updates immediately (albeit in all the buttons for any change, so it might even be a bit much…

lesson learned: if you need a button in an auto-entities template, create a dedicated template with the full button-config to make life easier :wink:

thanks Ildar

2 Likes

Hi,

I use auto-entites card, and I have a little problem. My card works fine, with this code:

type: custom:auto-entities
card:
  type: custom:layout-card
  layout_type: horizontal
  layout_options:
    width: 100
filter:
  include:
    - domain: switch
      options:
        type: custom:button-card
        entity_id: this.entity_id
        layout: vertical
        lock:
          enabled: true
        hold_action:
          action: more-info
        show_last_changed: true
        aspect_ratio: 1/1
        custom_fields:
          type_icon: >
            [[[  if ('this.entity_id' == 'switch.sonoff_100109c76c_1')
              return `<ha-icon
                icon="mdi:lightbulb"
                style="width: 25px; height: 25px; color: red;">
                `
            else if ('this.entity_id' == 'switch.sonoff_1000f46826_1')
              return `<ha-icon
                icon="mdi:fan"
                style="width: 25px; height: 25px; color: red;">
                `
            else if ('this.entity_id' == 'switch.sonoff_1000f46826_2')
               return `<ha-icon
                icon="mdi:fan"
                style="width: 25px; height: 25px; color: red;">
                `
            else if ('this.entity_id' == 'switch.sonoff_100109c76c_2')
              return `<ha-icon
                icon="mdi:lightbulb"
                style="width: 25px; height: 25px; color: red;">
                `
            else if ('this.entity_id' == 'switch.shelly1_b8b7bc_relay_0')
              return `<ha-icon
                icon="mdi:fan"
                style="width: 25px; height: 25px; color: red;">
                `
            else if ('this.entity_id' == 'switch.shellyplug_s_eee310')
              return `<ha-icon
                icon="mdi:lightbulb"
                style="width: 25px; height: 25px; color: red;">
                `
            else if ('this.entity_id' == 'switch.shellyplug_s_ea693e' &&
            states['input_boolean.teraszfan_decorationlight'].state == "on")
              return `<ha-icon
                icon="mdi:lightbulb"
                style="width: 25px; height: 25px; color: red;">
                `
            else if ('this.entity_id' == 'switch.shellyplug_s_ea693e' &&
            states['input_boolean.teraszfan_decorationlight'].state == "off")
              return `<ha-icon
                icon="mdi:fan"
                style="width: 25px; height: 25px; color: red;">
                `
            return `<ha-icon
                icon="mdi:toggle-switch"
                style="width: 25px; height: 25px; color: red;">
                `
            ]]]
          timer:
            card:
              type: custom:button-card
              name: Timer
              entity: |
                [[[
                  if ('this.entity_id' == 'switch.sonoff_1000f46826_1')
                    return "timer.toilett_fan";
                  else if ('this.entity_id' == 'switch.sonoff_1000f46826_2')
                    return "timer.bathroom_fan";
                  else if ('this.entity_id' == 'switch.sonoff_100109c76c_2')
                    return "timer.chalet_fan";
                  else if ('this.entity_id' == 'switch.shelly1_b8b7bc_relay_0')
                    return "timer.kitchen_fan";
                  else if ('this.entity_id' == 'switch.sonoff_10005b6113_1')
                    return "timer.irrigation_zone1_timer";
                  else if ('this.entity_id' == 'switch.sonoff_10005b6113_2')
                    return "timer.irrigation_zone2_timer";
                  else if ('this.entity_id' == 'switch.sonoff_10005b6113_3')
                    return "timer.irrigation_zone3_timer";
                  else if ('this.entity_id' == 'switch.sonoff_10005b6113_4')
                    return "timer.irrigation_zone4_timer";
                  else if ('this.entity_id' == 'switch.shelly1pm_e8db84d43d0f')
                    return "timer.bojler";
                  else if ('this.entity_id' == 'switch.shellyplug_s_ea693e' && states['input_boolean.teraszfan_decorationlight'].state == "off")
                    return "timer.terasz_fan";
                  return "null"; 
                ]]] 
              show_name: false
              show_icon: false
              show_state: true
              styles:
                card:
                  - font-size: 12px
              style: |
                .t { padding: 0px; }
                .flex { padding: 0px; }
        icon: |
          [[[
            if ('this.entity_id' == 'switch.sonoff_100109c76c_1')
              return "mdi:home-floor-1";
            else if ('this.entity_id' == 'switch.sonoff_1000f46826_1')
              return "mdi:toilet";
            else if ('this.entity_id' == 'switch.sonoff_1000f46826_2')
              return "mdi:shower";
            else if ('this.entity_id' == 'switch.sonoff_100109c76c_2')
              return "mdi:home-outline";
            else if ('this.entity_id' == 'switch.shelly1_b8b7bc_relay_0')
              return "mdi:weather-windy";
            else if ('this.entity_id' == 'switch.sonoff_1000f46826_3')
              return "mdi:water-pump";
            else if ('this.entity_id' == 'switch.sonoff_1000f46826_4')
              return "mdi:speaker";
            else if ('this.entity_id' == 'switch.sonoff_10005b6113_1')
              return "mdi:engine";
            else if ('this.entity_id' == 'switch.sonoff_10005b6113_2')
              return "mdi:engine";
            else if ('this.entity_id' == 'switch.sonoff_10005b6113_3')
              return "mdi:engine";
            else if ('this.entity_id' == 'switch.sonoff_10005b6113_4')
              return "mdi:engine";
            else if ('this.entity_id' == 'switch.shelly1pm_e8db84d43d0f')
              return "mdi:water-boiler";
            else if ('this.entity_id' == 'switch.shellyplug_s_eee310')
              return "mdi:pine-tree";
            else if ('this.entity_id' == 'switch.shellyplug_s_ea693e' && states['input_boolean.teraszfan_decorationlight'].state == "off")
              return "mdi:wind-turbine";
            else if ('this.entity_id' == 'switch.shellyplug_s_ea693e' && states['input_boolean.teraszfan_decorationlight'].state == "on")
              return "mdi:string-lights";
            return "mdi:toggle-switch"; 
          ]]] 
        styles:
          custom_fields:
            timer:
              - color: gray
              - font-size: 15px
              - position: absolute
              - left: 25%
              - top: 8%
            type_icon:
              - color: gray
              - font-size: 15px
              - position: absolute
              - left: 5%
              - top: 5%
          card:
            - box-shadow: 0px 0px 10px 1px var(--button-card-light-color)
          icon:
            - width: 40%
            - padding-top: 20px
          label:
            - color: gray
            - font-size: 10px
            - justify-self: start
            - padding-left: 10px
            - padding-top: 0px
          name:
            - font-weight: bold
            - padding-left: 0px
            - font-size: 12px
            - white-space: normal
        tap_action:
          action: toggle
  exclude:
    - entity_id: switch.bfa6a6a67d0322660d3ncb
    - entity_id: switch.bf091a9060db59254e78h7
    - entity_id: switch.bojler_1
    - entity_id: switch.viz_1
    - entity_id: switch.bojler_socket
    - entity_id: light.deerma_jsq5_d52a_indicator_light
    - entity_id: switch.viz_switch_1
    - entity_id: light.nappalitablet
    - entity_id: light.browser_cd5c8c62_98c23c4a
    - entity_id: switch.0x588e81fffee4b266_firmware_lock
    - entity_id: light.deerma_jsq5_94af_indicator_light
    - entity_id: '*browser*'
    - entity_id: '*switch.kejszijo*'
    - entity_id: '*mikrotik*'
    - entity_id: '*coil*'
    - state: 'off'
    - state: '0'
    - state: unavailable
    - state: docked
sort:
  method: none
  reverse: false
  numeric: false
show_empty: false
view_layout:
  column: 1

image

But, if I use with browser_mod pop up card, the custom_fields note working:

tap_action:
  action: fire-dom-event
  browser_mod:
    command: popup
    service_data: null
    card:
      type: custom:auto-entities
      card:
        type: custom:layout-card
        layout_type: horizontal
        layout_options:
          width: 100
      filter:
        include:
          - domain: switch
            options:
              type: custom:button-card
              entity_id: this.entity_id
              layout: vertical
              lock:
                enabled: true
              hold_action:
                action: more-info
              show_last_changed: true
              aspect_ratio: 1/1
              custom_fields:
                type_icon: >
                  [[[  if ('this.entity_id' == 'switch.sonoff_100109c76c_1')
                    return `<ha-icon
                      icon="mdi:lightbulb"
                      style="width: 25px; height: 25px; color: red;">
                      `
                  else if ('this.entity_id' == 'switch.sonoff_1000f46826_1')
                    return `<ha-icon
                      icon="mdi:fan"
                      style="width: 25px; height: 25px; color: red;">
                      `
                  else if ('this.entity_id' == 'switch.sonoff_1000f46826_2')
                     return `<ha-icon
                      icon="mdi:fan"
                      style="width: 25px; height: 25px; color: red;">
                      `
                  else if ('this.entity_id' == 'switch.sonoff_100109c76c_2')
                    return `<ha-icon
                      icon="mdi:lightbulb"
                      style="width: 25px; height: 25px; color: red;">
                      `
                  else if ('this.entity_id' == 'switch.shelly1_b8b7bc_relay_0')
                    return `<ha-icon
                      icon="mdi:fan"
                      style="width: 25px; height: 25px; color: red;">
                      `
                  else if ('this.entity_id' == 'switch.shellyplug_s_eee310')
                    return `<ha-icon
                      icon="mdi:lightbulb"
                      style="width: 25px; height: 25px; color: red;">
                      `
                  else if ('this.entity_id' == 'switch.shellyplug_s_ea693e' &&
                  states['input_boolean.teraszfan_decorationlight'].state == "on")
                    return `<ha-icon
                      icon="mdi:lightbulb"
                      style="width: 25px; height: 25px; color: red;">
                      `
                  else if ('this.entity_id' == 'switch.shellyplug_s_ea693e' &&
                  states['input_boolean.teraszfan_decorationlight'].state == "off")
                    return `<ha-icon
                      icon="mdi:fan"
                      style="width: 25px; height: 25px; color: red;">
                      `
                  return `<ha-icon
                      icon="mdi:toggle-switch"
                      style="width: 25px; height: 25px; color: red;">
                      `
                  ]]]
                timer:
                  card:
                    type: custom:button-card
                    name: Timer
                    entity: |
                      [[[
                        if ('this.entity_id' == 'switch.sonoff_1000f46826_1')
                          return "timer.toilett_fan";
                        else if ('this.entity_id' == 'switch.sonoff_1000f46826_2')
                          return "timer.bathroom_fan";
                        else if ('this.entity_id' == 'switch.sonoff_100109c76c_2')
                          return "timer.chalet_fan";
                        else if ('this.entity_id' == 'switch.shelly1_b8b7bc_relay_0')
                          return "timer.kitchen_fan";
                        else if ('this.entity_id' == 'switch.sonoff_10005b6113_1')
                          return "timer.irrigation_zone1_timer";
                        else if ('this.entity_id' == 'switch.sonoff_10005b6113_2')
                          return "timer.irrigation_zone2_timer";
                        else if ('this.entity_id' == 'switch.sonoff_10005b6113_3')
                          return "timer.irrigation_zone3_timer";
                        else if ('this.entity_id' == 'switch.sonoff_10005b6113_4')
                          return "timer.irrigation_zone4_timer";
                        else if ('this.entity_id' == 'switch.shelly1pm_e8db84d43d0f')
                          return "timer.bojler";
                        else if ('this.entity_id' == 'switch.shellyplug_s_ea693e' && states['input_boolean.teraszfan_decorationlight'].state == "off")
                          return "timer.terasz_fan";
                        return "null"; 
                      ]]] 
                    show_name: false
                    show_icon: false
                    show_state: true
                    styles:
                      card:
                        - font-size: 12px
                    style: |
                      .t { padding: 0px; }
                      .flex { padding: 0px; }
              icon: |
                [[[
                  if ('this.entity_id' == 'switch.sonoff_100109c76c_1')
                    return "mdi:home-floor-1";
                  else if ('this.entity_id' == 'switch.sonoff_1000f46826_1')
                    return "mdi:toilet";
                  else if ('this.entity_id' == 'switch.sonoff_1000f46826_2')
                    return "mdi:shower";
                  else if ('this.entity_id' == 'switch.sonoff_100109c76c_2')
                    return "mdi:home-outline";
                  else if ('this.entity_id' == 'switch.shelly1_b8b7bc_relay_0')
                    return "mdi:weather-windy";
                  else if ('this.entity_id' == 'switch.sonoff_1000f46826_3')
                    return "mdi:water-pump";
                  else if ('this.entity_id' == 'switch.sonoff_1000f46826_4')
                    return "mdi:speaker";
                  else if ('this.entity_id' == 'switch.sonoff_10005b6113_1')
                    return "mdi:engine";
                  else if ('this.entity_id' == 'switch.sonoff_10005b6113_2')
                    return "mdi:engine";
                  else if ('this.entity_id' == 'switch.sonoff_10005b6113_3')
                    return "mdi:engine";
                  else if ('this.entity_id' == 'switch.sonoff_10005b6113_4')
                    return "mdi:engine";
                  else if ('this.entity_id' == 'switch.shelly1pm_e8db84d43d0f')
                    return "mdi:water-boiler";
                  else if ('this.entity_id' == 'switch.shellyplug_s_eee310')
                    return "mdi:pine-tree";
                  else if ('this.entity_id' == 'switch.shellyplug_s_ea693e' && states['input_boolean.teraszfan_decorationlight'].state == "off")
                    return "mdi:wind-turbine";
                  else if ('this.entity_id' == 'switch.shellyplug_s_ea693e' && states['input_boolean.teraszfan_decorationlight'].state == "on")
                    return "mdi:string-lights";
                  return "mdi:toggle-switch"; 
                ]]] 
              styles:
                custom_fields:
                  timer:
                    - color: gray
                    - font-size: 15px
                    - position: absolute
                    - left: 25%
                    - top: 8%
                  type_icon:
                    - color: gray
                    - font-size: 15px
                    - position: absolute
                    - left: 5%
                    - top: 5%
                card:
                  - box-shadow: 0px 0px 10px 1px var(--button-card-light-color)
                icon:
                  - width: 40%
                  - padding-top: 20px
                label:
                  - color: gray
                  - font-size: 10px
                  - justify-self: start
                  - padding-left: 10px
                  - padding-top: 0px
                name:
                  - font-weight: bold
                  - padding-left: 0px
                  - font-size: 12px
                  - white-space: normal
              tap_action:
                action: toggle
        exclude:
          - entity_id: switch.bfa6a6a67d0322660d3ncb
          - entity_id: switch.bf091a9060db59254e78h7
          - entity_id: switch.bojler_1
          - entity_id: switch.viz_1
          - entity_id: switch.bojler_socket
          - entity_id: light.deerma_jsq5_d52a_indicator_light
          - entity_id: switch.viz_switch_1
          - entity_id: light.nappalitablet
          - entity_id: light.browser_cd5c8c62_98c23c4a
          - entity_id: switch.0x588e81fffee4b266_firmware_lock
          - entity_id: light.deerma_jsq5_94af_indicator_light
          - entity_id: '*browser*'
          - entity_id: '*switch.kejszijo*'
          - entity_id: '*mikrotik*'
          - entity_id: '*coil*'
          - state: 'off'
          - state: '0'
          - state: unavailable
          - state: docked
      sort:
        method: none
        reverse: false
        numeric: false
      show_empty: false
      view_layout:
        column: 1

    deviceID:
      - this
      - dashboard
    large: false
    title: Aktív fogyasztók

image

Any idea what is problem with my code? :woozy_face:

Thanks!

If you re-open the popup, does the custom_field work then? So if you press the button and the icon should turn into lightbulb, then close popup, then open again. If it’s changed, then this is due to browser_mod. It doesn’t update the icon when in a popup.

See: 🔹 Browser_mod - turn your browser into a controllable device, and a media_player - #1240 by ASNNetworks

Hi
I am trying to set this up to show my Steams games when they are on sale, which I have working, however I would like to see the normal price and the sale price, but I cannot seem to get it working.

I have gone through this thread and tried to format the code but I am obviously not getting it.

type: custom:auto-entities
show_empty: false
card:
  title: Steam Wishlist On Sale
  type: entities
filter:
  include:
    - entity_id: binary_sensor.steam_wishlist_*
  attributes:
    - sale_price: null
  options:
    type: custom:multiple-entity-row
    toggle: true
    secondary_info: normal_price
    primary:
      entity: this.entity_id
      attribute: sale_price
      name: SP
  exclude:
    - state: 'False'

but my display is

image

I would appreciate any advice :slight_smile:

thank you

There is no such an option in multiple-entity-row.

No, it isn’t update. I try many times open/close. I try turn off the light from the list…no update.
It does not execute functions like this:

icon: |
          [[[
            if ('this.entity_id' == 'switch.sonoff_100109c76c_1')
              return "mdi:home-floor-1";
            else if ('this.entity_id' == 'switch.sonoff_1000f46826_1')
              return "mdi:toilet";
return "mdi:toggle-switch"; 
                ]]]

Love this card, but is it possible to place a divider between the entities?

type: custom:auto-entities
card:
  type: entities
filter:
  template: |-
    {% for s in states.switch -%}
      {{
        {
          'entity': s.entity_id,
          'secondary_info': 'last-changed'
        }
      }},{%- if not loop.last -%}{{
        {
          'type': 'section'
        }
      }},
      {%- endif -%}
    {%- endfor %}

image

4 Likes

Thanks, this works, until you use sort on a attribute. It place all dividers at the bottom of the card. How do you exclude a dvivider?

You cannot exclude a divider - unless you specify a sort inside the template.

1 Like

To solve my own question, fixed it wuthin the template code like @Ildar_Gabdullin said, thanks!
Here’s the code original code;

      - type: custom:auto-entities
        card:
          type: entities
        filter:
          include:
            - entity_id: "sensor.nl_trash_*"
              options:
                type: custom:multiple-entity-row
                secondary_info:
                  attribute: remaining
        sort:
          method: attribute
          attribute: remaining_int
          numeric: true

And using template with a divider;

      - type: custom:auto-entities
        card:
          type: entities
        filter:
          template: |-
            {% set trash = [
              states.sensor.nl_trash_gft,
              states.sensor.nl_trash_paper,
              states.sensor.nl_trash_pmd,
              states.sensor.nl_trash_residual] | sort(attribute='attributes.remaining_int') %}
            {%- for t in trash -%}
              {{
                {
                  'type': 'custom:multiple-entity-row',
                  'entity': t.entity_id,
                  'secondary_info': t.attributes.remaining
                }
              }},{%- if not loop.last -%}{{
                {
                  'type': 'divider'
                }
              }},
              {%- endif -%}
            {%- endfor %}

Looks like it can’t handle “this.entity_id”.

Is it possible to use auto entities card to sort out devices created by a specific integration?

In Home Assistant, under Integrations, I can view all devices controlled by a specific integration (“Filtering by integration”).

I would like to do this in using a auto entities-card but I don’t know what filter to use? Is it even possible?

I have an (iOS) device integrated by the official HA Companion app. It provides a battery state sensor storing the Low Power Mode in an attribute.

I want auto-entities to show all entities with state Low Power Mode: true. Unfortunately, auto-entities seems to not being able to handle the “not so precise” naming of this attribute.

E. g. this is working for the default attribute within a normal entities card:

      - type: attribute
        entity: sensor.phone_battery_state
        attribute: 'Low Power Mode'

But with auto-entities nothing is displayed. Doesn’t matter how I write the Low Power Mode. Bug or am I using it wrong?

type: custom:auto-entities
card:
  type: entities
  title: Power Saving Mode
  state_color: true
  show_header_toggle: false
entities: []
filter:
  include:
    - domain: sensor
      attributes:
        device_class: battery
        'Low Power Mode': true
      options:
        secondary_info: last-updated
  exclude: null
show_empty: false
unique: true
sort:
  method: last_changed
  reverse: true

This is what dev tools gives me, so YES, the naming of that attribute is just horrible.

Low Power Mode: true
device_class: battery
icon: mdi:battery-40
friendly_name: Phone Battery State

Any ideas?
(How) Can auto-entities handle “not well formatted” attributes?

    type: custom:auto-entities
    card:
      type: entities
      title: Integration
    unique: true
    show_empty: true
    filter:
      template: '{{integration_entities("kodi") }}'
    sort:
      method: name

изображение

1 Like

I do not see this attribute in this sensor:

изображение

As for “Low Power Mode” attribute.
In my experience, if some attribute is displayed as “Xxx Yyy Zzz”, that means that it’s actual name is “xxx_yyy_zzz”.
But this particular “Mobile App” integration is smth strange…
Check these templates:

That means that you may address this attribute only by using the "Xxx Yyy Zzz" name.
Try using this template (just replace “false” with “true”):

filter:
  template: >-
    {% for sensor in integration_entities("mobile_app") -%}
    {%- if is_state_attr(sensor,"Low Power Mode",false) -%}
    {{sensor}},
    {%- endif -%}
    {%- endfor %}

изображение

I tried using “selectattr” filter - does not work:

    {{states | selectattr('attributes["Low Power Mode"]', 'eq', false) |
    map(attribute='entity_id') | list }}
    {{states | selectattr('attributes.low_power_mode', 'eq', false) |
    map(attribute='entity_id') | list }}

I asked a question about using the “selectattr” filter, you may follow that thread if you like.

trying to fighter compress the yaml, it would be nice if I could replace this filter:

          filter:
            include:
              - entity_id: '*.[[id]]_*'
            exclude:
              - entity_id: 'switch.[[id]]'
              - entity_id: 'sensor.[[id]]_actueel'
              - entity_id: 'sensor.[[id]]_totaal'
              - entity_id: '*daily'
              - entity_id: '*daystart'
              - entity_id: '*power'
              - entity_id: '*energy'
              - entity_id: '*door*'
              - entity_id: '*battery*'

with a regex search for the wild card strings GitHub - thomasloven/lovelace-auto-entities: 🔹Automatically populate the entities-list of lovelace cards

          filter:
            include:
              - entity_id: '*.[[id]]_*'
            exclude:
              - entity_id: 'switch.[[id]]'
              - entity_id: 'sensor.[[id]]_actueel'
              - entity_id: 'sensor.[[id]]_totaal'
              - entity_id: '/^(daily|daystart|power|energy|door|battery$/'

I tried this, but upon refreshing my system went down ;-)…

please could anyone help me out finding the correct syntax?

update
wait, this seems to work nicely:

            exclude:
              - entity_id: 'switch.[[id]]'
#              - entity_id: 'sensor.[[id]]_actueel'
#              - entity_id: 'sensor.[[id]]_totaal'
#              - entity_id: '*daily'
#              - entity_id: '*daystart'
#              - entity_id: '*power'
#              - entity_id: '*energy'
#              - entity_id: '*door*'
#              - entity_id: '*battery*'
              - entity_id: '/(actueel|totaal|daily|day|power|energy|door|battery|position|afstand)/'

only doesnt filter out things like showing ‘cv stookhok’ in search ‘stookhok’…

adding - entity_id: '*.cv_[[id]]*' somehow fixes ist, even on cv_stookhok entities . huh?

You’re right the device_class: battery was a custom setting, nothing the integration seems to provide as default.

Your template worked :+1: But:

  • basically I try to avoid using templates whereever possible
  • the state shown is the state of the entity, not the one of the attribute.

This is desired output (the entity name does not matter):
grafik

…achieved by entities card default attribute:

      - type: attribute
        entity: sensor.phone_battery_state
        attribute: Low Power Mode
        name: Energiesmarmodus

This is what I get in auto-entities using the template:
grafik

Another workaround needed?

Maybe auto-entities can “just” work around those “crazy” attributes? So that

      attributes:
        'Strange Attribute Naming': true

would be accepted AND the attribute’s state is shown.

  - type: custom:auto-entities
    card:
      type: entities
      title: Power Saving Mode
      state_color: true
      show_header_toggle: false
    entities: []
    filter:
      template: >-
        {% for sensor in integration_entities("mobile_app") -%}
        {%- if is_state_attr(sensor,"Low Power Mode",false) -%}
        {{
          {
            'type': 'attribute',
            'entity': sensor,
            'attribute': 'Low Power Mode',
            'name': 'xyz'
          }
        }},
        {%- endif -%}
        {%- endfor %}
    show_empty: false
    unique: true
    sort:
      method: last_changed
      reverse: true

изображение

Or this:

          {
            'type': 'attribute',
            'entity': sensor,
            'attribute': 'Low Power Mode',
            'name': state_attr(sensor,'friendly_name').split(' Battery')[0]
          }

изображение

We use templates in Configuration to create template sensors, why not using templates in Frontend?)))

I do not think this is supported…
Every attribute which I have seen is a kind of “xxx_yyy_zzz” - and is presented in UI as “Xxx Yyy Zzz” - let’s call these attributes NORMAL. These attributes from Mobile App are STRANGE (I would call them in Russian by another word - and the whole Mobile App integration is unstable and unreliable, IMHO).

2 Likes

Thank you VERY MUCH! The output is pretty much exactly what I was looking for. Think I need to start using templates in the UI to get even more out of whole HA.

I’m not brave enough to raise an issue for the mobile_app integration but I double what you said - that’s not a ‘normal’ naming convention and it’s from the official app… anyway, auto-entities is working for now :smiley: