Person Cards - Show Off Yours

Unfortuantely not sure what can be wrong. Seem like some weird issue as it’s working on one person not another. You would have to try to debug it with Chrome inspect tool looking for some errors in the console and checking the html code.

Regarding moving primary_info - you can always add i.e. markdown card to vertical stack with person-card and set the primary_info to none like below:

type: custom:stack-in-card
mode: vertical
cards:
  - type: custom:stack-in-card
    mode: horizontal
    card_mod:
      style: |
        ha-card {
          border: none !important;
          background: none !important;
        }
    cards:
      - type: custom:stack-in-card
        mode: vertical
        card_mod:
          style: |
            ha-card {
              border: none !important;
              background: none !important;
            }
        cards:
          - type: custom:mushroom-person-card
            name: Irina
            entity: person.irina
            icon_type: entity-picture
            primary_info: none
            secondary_info: false
            card_mod:
              style:
                mushroom-shape-avatar$: |
                  .picture {
                   display: flex;
                   border-radius: 50%;
                   {% if states(config.entity) == 'home' %}
                     animation: pinggreen 6s infinite;
                   {% else %}
                     animation: pingred 6s infinite;
                   {% endif %}
                  }
                  @keyframes pinggreen {
                   0% {box-shadow: 0 0 5px 3px rgba(var(--rgb-green), 0.9);}
                   100% {box-shadow: 0 0 5px 15px transparent;}
                  }
                  @keyframes pingred {
                   0% {box-shadow: 0 0 5px 3px rgba(var(--rgb-red), 0.9);}
                   100% {box-shadow: 0 0 5px 15px transparent;}
                  }
                .: |
                  ha-card { 
                  border: none !important;
                  background: none !important;
                  }
          - type: markdown
            card_mod:
              style: |
                ha-card {
                  border: none !important;
                  background: none !important;
                }
                ha-markdown {
                  padding-top: 0 !important;
                  padding-bottom: 0 !important;
                }
            content: |
              <b>{{ states('person.irina') | title }}</b>
      - type: custom:mushroom-chips-card
        chips:
          - type: entity
            entity: sensor.irinab_iphone_battery_level
            use_entity_picture: false
            card_mod: null
            style: |
              ha-card {
                border: none
              }
      - type: custom:mushroom-chips-card
        chips:
          - type: entity
            entity: sensor.irinab_iphone_battery_state
            use_entity_picture: false
            card_mod:
              style: |
                ha-card {
                  border: none
                }                    
              alignment: center
  - type: custom:mushroom-chips-card
    chips:
      - type: entity
        card_mod:
          style: |
            ha-card {
              border: none !important;
              background: none !important;
            }
        entity: sensor.irinab_iphone_geocoded_location
        icon: mdi:google-maps
        use_entity_picture: false
    card_mod:
      style: |
        ha-card {
          border: none !important;
          background: none !important;
        }
    alignment: center

Edit:
Looking at the documentation of mushroom-person-card there is a parameter called layout. Instead of above code you can just add it to your person card:

- type: custom:mushroom-person-card
  name: Irina
  entity: person.irina
  layout: vertical  # Add this line
1 Like

Thank you. Will try to add this code.
I think you right about Iphone entity’s.
I check battery level and state in dev tools today and it’s still shows yesterday information. Looks like it’s not refreshing data until I open my wife Home assistant companion app. Will do my investigation and report back, maybe someone else struggle with same issue.
Thank you again
edit:
it’s something about state attribute: state or state_not is working fine for my Android phone but not working for Iphone. When I change state from FULL or Charging to anything else it’s always show me phone is CHARGING, even if it’s not.

        conditions:
          - entity: sensor.irinab_iphone_battery_state
            state_not: not charging
1 Like

can someone helpme, with decimals display here? i want only 2 decimals

