Person Cards - Show Off Yours

Hi everyone,
I’m new to HA and I’m configuring my presence cards trying to grab things here and there from this topic.
I’m almost there but I can’t achieve one thing: Have the time-changed to show up like in these cards
image

Here is my template code

  person_card_new:
    default:
      - size: 100%
      - color: auto
      - background_color: var(--primary-background-color)
      - variable: spin
      - spin: false
      - show_name: false
      - show_state: false
      - show_label: false
      - show_icon: true
      - show_last_changed: true
      - triggers_update: all
      - show_entity_picture: true
      - tap_action:
          action: more-info
          haptic: light
      - aspect_ratio: 2/1
      - margin-right: 20px
      - label: ' '
    card:
      type: custom:button-card
      battery_level: '[[battery_level]]'
      battery_state: '[[battery_state]]'
      name: '[[name]]'
      icon: mdi:[[icon]]
      secondary-info: '[[secondary-info]]'
      size: '[[size]]'
      color: '[[color]]'
      aspect_ratio: '[[aspect_ratio]]'
      entity: '[[entity]]'
      label: '[[label]]'
      show_name: '[[show_name]]'
      show_icon: '[[show_icon]]'
      show_state: '[[show_state]]'
      show_label: '[[show_label]]'
      last_changed: '[[last_changed]]'
      show_last_changed: '[[show_last_changed]]'
      tap_action: '[[tap_action]]'
      hold_action: '[[hold_action]]'
      entity_picture: '[[entity_picture]]'
      show_entity_picture: '[[show_entity_picture]]'
      styles:
        card:
          - border-radius: 12px
          - '--card-background-color': '[[background_color]]'
        icon:
          - grid-column: 1
          - grid-row: 1 / 4
        label:
          - color: gray
          - font-size: 11px
          - padding: 0px 10px
          - justify-self: start
        state:
          - font-size: 12px
          - padding: 0px 10px
          - justify-self: start
          - text-transform: capitalize
          - font-weight: bold
          - padding-left: 10px
          - color: var(--primary-text-color)
        grid:
          - grid-template-areas: '"i battery" "i home" "i s" "i watch"'
          - grid-template-columns: 65% 35%
          - grid-template-rows: 20% 20% 40% 20%
        img_cell:
          - align-self: start
          - text-align: start
        name:
          - justify-self: start
          - padding-left: 10px
          - font-weight: bold
          - font-size: 13px
        entity_picture:
          - height: 80px
          - width: 80px
          - border-radius: 100%
        custom_fields:
          battery:
            - align-self: start
            - justify-self: end
            - font-size: 12px
            - color: |-
                [[[
                  if (states['[[battery_level]]'].state < 30) return "#ff1a1a";
                  if (states['[[battery_level]]'].state < 50) return "#ffcd1a";
                  if (states['[[battery_level]]'].state < 101) return "#50A14F";
                  else return "#ffc640"
                ]]]
          home:
            - align-self: start
            - justify-self: end
            - font-size: 12px
            - color: var(--secondary-text-color)
          watch:
            - align-self: end
            - justify-self: start
            - font-size: 12px
            - color: var(--secondary-text-color)
      custom_fields:
        battery: |
          [[[
            if (states['[[battery_state]]'].state === 'discharging')
              return `<ha-icon icon="mdi:battery" style="--mdc-icon-size: 14px; padding-left: 6px; padding-right: 5px;"></ha-icon><span>${states['[[battery_level]]'].state}%</span>`
            else if (states['[[battery_state]]'].attributes.battery_status === 'NotCharging')
              return `<ha-icon icon="mdi:battery" style="--mdc-icon-size: 14px; padding-left: 6px; padding-right: 5px;"> </ha-icon><span>${states['[[battery_level]]'].state}%</span>`
            else return `<ha-icon icon="mdi:battery-charging" style="--mdc-icon-size: 14px; padding-left: 5px; padding-right: 5px;"></ha-icon><span>${states['[[battery_level]]'].state}%</span>`
          ]]]
        home: |
          [[[
            if (states['[[entity]]'].state =='not_home')
              return `<ha-icon icon="mdi:home-export-outline" style="width: 20px; height: 20px; color: '#888888';"></ha-icon>`;
            if (states['[[entity]]'].state =='home')
              return `<ha-icon  icon="mdi:home" style="width: 20px; height: 20px; color: 888888;">`;
          ]]]

