šŸ”¹ Auto-entities - Automatically fill cards with entities

Because all the To Do type cards I have found look like crap to be honest haha :grimacing:
They all look like flat text lists with checkmarks. No flexibility on what to show, which date range or status. They are just incredibly lacking and not user / touch / dashboard friendly in my opinion.

I have been working with Mushroom Template cards based on date_time input helpers to create lists for reoccurring tasks (mow the lawn, take medication, take out the trash, clean the litter box, refill the salt in water softener, etc). This is a user-friendly experience (think parents in law :wink:)
Looks and works like a charm, but with one major limitation. For each task they want, I have to create and maintain the input helper and the recurrence manually.

What my end goal would be is to use Google Tasks or something to (have others) set up the tasks and the recurrence. Then use the integration into HA to pick up the tasks and show them (using auto-entities) as separate buttons in the interface, based on ā€¦ time, category, etc

But since the tasks from any To Do based integration in HA are not created as entities, but only available as response list from a service-call / action, I want to pass that response into auto-entities to create the separate cards. But I have yet to discover how to actually perform an action and use the response in auto-entities. I have used the template filter using jinja for many things, but cannot get this to work.

OK, a bit clearer but I am not sure how ā€˜todoā€™ will help as fafaik these do not (yet) allow for recurrence/scheduling so in my eyes only making things more complex if you want to put this in the middle but I have no clue how far up/down the road you are. In any case, this seems (?) not for auto-entities as how would you create an entity from a free-text todo-list itemā€¦you would need an entity to populate a button card?

The recurrence is handled in the To Do integration, and that is working. The service all gives the next occurrence each time with the correct date. This is an example of response from todo.get_items task:

todo.kluslijst:
  items:
    - summary: Test Recurrence
      uid: #hash#
      status: needs_action
      due: "2025-03-05"
    - summary: Test One Time
      uid: #hash#
      status: needs_action
      due: "2025-03-04"

You donā€™t need an entity to populate a Mushroom Template card. Thatā€™s the beauty of it. If I have the above data in some form stored in an variable I can use Jinja to populate all the required fields for that card. If needed I will refer to a dummy entity.

By using the template filter and the for-loop you can create as many cards as you like based on your loop and if criteria. See below example I have working, but based on an integration that is not maintained anymoreā€¦