i use the code

  proximity: |
    [[[
      return `<ha-icon
        icon="mdi:map-marker-distance"
        style="width: 20px; height: 20px; color: deepskyblue;">
        </ha-icon>  <span>\<span style="color: var(--text-color-sensor);">${states['sensor.acasa_my_phone_distance'].state} Km Pana acasa</span></span>`
    ]]]
  proximity_work: |
    [[[
      return `<ha-icon
        icon="mdi:home-switch-outline"
        style="width: 20px; height: 20px; color: deepskyblue;">
        </ha-icon>  <span>\<span style="color: var(--text-color-sensor);">${states['sensor.munca_my_phone_distance'].state} Km Pana la Munca</span></span>`
    ]]]

You need to round value to 2 decimal points, something like this:

${states['sensor.munca_my_phone_distance'].state |float|round(2)}

is not working

ButtonCardJSTemplateError: ReferenceError: float is not defined in 'return `<ha-icon icon="mdi:map-marker-distance" style="width: 20px; height: 20px; color: d...'

Can you try this?

${parseFloat(states['sensor.munca_my_phone_distance'].state).toFixed(2)}

It’s works
tks

1 Like

Hello all im “new” in HA.
I have a standard layout wich i had to reconfigure after the nest update.
In my old environment i wasnt able to get a new one inserted and started a new clean install. That did it and i have my nest thermostat working now.
I would like to create a personal card, i have seen a lot of nice ones here. but i nowhere can find a youtube video with an explanation how to - install - insert the codes on the right places, in which *.yaml code needs to be pasted , and what card to use… can someone guid me please? im a quick learner so when i visualy have done it i get the hang of it…

much apreciated.

Best regards,

Johan

  • HA running in VM on Synology Nas.
  • Energy meter
  • Nest
  • Reolink doorbell

Got somehow inspired by development I’ve seen in this thread, so decided to replace old badges with something more visually pleasing… :slight_smile: So here the outcome so far:
image

Background image is dynamically changing based on current zone (so yet need to find nice pictures for all defined zones :slight_smile: ). Also planning to replace picture with map view for being away, but not at predefined zone.

3 Likes

Really impressed personal card approach. If you don’t mind, please share .yaml code. Thank you

Sure, here it goes. I added some comments to the code, so it is easier to understand and also gives some hints how to configure in your particular environments… or improve.

type: custom:config-template-card
variables:
  - states['sensor.mirek_icloud_iphone_zone_name'].state # name of zone person is in, it is case sensitive for image selection!
  - states['sensor.mireks_iphone_geocoded_location'].state # location address from reverse geocoding
  - states['sensor.mireks_iphone_ssid'].state # SSID of WiFi connection provider 
  - states['sensor.mireks_iphone_sim_1_2'].state # BSSID of mobile provder
  - states['sensor.mirek_icloud_iphone_badge'].attributes.entity_picture # person image
  - states['device_tracker.mirek_icloud_iphone'].attributes.home_distance # distance to home zone
  - states['sensor.mirek_icloud_iphone_dir_of_travel'].attributes.travel_time_min # travel time to home zone
  - states['sensor.mirek_icloud_iphone_dir_of_travel'].attributes.arrival_time # estimated arrival time if travel started now
  - states['sensor.mireks_iphone_battery_level'].state # mobile battery level
entities:
  - device_tracker.mirek_icloud_iphone # device that any change triggers template updates, perhaps more integrations to be added