And my card:

    cards:
      - type: horizontal-stack
        cards:
          - type: custom:decluttering-card
            template: person_card_new
            variables:
              - entity: device_tracker.galaxy_s9
              - entity_picture: /local/images/seb_new.png
              - battery_level: sensor.kinder_s_s9_ha_battery_level
              - battery_state: sensor.kinder_s_s9_ha_battery_state
              - show_entity_picture: true
              - show_last_changed: true
              - tap_action:
                  action: more-info
                  haptic: light
          - type: custom:decluttering-card
            template: person_card_new
            variables:
              - entity: person.2
              - entity_picture: /local/images/esther_new.png
              - battery_level: sensor.iphone_de_esther_battery_state
              - battery_state: sensor.iphone_de_esther_battery_state
              - show_entity_picture: true
              - show_last_changed: true
              - tap_action:
                  action: more-info
                  haptic: light

Does someone have an idea of what I’m missing so I can show the last_changed info?

Thanks !

1 Like

Hi,

For the time to home, please refer to this post: Person Cards - Show Off Yours - #24 by VaReTaS (about Waze travel time integration)

For the away time, I wonder that you need to get a sensor that measures the time from the last change from “Home” to other state, for each person. Check @benm7 initial code Person Cards - Show Off Yours - #6 by benm7 since yours look different and missing bits of it.

Is the CSS different for the mobile version? I’m trying to get everything to fit and struggling. The only modifications I’ve made so far is reducing the picture entity size to 70%, removed the word “Battery” and removed the border around the entity-picture. All changes to make it fit better.
image

I changed the columns and that seems to have fixed it.
- grid-template-columns: 2fr 1fr changed to - grid-template-columns: 2fr.

It might be due to your theme. I was facing the same issue before but on desktop, when changing screens (on mobile it was looking ok). Changed the theme and it start showing ok.

Sorry, but I’m not sure where the issue may come from.

What did you use to create your avatars?

I copied them from our iPhone/iMessage avatars and then simply added a coloured background to it and saved as a png

2 Likes

Hi @moostmartijn, I’m also interested in your code. Could you share it?
Thanks!

1 Like

@mcfly76