filter:
  template: |-
    {% for state in states.sensor -%}
      {%- if state_attr(state.entity_id, 'integration') == 'activity_manager' -%}
        {%- if as_datetime(state.state) < (now() + timedelta(days=7)) -%}
          {%- if as_datetime(state.state) < now() -%}
            {{
              {
                'type': "custom:mushroom-template-card",

The one thing I am missing is how to execute the service to get the above response from my filter templateā€¦

okā€¦am (clearly) not the specialist on all levels.
So what you seem to want is: existing todolist > get items & atribs > populate mushroom cards ?

EDIT, I see the challenge getting the data from the todolist but that could be handled with a template entity and just populate that with the items, not? From there on you can query these attributes and populate the card via auto-entities

Thanks that is a really good idea!
I quickly built a template sensor with all the current items that arenā€™t completed yet.

template:
  - trigger:
      - trigger: time_pattern
        seconds: "20"
    action:
      - action: todo.get_items
        data:
          status: needs_action
        target:
          entity_id:
            - todo.kluslijst
        response_variable: action_response
    sensor:
      - name: Kluslijst Items
        unique_id: kluslijst_items
        state: "{{ now().isoformat() }}"
        attributes:
          tasks: "{{ action_response['todo.kluslijst']['items'] }}"

And now able to use that sensor in auto entities to create multiple cards for items due in the next 7 days. First setup as the final version will contain different colors for different due times and an call to update the todo item when pressed on.

type: custom:auto-entities
card_param: cards
card:
  square: false
  type: grid
  columns: 2
  title: To-Do List
filter:
  template: |-
    {%- set tasks = states.sensor.kluslijst_items.attributes.tasks | sort(attribute='due', reverse=false) | list -%}
    {%- for item in tasks -%}
      {%- if as_datetime(item.due).astimezone() < (now() + timedelta(days=7)) -%}
        {{
          {
            'type': "custom:mushroom-template-card",
            'entity': "sensor.kluslijst_items",
            'primary': item.summary,
            'secondary': item.due,
            'icon': "mdi:home",
            'icon_color': "red",
          }
        }},
      {%- endif -%}
    {%- endfor -%}

Result:

what you can do instead (or adding to the timepattern) is a trigger on state change of that todo list, should be more accurate :slight_smile:

1 Like

And I think I like this idea too as removing items from a todo-list via the card takes too many steps., selecting, deleting, confirming

EDIT: done, tap action added to move items between completed and needs_actionā€¦ two cards covering them both. Could also be done with two lists and moving items left/right

1 Like

Iā€™d like to know if it is possible to include specific groups based on the day of the week. I have tried variations of the following in include/groups, but I does not want to work. Any help would be appreciated

type: custom:auto-entities
card:
  type: entities
  show_header_toggle: false
  state_color: false
  title: Tasks
filter:
  include:
    - group: group.group_tasks_daily
    - group: >-
        {% if now().weekday() == 4 %}
          group.group_tasks_thursday
          # etc
        {% endif %}
  exclude:
    - state: "on"
show_empty: true

Is this (or something similar) possible?

You are trying to use jinja which is only possible for the ā€œtemplateā€ option.

Thanks for the response. Will I be able to include/exclude groups in the template section through jinja or am I going about this the wrong way?

All include/exclude should be provided inside the ā€œtemplateā€ option (with selectattr, rejectattr or similar).

How I can change a severity color base on state value from air quality sensor which have only
these states: good, hazardous, high, low, moderate, unhealthy?

type: custom:auto-entities
filter:
  include:
    - entity_id: sensor.nash_dom_air_quality*
      state: hazardous
    - entity_id: sensor.nash_dom_air_quality*
      state: high
    - entity_id: sensor.nash_dom_air_quality*
      state: low
    - entity_id: sensor.nash_dom_air_quality*
      state: moderate
    - entity_id: sensor.nash_dom_air_quality*
      state: unhealthy
  exclude: []
card:
  type: custom:auto-entities
  card:
    type: entities
    state_color: false
    show_header_toggle: false
  filter:
    include: []
    exclude: []
grid_options:

I tried to use something like these , but no luck

  severity:
    - value: null
      from: 0
      to: 20
      color: red
    - value: null
      from: 21
      to: 40
      color: darkorange
    - value: null
      from: 41
      to: 60
      color: darkgreen
    - value: null
      from: 61
      to: 100
      color: green

how can I make this card ā€˜status onlyā€™ā€¦ removing any control capabilities (clicks do nothing). Ideally it would also remove the text / right most columnā€¦

type: custom:auto-entities
card:
  type: entities
  state_color: true
filter:
  include:
    - entity_id: "*_deadbolt"
      options:
        secondary_info: last-changed
  exclude: []
grid_options:
  columns: full
  rows: auto

thanks!

One option would be to create a template binary sensor for each entity:

{{ states.lock.front_door_lock.state }}

Be sure to change the device class to ā€˜lockā€™ when creating the sensor. Then create your auto-entities to query against those binary_sensors.

I think you can set type: simple-entity in the options for the entity (so with secondary_info)

It is kind of mentioned in the entities card docs, but easy to miss.

that did work to disable the ā€˜clickā€™ ability on the value text but it did not disable the click on the icon or name.

Any ideas how to disable those? And remove the value text completely?

@coolhand I appreciate the suggestion. Iā€™d prefer not to create a ton of workarounds (hacks), which is what I consider sensor templates. Something this simple IMO its unacceptable HA doesnt have a built-in ā€˜status onlyā€™ capability. HA is great if you love overly complex stuffā€¦ but it misses a ton of ā€˜basicsā€™

For this you will have to learn css & card-mod.

Then use a markdown card.
No control, text/table only.
The question is asked incorrectly IMHO.
Your ask is how to make an entity card do nothing.
My answer is donā€™t use an entity card, use an informational card like markdown.
Of course, then no need for auto-entities as you write that simple filter right in the card and you have one card ā€¦ markdown.

example, not yours:

{% for sen in (states | selectattr('entity_id','contains', 'xan')) %}
{{ sen.entity_id }} last updated {{sen.last_updated}}
{% endfor %}

or in a card like this:

No auto-entities, no interaction, one card for information only.

2 Likes

Markdown doesnt output the same without, Iā€™m assuming, being a coding expertā€¦ which is far from use friendly. by default the output just a ton of unwanted text, no icons, etcā€¦ vs what auto-entities outputs, which is nice and clean visual with only the info I want.

OK. essentially as non-coding ā€œexpertā€ myself, the few lines I put in contain all the information in the GUI that is your auto-entities entry.

Again, your asking this:

ā€œwhy canā€™t I have a card that has no control or click or anythingā€

Answer ā€¦;. 99% of us do not want that.

The two suggestions (@Ildar_Gabdullin and mine) are the proper answers. Use CSS and card_mod to remove what 99% of us wantā€¦requires coding.
Use markdown to show me information ā€¦ requires coding.

I suppose you could use bubble or mushroom and show heading only ā€œcardsā€, but you have no reason to use many cards to show things if you donā€™t want to interact. Not to mention then 1000 lines of HTML and browser slowdown, etc. you get for ā€œXā€ cards where "X is greater than than a few.

If you do not know the standard attributes for an entity, you should learn them.