card:
  type: picture-elements
  card_mod:
    style: |
      ha-card {
        height: 255px !important;
      }
  image: ${'/local/' + vars[0] + '.jpg'} # background image file name combined from zone nam (eg. /local/Home.jpg)
  elements:
    - type: image # here comes semi-transparrent image overlayed 4 times over mackgroud to create darkened area to display card data
      image: /local/overlay2.png # could be single image with proper transparency gradient used, but I have no handy one, need to refresh my graphic skills yet :-)
      style:
        top: 49%
        left: 100px
        width: 400px
    - type: image
      image: /local/overlay2.png
      style:
        top: 49%
        left: 110px
        width: 400px
    - type: image
      image: /local/overlay2.png
      style:
        top: 49%
        left: 120px
        width: 400px
    - type: image
      image: /local/overlay2.png
      style:
        top: 49%
        left: 130px
        width: 400px
    - type: custom:layout-card
      style:
        top: 0%
        left: 0%
        transform-origin: left top
        transform: translate(-0%,-0%)
      layout_type: grid # here comes definition of grid I use to place different markdown cards with details
      layout_options:
        grid-template-columns: 170px 170px auto
        grid-template-rows: 40px 100px 30px 30px
        grid-template-areas: |
          "pic  loc  img"
          "pic  adr  img"
          "wifi dist img"
          "ssid time img"
          "bat  arr  img"
      cards:
        - type: picture-entity
          entity: person.mirek_malinowski
          show_name: false
          show_state: false
          image: ${vars[4]}
          view_layout:
            grid-area: pic
          card_mod:
            style: |
              ha-card {
                background: none;
                box-shadow: none;
              }
              h1.card-header {
                padding: 0px;
              }
              div#states.card-content {
                padding: 0px;
              }
        - type: markdown
          content: ${'<ha-icon icon="mdi:map"></ha-icon>' + ' ' + vars[0]}
          view_layout:
            grid-area: loc
          card_mod: # this card mod code is used to remove background of overlay markdown cards, repeated for each card
            style: |
              ha-card {
                background: none;
                box-shadow: none;
              }
              h1.card-header {
                padding: 8px;
              }
              div#states.card-content {
                padding: 8px;
              }
        - type: markdown
          content: ${ vars[1]}
          view_layout:
            grid-area: adr
          card_mod:
            style: |
              ha-card {
                background: none;
                box-shadow: none;
              }
              h1.card-header {
                padding: 8px;
              }
              div#states.card-content {
                padding: 8px;
              }
        - type: markdown
          content: ${'<ha-icon icon="mdi:wifi"></ha-icon>' + ' ' + vars[2]}
          view_layout:
            grid-area: wifi
          card_mod:
            style: |
              ha-card {
                background: none;
                box-shadow: none;
              }
              h1.card-header {
                padding: 8px;
              }
              div#states.card-content {
                padding: 8px;
              }
        - type: markdown
          content: >-
            ${'<ha-icon icon="mdi:cellphone"></ha-icon>' + ' ' +
            vars[3]}
          view_layout:
            grid-area: ssid
          card_mod:
            style: |
              ha-card {
                background: none;
                box-shadow: none;
              }
              h1.card-header {
                padding: 8px;
              }
              div#states.card-content {
                padding: 8px;
              }
        - type: markdown
          content: >-
            ${'<ha-icon icon="mdi:battery-50"></ha-icon>' + ' ' +
            vars[8] + '%'}
          view_layout:
            grid-area: bat
          card_mod:
            style: |
              ha-card {
                background: none;
                box-shadow: none;
              }
              h1.card-header {
                padding: 8px;
              }
              div#states.card-content {
                padding: 8px;
              }
        - type: markdown
          content: >-
            ${'<ha-icon icon="mdi:map-marker-distance"></ha-icon>' + ' '
            + vars[5] +' km'}
          view_layout:
            grid-area: dist
          card_mod:
            style: |
              ha-card {
                background: none;
                box-shadow: none;
              }
              h1.card-header {
                padding: 8px;
              }
              div#states.card-content {
                padding: 8px;
              }
        - type: markdown
          content: >-
            ${'<ha-icon icon="mdi:map-clock"></ha-icon>' + ' ' +
            vars[6]}
          view_layout:
            grid-area: time
          card_mod:
            style: |
              ha-card {
                background: none;
                box-shadow: none;
              }
              h1.card-header {
                padding: 8px;
              }
              div#states.card-content {
                padding: 8px;
              }
        - type: markdown
          content: >-
            ${'<ha-icon icon="mdi:home-clock"></ha-icon>' + ' ' +
            vars[7]}
          view_layout:
            grid-area: arr
          card_mod:
            style: |
              ha-card {
                background: none;
                box-shadow: none;
              }
              h1.card-header {
                padding: 8px;
              }
              div#states.card-content {
                padding: 8px;
              }
2 Likes

Hi @Mandoliinimies
I think your cards are mega. especially the first card with your photo and the information as icons. Would you have the code for the first card?
Many thanks and best wishes from Switzerland.

Thank you!

The code is currently not working properly. I need to take a closer look at it when I have more time to get it fixed, after which I can share it. Unfortunately, I can’t say a schedule for this. I have been away from HomeAssistant for a long time, but now I’m getting back into it.

Thanks a lot for this post, it was really inspiring.
This is my final version… or at least the current one!
person card

2 Likes

I like your layout. Would you be able to share the code?

some great examples here. I love the mushroom cards to settled with this.

6 Likes

Love this idea! Do Tile trackers work outside of bluetooth range? Or would I need to use an airtag or similar to have longer range tracking?

person_card

This is what I came up with. I have 4 of these on my main dashboard in a 2x2 grid, on touch it opens directly the map view with the last known position. The sensor values are showing:

  • Known location/zone or “on the way”
  • Phone battery status (charging or not changes icon) and current level (changing to redish if lower than 35)
  • Currently connected wi-fi network SSID
  • Distance to Home-zone

The pictures are bitmoji with removed background. The circle border changes the color using the actual zone the person.entity is in.

type: custom:button-card
entity: [YOUR.PERSON.ENTITY]
variables:
  phone_battery_level_sensor: '[[[ return states["sensor.phone_battery_level"].state]]]'
  phone_battery_state_sensor: '[[[ return states["sensor.phone_battery_state"].state]]]'
  phone_wifi_sensor: '[[[ return states["sensor.phone_wifi_connection"].state]]]'
  proximity_sensor: '[[[ return states["sensor.home_proximity"].state]]]'
aspect_ratio: 2/1
name: Person
show_entity_picture: true
show_name: false
hold_action:
  action: none
state:
  - value: home
    styles:
      card:
        - background-color: '#202124'
      custom_fields:
        icon:
          - border-color: '#77c66e'
  - value: not_home
    styles:
      card:
        - background-color: '#202124'
      custom_fields:
        icon:
          - border-color: deepskyblue
  - value: Pizzeria
    styles:
      card:
        - background-color: '#202124'
      custom_fields:
        icon:
          - border-color: '#B83838'
styles:
  card:
    - background-color: '#202124'
    - border-radius: 5%
    - padding: 2% 5% 5% 5%
    - color: gray
    - font-size: 10px
    - text-shadow: 0px 0px 0px black
    - text-transform: capitalize
    - justify-self: center
    - align-content: center
  grid:
    - grid-template-areas: '"icon status" "icon battery" "icon wifi" "icon proximity"'
    - grid-template-columns: 1.5fr 1fr
    - grid-template-rows: 1fr 1fr 1fr 1fr
    - align-content: center
  name:
    - font-size: 15px
    - align-self: middle
    - justify-self: start
  custom_fields:
    icon:
      - clip-path: circle()
      - width: 60%
      - pointer-events: none
      - display: grid
      - border: 5px solid
      - border-color: '#808080'
      - border-radius: 500px
      - margin: 0 0 0 0
      - opacity: 1
      - align-self: center
      - justify-self: center
    status:
      - justify-self: start
      - color: gray
    proximity:
      - align-self: middle
      - justify-self: start
      - color: gray
    wifi:
      - justify-self: start
      - color: gray
      - '--text-wifi-color-sensor': >-
          [[[ if (variables.phone_wifi_sensor == '<not connected>') return
          "#aaaaaa"; ]]]
    battery:
      - align-self: middle
      - justify-self: start
      - color: gray
      - '--text-color-sensor': >-
          [[[ if (variables.phone_battery_level_sensor < 35) return "#EF4F1A";
          ]]]
custom_fields:
  icon: >
    [[[ return entity === undefined ? null : `<img
    src="${states[entity.entity_id].attributes.entity_picture}" width="100%">`;
    ]]]
  status: |
    [[[
      if (entity.state =='not_home') { 
      return `<ha-icon icon="mdi:home-export-outline"
        style="width: 20px; height: 20px; color: '#888888';">
        </ha-icon><span> On the way</span>`;
      } 
      if (entity.state =='home') { 
      return `<ha-icon 
        icon="mdi:home"
        style="width: 20px; height: 20px; color: 888888;">
        </ha-icon><span> ${entity.state}</span>`;
      } else { 
        if (entity.state =='[YOUR OTHER LOCATION]') { 
        return `<ha-icon icon="mdi:pizza"
          style="width: 20px; height: 20px; color: '#888888';">
          </ha-icon><span> ${entity.state}</span>`;
        }
        else{
        return `<ha-icon 
          icon="mdi:map-marker-radius"
          style="width: 20px; height: 20px; color: 888888;">
          </ha-icon><span> ${entity.state}</span>`;
        }
      }
    ]]]
  battery: |
    [[[
      if (variables.phone_battery_state_sensor =='charging') { 
        return `<ha-icon
        icon="mdi:battery-charging-medium"
        style="width: 20px; height: 20px; color: #888888;">
        </ha-icon> <span><span style="color: var(--text-color-sensor);">${variables.phone_battery_level_sensor}% Battery</span></span>`;
      } else {
        return `<ha-icon
        icon="mdi:battery-medium"
        style="width: 20px; height: 20px; color: #888888;">
        </ha-icon> <span><span style="color: var(--text-color-sensor);">${variables.phone_battery_level_sensor}% Battery</span></span>`;
      }
    ]]]
  proximity: |
    [[[
      return `<ha-icon
        icon="mdi:map-marker-distance"
        style="width: 20px; height: 20px; color: #888888;">
        </ha-icon>  <span>\<span style="color: var(--text-color-sensor);">${variables.proximity_sensor} Km</span></span>`
    ]]]
  wifi: |
    [[[
      if (variables.phone_wifi_sensor.state =='<not connected>') { 
        return `<ha-icon
        icon="mdi:wifi"
        style="width: 20px; height: 20px; color: var(--text-wifi-color-sensor);">
        </ha-icon> <span><span style="color: var(--text-wifi-color-sensor);">Disconnected</span></span>`; 
      } else {
        return `<ha-icon
        icon="mdi:wifi"
        style="width: 20px; height: 20px; color: #888888;">
        </ha-icon> <span><span style="color: var(--text-color-sensor);">${variables.phone_wifi_sensor}</span></span>`;
      }
    ]]]

2 Likes

It looks really good! I love it!
I’m not familiar with YAML code. I have installed button-card and I can’t get it to work… I made some changes to the code but even with the original code it didn’t work.

type: custom:button-card
entity: person.osher
aspect_ratio: 1/1
name: Person
show_entity_picture: true
show_name: false
hold_action:
  action: none
state:
  - value: home
    styles:
      custom_fields:
        icon:
          - border-color: '#77c66e'
  - value: not_home
    styles:
      card:
        - background-color: '#dedede'
      custom_fields:
        icon:
          - border-color: '#EF4F1A'
  - value: Work
    styles:
      custom_fields:
        icon:
          - border-color: deepskyblue
styles:
  card:
    - background-color: white
    - border-radius: 5%
    - padding: 5%
    - color: gray
    - font-size: 10px
    - text-shadow: 0px 0px 0px black
    - text-transform: capitalize
    - justify-self: end
    - align-self: middle
  grid:
    - grid-template-areas: '"icon status" "n n" "battery proximity" "wifi ss" "sd sd"'
    - grid-template-columns: 2fr 1fr
    - grid-template-rows: 1fr min-content min-content min-content min-content
  name:
    - font-size: 15px
    - align-self: middle
    - justify-self: start
    - padding-bottom: 10px
  custom_fields:
    icon:
      - clip-path: circle()
      - width: 80%
      - pointer-events: none
      - display: grid
      - border: 5px solid
      - border-color: gray
      - border-radius: 500px
      - margin: 0 +10% 0 0
      - justify-self: end
      - opacity: 1
    status:
      - align-self: start
      - justify-self: end
      - color: gray
    proximity:
      - padding: 0.5em 0px
      - align-self: middle
      - justify-self: start
      - color: gray
    wifi:
      - padding: 0.5em 0px
      - align-self: middle
      - justify-self: start
      - color: gray
      - '--text-wifi-color-sensor': >-
          [[[ if (states["sensor.mobile_wifi_connection"].state == '<not
          connected>') return "#aaaaaa"; ]]]
    battery:
      - padding: 0.5em 0px
      - align-self: middle
      - justify-self: start
      - color: gray
      - '--text-color-sensor': >-
          [[[ if (states["sensor.mobile_battery_level"].state < 50) return
          "#EF4F1A"; ]]]
custom_fields:
  icon: >
    [[[ return entity === undefined ? null : `<img
    src="${states[entity.entity_id].attributes.entity_picture}" width="100%">`;
    ]]]
  status: |
    [[[
      if (states['person.osher'].state =='not_home') { 
      return `<ha-icon icon="mdi:home-export-outline"
        style="width: 20px; height: 20px; color: '#888888';">
        </ha-icon><span> Away</span>`;
      } 
      if (states['person.osher'].state =='home') { 
      return `<ha-icon 
        icon="mdi:home"
        style="width: 20px; height: 20px; color: 888888;">
        </ha-icon><span> ${entity.state}</span>`;
      } else {
      return `<ha-icon 
        icon="mdi:map-marker-radius"
        style="width: 20px; height: 20px; color: 888888;">
        </ha-icon><span> ${entity.state}</span>`;
      }
    ]]]
  proximity: |
    [[[
      return `<ha-icon
        icon="mdi:map-marker-distance"
        style="width: 20px; height: 20px; color: #888888;">
        </ha-icon>  <span>\<span style="color: var(--text-color-sensor);">${states['proximity.ad_home'].state} Kms</span></span>`
    ]]]
  battery: |
    [[[
      if (states['sensor.mobile_battery_state'].state =='charging') { 
        return `<ha-icon
        icon="mdi:battery-charging"
        style="width: 20px; height: 20px; color: #888888;">
        </ha-icon> <span><span style="color: var(--text-color-sensor);">${states['sensor.ad_s9_aim_battery_level'].state}% battery</span></span>`;
      } else {
        return `<ha-icon
        icon="mdi:battery"
        style="width: 20px; height: 20px; color: #888888;">
        </ha-icon> <span><span style="color: var(--text-color-sensor);">${states['sensor.mobile_battery_level'].state}% battery</span></span>`;
      }
    ]]]
  wifi: |
    [[[
      if (states['sensor.mobile_wifi_connection'].state =='<not connected>') { 
        return `<ha-icon
        icon="mdi:wifi"
        style="width: 20px; height: 20px; color: var(--text-wifi-color-sensor);">
        </ha-icon> <span><span style="color: var(--text-wifi-color-sensor);">Disconnected</span></span>`; 
      } else {
        return `<ha-icon
        icon="mdi:wifi"
        style="width: 20px; height: 20px; color: #888888;">
        </ha-icon> <span><span style="color: var(--text-color-sensor);">${states['sensor.mobile_wifi_connection'].state}</span></span>`;
      }
    ]]]

Can someone tell me what is the problem here?:sweat_smile:

Would be easier if you could post your code as a preformatted text instead of picture. In the post editor click </> and paste your code where it says.

PS.
You have to replace all person.xxx occurance with your entity. You can check it by going to Developer Tools → States and in the entity filter search start typing ‘person’.