- type: custom:vertical-stack-in-card
        cards:
          - type: horizontal-stack
            cards:
              - type: custom:button-card
                entity: person.martijn
                show_entity_picture: true
                entity_picture: /local/images/martijn_werk.gif
                show_name: true
                show_last_changed: true
                triggers_update: all
                state:
                  - value: home
                    name: 🏡 Thuis
                    entity_picture: /local/images/martijn.gif
                    styles:
                      card:
                        - height: 170px
                      entity_picture:
                        - margin-top: 12px
                        - width: 60%
                        - position: relative
                      name:
                        - color: "#7DDA9F"

                  - value: Werk
                    name: 🏥 Werk
                    entity_picture: /local/images/martijn_werk.gif
                    styles:
                      card:
                        - height: 170px
                      name:
                        - color: "#7DDA9F"
                      entity_picture:
                        - width: 60%
                        - position: relative
                        - margin-top: 20px

                  - value: not_home
                    name: |
                      [[[
                        return `🗺️ ${states['sensor.martijn_stad'].state}`                                                   
                      ]]]
                    entity_picture: /local/images/martijn.gif
                    styles:
                      card:
                        - height: 170px
                      name:
                        - color: "#93ADCB"
                      entity_picture:
                        - margin-top: 12px
                        - opacity: 0.3
                        - width: 60%
                        - position: relative

                  - value: unknown
                    name: |
                      [[[
                        return `🗺️ ${states['sensor.martijn_stad'].state}`                                                   
                      ]]]
                    operator: default
                    entity_picture: /local/images/martijn.gif
                    styles:
                      card:
                        - height: 170px
                      entity_picture:
                        - margin-top: 12px
                        - opacity: 0.3
                        - width: 60%
                        - position: relative
                      name:
                        - color: gray
                custom_fields:
                  activity: |
                    [[[
                      if (states['sensor.iphone_max_activity'].state == 'Walking')
                      return `<img src="/local/images/martijn_walking.png" style="width:16px; height:16px"></img>`
                      if (states['sensor.iphone_max_activity'].state == 'Running')
                      return `<img src="/local/images/martijn_running.png" style="width:16px; height:16px"></img>`
                      if (states['sensor.iphone_max_activity'].state == 'Automotive')
                      return `<img src="/local/images/martijn_auto.png" style="width:16px; height:16px"></img>`
                      if (states['sensor.iphone_max_activity'].state == 'Cycling')
                      return `<img src="/local/images/martijn_bike.png" style="width:16px; height:16px"></img>`                                                  
                      else return ""
                    ]]]
                  battery: |
                    [[[
                      var i = states['sensor.iphone_max_battery_level'].attributes.icon;
                      var b = states['sensor.iphone_max_battery_level'].state;
                      return `${b}%<span style='vertical-align: 1px'></span><ha-icon icon='${i}' style='width: 16px; vertical-align:2px'></ha-icon>`
                    ]]]
                  traveltime: |
                    [[[
                      if (states['sensor.martijn_thuis'].state == 0)
                      return ""
                      else return `<ha-icon
                          icon="mdi:clock"
                          style="width: 16px; height: 16px; vertical-align: 2px; padding-right: 2px">
                          </ha-icon>${
                        states['sensor.martijn_thuis'].state
                      }`
                    ]]]
                  distance: |
                    [[[
                      if (states['sensor.martijn_distance'].state <= 0.2)
                      return ""
                      else return `<ha-icon
                          icon="mdi:map-marker-distance"
                          style="width: 16px; height: 16px; vertical-align: 2px; padding-right: 1px">
                          </ha-icon>${
                        states['sensor.martijn_distance'].state
                      }`
                    ]]]
                  albert_heijn: |
                    [[[
                      if (states['person.martijn'].state == 'Albert Heijn')
                      return `<img src="/local/images/ah.png" style="width:25px; height:25px"></img>`
                      else return ""
                    ]]]
                styles:
                  name:
                    - font-size: 16px
                  label:
                    - font-size: 8px
                  icon:
                    - width: 80%
                    - position: absolute
                    - top: 1%
                  custom_fields:
                    albert_heijn:
                      - height: 30%
                      - width: 30%
                      - position: absolute
                      - top: 45%
                      - left: 10%
                    activity:
                      - height: 20%
                      - position: absolute
                      - top: 15%
                      - right: 2px
                    distance:
                      - position: absolute
                      - left: 2px
                      - top: 2px
                      - font-size: 12px
                    traveltime:
                      - position: absolute
                      - left: 2px
                      - top: 15%
                      - font-size: 12px
                    battery:
                      - align-self: right
                      - position: absolute
                      - right: 2px
                      - top: 2%
                      - font-size: 12px
                      - color: >-
                          [[[ if (states["sensor.iphone_max_battery_level"].state < 30) return
                          "#e45649"; if (states["sensor.iphone_max_battery_level"].state < 50)
                          return "#ffa229"; if (states["sensor.iphone_max_battery_level"].state <
                          101) return "#50A14F"; else return "#ffc640"]]]

              - type: custom:button-card
                entity: person.jildou
                show_entity_picture: true
                entity_picture: /local/images/jildou_werk.gif
                show_name: true
                show_last_changed: true
                triggers_update: all
                state:
                  - value: home
                    name: 🏡 Thuis
                    entity_picture: /local/images/jildou.gif
                    styles:
                      card:
                        - height: 170px
                      entity_picture:
                        - width: 60%
                        - position: relative
                      name:
                        - color: "#7DDA9F"

                  - value: Werk
                    name: 🏥 Werk
                    entity_picture: /local/images/jildou_werk.gif
                    styles:
                      card:
                        - height: 170px
                      name:
                        - color: "#7DDA9F"
                      entity_picture:
                        - width: 70%
                        - margin-top: 24px
                        - position: relative

                  - value: not_home
                    name: |
                      [[[
                        return `🗺️ ${states['sensor.jildou_stad'].state}`                                                   
                      ]]]
                    entity_picture: /local/images/jildou.gif
                    styles:
                      card:
                        - height: 170px
                      name:
                        - color: "#93ADCB"
                      entity_picture:
                        - opacity: 0.3
                        - width: 60%
                        - position: relative

                  - value: unknown
                    name: |
                      [[[
                        return `🗺️ ${states['sensor.jildou_stad'].state}`                                                   
                      ]]]
                    operator: default
                    entity_picture: /local/images/jildou.gif
                    styles:
                      card:
                        - height: 170px
                      name:
                        - color: gray
                      entity_picture:
                        - opacity: 0.3
                        - width: 60%
                        - position: relative

                custom_fields:
                  activity: |
                    [[[
                      if (states['sensor.xq_at51_detected_activity'].state == 'walking')
                      return `<img src="/local/images/jildou_on_foot.png" style="width:16px; height:16px"></img>`
                      if (states['sensor.xq_at51_detected_activity'].state == 'running')
                      return `<img src="/local/images/jildou_running.png" style="width:16px; height:16px"></img>`
                      if (states['sensor.xq_at51_detected_activity'].state == 'on_foot')
                      return `<img src="/local/images/jildou_on_foot.png" style="width:16px; height:16px"></img>`
                      if (states['sensor.xq_at51_detected_activity'].state == 'in_vehicle')
                      return `<img src="/local/images/jildou_auto.png" style="width:16px; height:16px"></img>`
                      if (states['sensor.xq_at51_detected_activity'].state == 'on_bicycle')
                      return `<img src="/local/images/jildou_bike.png" style="width:16px; height:16px"></img>`                                                   
                      else return ""
                    ]]]
                  battery: |
                    [[[
                      var i = states['sensor.xq_at51_batterijniveau'].attributes.icon;
                      var b = states['sensor.xq_at51_batterijniveau'].state;
                      return `${b}%<span style='vertical-align: 0px'></span><ha-icon icon='${i}' style='width: 16px; vertical-align:3px'></ha-icon>`
                    ]]]
                  distance: |
                    [[[
                      if (states['sensor.jildou_distance'].state <= 0.2)
                      return ""
                      else return `<ha-icon
                          icon="mdi:map-marker-distance"
                          style="width: 16px; height: 16px; vertical-align: 2px; padding-right: 1px">
                          </ha-icon>
                          ${
                          states['sensor.jildou_distance'].state
                          }`
                    ]]]
                  traveltime: |
                    [[[
                      if (states['sensor.jildou_thuis'].state == 0)
                      return ""
                      else return `<ha-icon
                          icon="mdi:clock"
                          style="width: 16px; height: 16px; vertical-align: 2px; padding-right: 1px">
                          </ha-icon>
                          ${
                          states['sensor.jildou_thuis'].state
                          }`
                    ]]]
                  albert_heijn: |
                    [[[
                      if (states['person.jildou'].state == 'Albert Heijn')
                      return `<img src="/local/images/ah.png" style="width:25px; height:25px"></img>`
                      else return ""
                    ]]]
                styles:
                  name:
                    - font-size: 16px
                  label:
                    - font-size: 8px
                  custom_fields:
                    albert_heijn:
                      - height: 30%
                      - width: 30%
                      - position: absolute
                      - top: 15%
                      - left: 10%
                    activity:
                      - height: 20%
                      - position: absolute
                      - top: 15%
                      - right: 2px
                    distance:
                      - position: absolute
                      - left: 2px
                      - top: 2px
                      - font-size: 12px
                    traveltime:
                      - position: absolute
                      - left: 2px
                      - top: 15%
                      - font-size: 12px
                    battery:
                      - align-self: left
                      - position: absolute
                      - right: 2px
                      - top: 2%
                      - font-size: 12px
                      - color: >-
                          [[[ if (states["sensor.xq_at51_batterijniveau"].state < 30) return
                          "#e45649"; if (states["sensor.xq_at51_batterijniveau"].state < 50)
                          return "#ffa229"; if (states["sensor.xq_at51_batterijniveau"].state <
                          101) return "#50A14F"; else return "#ffc640"]]]
                  icon:
                    - width: 80%
                    - position: absolute
                    - top: 1%
1 Like

Hello, please tell us noobies where the template code goes to exactly. i put it in every place i can think of but it’s not working for me.
Thank you

I know this is sort of outside the scope of this thread, but I’m having trouble with getting different pictures to render. Most specifically, this section of your card setup:

cards:
  - variables:
      person: person.agata
      bg: |
        [[[
          if (states['person.agata'].state == 'home' )
            return '#191f2b';
          return 'url(/local/agata/' + states['person.agata'].state +
        '.png';
        ]]]

I see that the custom:button-card will look for pictures in local, but it isn’t working for me. I am using HomeAssistant OS on an SBC.

If you have setup media_dirs in your configuration.yaml, would you mind sharing what you have? Hoping to mirror what you have by looking for these answers:

  • Your media_dirs setup in your configuration.yml.
  • Your directory tree, i.e. where is your agata directory and the pictures.

Thanks, man!

I am quite sure that local refers to /config/www/ path. This is relative to Home Assistant so you should be able to get it working by placing you files on agata folder on /config/www/agata/

Hope this helps

1 Like

Yep. That worked! Thanks for clearing that up so quickly!

Ey @moostmartijn could you tell me where do you get those emojis with movement? Thank you!

You can make them on an iPhone. They’re called memoji’s. You can save them as a video and with some other (online) tools you can remove the background and save them as a .gif

2 Likes

Hi @benm7

Sorry to ressurect this.

I’m trying to reverse engineer your custom_fields, and I am failing miserably.

I understood what the if does, but I can’t figure out how, from the declutter template, it will correctly read my and my wife mobile battery status:

On the view/card itself, now the battery shows “undefined%” with the charging icon (device is not charging at the moment).

I tried to to get closer to the entities i have (instead of battery_charging to battery_is_charging, but no lucky.

The other fields from the card are working (honestly, not sure how, but hey, it is showing different times to work from me and wife, so yeah, it is working :slight_smile: ) Just the battery is testing me. Any help would be appreciated.

Tks!

2 Likes

johnperson

When the phone is charging the icon blinks and changes color. I’m not concerned about showing my location here… LOL I mean you can look me up on the internet my address is all over the place [so I found out LOL]. Not sure why Signal Strength says that but at times it just does, most of the time it reports no issues.

When I’m traveling it’s say “Traveling…” and then when I stop it reports the location :slight_smile: When I’m home it’ll say “John is Home” when I’m elsewhere it’ll just say “John is here”

The icons inbetween are just quick references for me to see if any doors or windows are open. What the temp is inside the house and if the AC is on. Tells me if the door is locked and cameras are armed. [The location is a good reference as I’m a contractor and in these times one never knows. I’m all over the place so my wife can at least know where I am, it makes her feel better :)]

This is a copy of @Posreg and his card. I’ve just modified it a bit and added to it. Thanks again @Posreg !!!

And the code:

- type: custom:stack-in-card
        mode: vertical
        card_mod:
        style: |
          ha-card {
          background-color: rgba(255, 255, 255, .1);
          }
        cards:
          - type: custom:stack-in-card
            mode: horizontal
            cards:
              - type: custom:mushroom-person-card
                entity: device_tracker.sm_f926u1
                icon_type: entity-picture
                hide_name: true
                layout: vertical
                secondary_info: state
              - type: conditional
                conditions:
                  - entity: sensor.sm_f926u1_battery_state
                    state: "charging"
                card:
                  type: custom:mushroom-template-card
                  entity: sensor.sm_f926u1_battery_level
                  layout: vertical
                  icon_color: yellow
                  fill_container: true
                  name: Fold3
                  icon: mdi:battery-charging-medium
                  hide_name: true
                  primary: "Battery Level: {{ states('sensor.sm_f926u1_battery_level') }}%"
                  secondary: "Signal Strength: {{ states('person.john_s_z_fold3_signal_strength') }}%"
                  card_mod:
                    style: |
                      mushroom-shape-icon {
                        animation: blink 1s linear infinite;
                      }          
                      @keyframes blink {
                        50% {opacity: 0;}
                      }
              - type: conditional
                conditions:
                  - entity: sensor.sm_f926u1_battery_state
                    state: "discharging"
                card:
                  type: custom:mushroom-template-card
                  entity: sensor.sm_f926u1_battery_level
                  layout: vertical
                  icon: |2
                      {% set bl = states('sensor.sm_f926u1_battery_level') | int %}
                      {% if bl < 10 %} mdi:battery-outline
                      {% elif bl < 20 %} mdi:battery-10
                      {% elif bl < 30 %} mdi:battery-20
                      {% elif bl < 40 %} mdi:battery-30
                      {% elif bl < 50 %} mdi:battery-40
                      {% elif bl < 60 %} mdi:battery-50
                      {% elif bl < 70 %} mdi:battery-60
                      {% elif bl < 80 %} mdi:battery-70
                      {% elif bl < 90 %} mdi:battery-80
                      {% elif bl < 100 %} mdi:battery-90
                      {% elif bl == 100 %} mdi:battery
                      {% else %} mdi:battery-unknown
                      {% endif %}
                  icon_color: |2-
                              {% set bl = states('sensor.sm_f926u1_battery_level') | int %}
                              {% if bl < 10 %} #cc0c16
                              {% elif bl < 20 %} #e61e28
                              {% elif bl < 30 %} #e3464e
                              {% elif bl < 40 %} orange
                              {% elif bl < 50 %} #f0b93a
                              {% elif bl < 60 %} #f3f56c
                              {% elif bl < 70 %} #f2f536
                              {% elif bl < 80 %} #69f095
                              {% elif bl < 90 %} #2ee669
                              {% elif bl < 100 %} #05ad3b
                              {% elif bl == 100 %} #03872d
                              {% else %} grey
                              {% endif %}
                  primary: "Battery Level: {{ states('sensor.sm_f926u1_battery_level') }}%"
                  secondary: "Signal Strength: {{ states('sensor.john_s_z_fold3_signal_strength') }}%"
                  tap_action:
                    action: more-info
                  fill_container: true
          - type: custom:mushroom-chips-card
            chips:
              - type: entity
                entity: binary_sensor.front_door_sensor_contact
                content_info: none
              - type: entity
                entity: binary_sensor.back_door_sensor_contact
                content_info: none
              - type: entity
                entity: binary_sensor.bedroom_window_sensor_contact
                content_info: none
              - type: entity
                entity: binary_sensor.right_kitchen_window_contact
                content_info: none
              - type: entity
                entity: binary_sensor.sink_kitchen_window_contact
                content_info: none
              - type: entity
                entity: binary_sensor.tv_window_sensor_contact
                content_info: none
              - type: template
                content: >-
                  {{ states('sensor.living_room_temp_sensor_temperature')| round (0)}}°F
                tap_action:
                  action: none
              - type: entity
                entity: lock.front_door_lock_2
                content_info: none
              - type: entity
                entity: alarm_control_panel.blink_johns_house
                content_info: none
              - type: template
                content: >-
                  {{ states('climate.john_s_device')}}
                tap_action:
                  action: none
              - type: entity
                entity: sensor.blink_back_yard_temperature
                content_info: none
          - type: custom:mushroom-template-card
            entity: sensor.john
            primary: >
              {% if (state_attr('sensor.john', 'direction_of_travel') == 'stationary') and (state_attr('sensor.john','home_zone') == 'zone.home') %}
              John is Home:
              {% elif (state_attr('sensor.john', 'direction_of_travel') == 'stationary')%}
              John is Here:              
              {% else %}
              John is
              {% endif %}
            secondary: >
              {% if (state_attr('sensor.john','direction_of_travel') == 'stationary') %}
              {{ state_attr('sensor.john','street_number') }} {{
              state_attr('sensor.john','street') }}, {{
              state_attr('sensor.john','city') }}, {{
              state_attr('sensor.john','postal_code') }}
              {% else %}
              Traveling...
              {% endif %}
            icon: >-
              {% if (state_attr('sensor.john','direction_of_travel') == 'stationary') and (states('device_tracker.sm_f926u1') == 'home') %} mdi:home-account
              {% elif (state_attr('sensor.john','direction_of_travel') == 'stationary') and (states('device_tracker.sm_f926u1') == 'not_home') %} mdi:domain
              {% else %} mdi:car
              {% endif %}
            icon_color: >-
              {% if (state_attr('sensor.john','direction_of_travel') == 'stationary') and (states('device_tracker.sm_f926u1') == 'home') %} green
              {% elif (state_attr('sensor.john','direction_of_travel') == 'stationary') and (states('device_tracker.sm_f926u1') == 'not_home') %} blue
              {% else %} cyan
              {% endif %}
            multiline_secondary: true

          - type: map
            default_zoom: 16
            entities:
              - device_tracker.sm_f926u1
            aspect_ratio: 1.95:1
