Yaml, Auto-Entities card, maybe a template

I created an Auto Entities card in an HA dashboard to simply display the temperature and humidity of sensors around my house. I found a thread from 2024 (I think) that described how to set this up using a flex-table-card. Here is the YAML:

type: custom:auto-entities
filter:
  include:
    - options: {}
      state: Room Entity
card:
  type: custom:flex-table-card
  columns:
    - name: ""
      modify: "'<ha-icon icon=\"mdi:thermometer\" style=color:green;></ha-icon>'    "
    - name: Room
      data: friendly_name
    - name: Temperature
      data: temperature
    - name: Humidity
      data: humidity

The data display like this (so far):

How do I suppress the display of or replace the text “undefinedundefined…”? Some of my sensors only have temperature, there is no humidity attribute.

I’m just getting into YAML, so I have a long way to go.

Here is a good place to ask your question:

And that thread contains examples you need.
Also - always post a code properly FORMATTED. Paste a code inside triple backticks or use a “preformatted” option from a cog menu.

Thank you for the advice! For whatever reason, when I created the original post using an iPad, niether the tick marks nor the preformatted options worked. This time, I used a PC.

All of my sensors support temperature, and only a handful don’t support humidity. As an example, here is what I ended up doing in my templates file:

sensor:
      - name: Tesla
        state: "Outside"
        attributes:
          temperature: '{{ states("sensor.red_rocket_inside_temperature_2")}} °F'
          humidity: >
            {% set hum = states('sensor.red_rocket_inside_humidity_2') %}
            {{ hum ~ '%' if hum not in ['unknown', 'unavailable', 'none'] else '' }}

This way, if a sensor has no humidity data, it will just show up blank in that column.

I also modified the card to use icons for the headings as shown here:

I created 3 separate cards for downstairs, upstairs and outside. I really like the ability to click on a heading to sort! Nicely done!

I’m looking forward to learning more about auto entities and building some other dashboard cards.

Why are you using template sensors for this? Just because you’re using flex-table-card?

If a table presentation of a set of values is needed, a stock Markdown card may be used (markdown supports tables).
In this case each row may contain different entities (in flex-table-card each row must represent one entity).
But Markdown does not support tap_action. So, alternatives may be considered - Heading card, multiple-entity-row.

  1. I wanted to figure out how to create a template sensor (knowledge quest)
  2. A post said you cannot use multiple entities in columns using another approach (don’t remember what it was)
  3. I found setting up a markdown card incredibly clunky
  4. I saw an example of exactly what I was looking to do using a flex card

You likely can with auto-entities and a template. You can fake out anything for the most part. But it’ll require someone who knows that process.

For just a table of icons and entity info, it’ll be pretty easy with a for loop and HTML.

Also, from what I can tell, the template sensor creates a new entity, and the other entities defined in it are defined as that entity’s attributes. This way, it is sort of a workaround to the single entity limitation. At least I think that’s how it works…

I don’t think there’s needs to be a single entity work around. It may be a limitation of that custom card, but again, it can be worked around using templates instead with auto entities or the markdown card using html to create the table.

Yeah, Ildar stated (in post #4) that a flex-entity-card only supports a single entity per row, so creating the sensor template works very well to get around that.

If you happen to have an example of using a markdown card with html, that would be awesome. I would like to learn how that works, as well.

It would probably be easier for me to just code it out with your entities. Otherwise the examples I have aren’t going to be 1 to 1 with what you need. Can you just post the list of entities you plan to use?

Thank you! I’ll take you up on your offer! I’ll do that soon from my pc - it’s kind of a pain on an iPad…

OK, here is a list of the entities for downstairs sensors. I set up the table assuming you might need the room name.

Room Temperature Sensor Humidity Sensor
Garage sensor.collins1_everspring_temperature sensor.collins1_everspring_humidity
Workshop sensor.workshop_motion_sensor_temperature N/A
Family Room sensor.hallway_thermostat_sensor_famiy_room_temperature sensor.hallway_thermostat_sensor_famiy_room_humidity
Kitchen sensor.hallway_thermostat_sensor_kitchen_temperature sensor.hallway_thermostat_sensor_kitchen_humidity
Hallway sensor.hallway_temperature sensor.hallway_humidity
Living Room sensor.office_temp_humidity_temperature sensor.office_temp_humidity_humidity

If there is a better way to post this to make it easier to copy the data, let me know.

This should be all you need for the template in markdown card

{%- set data = [
  {
    "name": "Garage",
    "temperature": "sensor.collins1_everspring_temperature",
    "humidity": "sensor.collins1_everspring_humidity"
  },
  {
    "name": "Workshop",
    "temperature": "sensor.workshop_motion_sensor_temperature",
  },
  {
    "name": "Family Room",
    "temperature": "sensor.hallway_thermostat_sensor_famiy_room_temperature",
    "humidity": "sensor.hallway_thermostat_sensor_famiy_room_humidity"
  },
  {
    "name": "Kitchen",
    "temperature": "sensor.hallway_thermostat_sensor_kitchen_temperature",
    "humidity": "sensor.hallway_thermostat_sensor_kitchen_humidity"
  },
  {
    "name": "Hallway",
    "temperature": "sensor.hallway_temperature",
    "humidity": "sensor.hallway_humidity"
  },
  {
    "name": "Living Room",
    "temperature": "sensor.office_temp_humidity_temperature",
    "humidity": "sensor.office_temp_humidity_humidity"
  }
] -%}
<table>
<tr>
  <th>Name</th>
  <th>Temperature</th>
  <th>Humidity</th>
</tr>
{%- for item in data %}
<tr>
  <td>{{ item.name }}</td>
  <td>{{ states(item.temperature, True, True) }}</td>
  <td>{{ states(item.get('humidity', 'NA'), True, True) }}</td>
</tr>
{%- endfor %}
</table>

I should also say, there’s a lot of styling that can be done for the table and you can even add HA icons. But I’d need to know what you’re looking for.

Wow! That would have taken me forever to figure out. This is hugely helpful and a great starting place! Thank you!

The ones I created using auto-entities and the templates look like this:

I didn’t do anything for formatting in the card itself, I think this is how the default works. I was able to figure out how to suppress “undefined” or “unknown” in the card using some formatting in the tempates.

It would be great to learn how to come up with something comparable using the markdown card. From there, I can experiment with different styles.

well, post what the markdown card produces and we can muck with it until it looks the same. It’s just HTML

OK, here is what the markdown card looks like in the dashboard: