#Can't add Arbitrary Text to Badge

1 messages · Page 1 of 1 (latest)

night knot
#

So I want a badge for every person in the house that displays info about a person, and I can get the info from our phones, such as Name, Location, Last change, and Last Update... but as pictured (blue arrow), it only displays the value and no text, where i'd want it to say:

**Name: **Jon **Location: **Home When: 3 Hours Ago Updated: 1 Hour Ago

but i cant find any way to put arbitrary text in a badge using the code editor. Am I going crazy? I've read https://www.home-assistant.io/dashboards/badges up and down and i just dont see anything.

Some sort of code similar to:

type: entity
show_name: true
show_state: true
show_icon: true
entity: person.jon
color: red
name: Jon
text1: When
text2: Updated
show_entity_picture: true
icon: mdi:account-plus
state_content:

  • name
  • state
  • text1
  • last_changed
  • text2
  • last_updated

but i dont know what the code for "text1/2" is. I've tried value, and some other stuff.

(Please tag me in a response, thank you :3)

Home Assistant

Description of the various badges that are available.

night knot
#

Bump?

bitter lichen
#

This is not a feature of the badge. You'll have to use a custom badge, or maybe some card mod.

south rain
#

I took this question as more of a challenge. Like karwosts mentioned, you'll have to use some custom stuff. The Mushroom Template Badge (part of Mushroom cards) can be templated to return a string with the information you want, but I don't think it would be possible to make some of the text bold. The Markdown down card, however, can do that, but it doesn't seem to be able to be made into a badge.

#

Here's what I came up with: a custom:button-card added as a Manual badge, the Markdown card embedded into the custom:button-card, some styling to make the custom:button-card look like a badge, and some card_mod to modify the Markdown card. I also used petro's Easy Time to easily show when the entity was last updated.

#

Note: this example is not 100% complete. It still could use a bit more work on it.

#
type: custom:button-card
styles:
  grid:
    - grid-template-areas: markdown
    - grid-template-columns: auto
    - grid-template-rows: min-content
  card:
    - height: 36px
    - width: auto
    - padding-top: 0px
    - padding-bottom: 0px
    - padding-left: 6px
    - padding-right: 6px
    - border-radius: 18px
    - border-width: 1px
    - background-color: transparent
custom_fields:
  markdown:
    card:
      type: markdown
      content: >
        {% set person_entity = "person.derek" %}  {% set battery_level =
        "sensor.s25_ultra_battery_level" %} {% from 'easy_time.jinja' import
        easy_relative_time %} <font size = 2> **Name:**  {{
        state_attr(person_entity, 'friendly_name') }} &nbsp;  **Location:** {{
        states(person_entity).capitalize() }} &nbsp; **When:** 3 Hours Ago
        &nbsp; **Updated:** {{
        easy_relative_time(states.person.derek.last_updated, max_period='hour',
        short=True) }}  &nbsp; 🔋{{ states(battery_level) }}%
      card_mod:
        style: |
          ha-card {
            border: none;
            background: none;
            padding-top: 0px;
            margin-top: -12px;
            height: 25px;
          }
```EDITS:
- Added a variable for the person entity to reduce repeating it
- Added a battery percentage because... why not?
- Centered Markdown card better
- Added **petro**'s [Easy Time](<https://github.com/Petro31/easy-time-jinja>).
  - This can't use the person variable and needs to be set as an object.
  - I don't think the person entity records when the Zone changed. You may need a secondary helper and/or automation to handle this but I'm not sure though.