3 Likes

Thanks for sharing and great job!
Can you share your code for the signal strength sensor and the direction_of_travel? I have the sensor.places installed but I don’t quite have the direction part down.

1 Like

The signal strength sensor populates itself it’s nothing I wrote. I’m using a Samsung Fold 3 so it just shows up as a sensor automatically.

The direction_of_travel is an attribute of places… so in my configuration.yaml I put this:

sensor places_john:
  - platform: places
    name: john
    devicetracker_id: device_tracker.sm_f926u1
    options: zone,place
    map_provider: google
    map_zoom: 19
    home_zone: zone.home
    api_key: !secret email_john  

Put your email in the secrets.yaml →

email_john: [email protected]

Then places kicks in and gives you a sensor called:

sensor.john

From that all your attributes are there:

street_number: 525
street: Budd Street
city: City of Elmira
postal_town: -
postal_code: 14904
state_province: New York
country: United States
county: Chemung County
formatted_address: 525, Budd Street, Southport, City of Elmira, Chemung County, New York, 14904, United States
place_type: building
place_name: -
place_category: building
neighbourhood: -
previous_latitude: 42.062969
previous_longitude: -76.8058404
current_latitude: 42.0628869
current_longitude: -76.8059342
devicetracker_entityid: device_tracker.sm_f926u1
devicetracker_zone: home
home_zone: zone.home
entity_picture: null
distance_from_home_km: 0.0 km
distance_from_home_m: 4.654
last_changed: 2022-07-13 14:33:17.772622
current_location: 42.0628869,-76.8059342
previous_location: 42.062969,-76.8058404
home_latitude: 42.06291457651508
home_longitude: -76.80589199066164
direction_of_travel: stationary
map_link: https://www.google.com/maps/search/?api=1&basemap=roadmap&layer=traffic&query=42.0628869,-76.8059342
options: zone,place
friendly_name: john

From that I made this:

- type: custom:mushroom-template-card
            entity: sensor.john
            primary: >
              {% if (state_attr('sensor.john', 'direction_of_travel') == 'stationary') and (state_attr('sensor.john','home_zone') == 'zone.home') %}
              John is Home:
              {% elif (state_attr('sensor.john', 'direction_of_travel') == 'stationary')%}
              John is Here:              
              {% else %}
              John is
              {% endif %}
            secondary: >
              {% if (state_attr('sensor.john','direction_of_travel') == 'stationary') %}
              {{ state_attr('sensor.john','street_number') }} {{
              state_attr('sensor.john','street') }}, {{
              state_attr('sensor.john','city') }}, {{
              state_attr('sensor.john','postal_code') }}
              {% else %}
              Traveling...
              {% endif %}
            icon: >-
              {% if (state_attr('sensor.john','direction_of_travel') == 'stationary') and (states('device_tracker.sm_f926u1') == 'home') %} mdi:home-account
              {% elif (state_attr('sensor.john','direction_of_travel') == 'stationary') and (states('device_tracker.sm_f926u1') == 'not_home') %} mdi:domain
              {% else %} mdi:car
              {% endif %}
            icon_color: >-
              {% if (state_attr('sensor.john','direction_of_travel') == 'stationary') and (states('device_tracker.sm_f926u1') == 'home') %} green
              {% elif (state_attr('sensor.john','direction_of_travel') == 'stationary') and (states('device_tracker.sm_f926u1') == 'not_home') %} blue
              {% else %} cyan
              {% endif %}
            multiline_secondary: true

I hope that helps :slight_smile:

1 Like

It does! Thanks so much!

1 Like

I switched this line back to the original because the signal strength works then it doesn’t for some reason…

THIS →

secondary: "Signal Strength: {{ states('sensor.john_s_z_fold3_signal_strength') }}%"

Back to THIS →

secondary: "Battery Temp: {{ states('sensor.sm_f926u1_battery_temperature') }}°"