Person Cards - Show Off Yours

It is, yes. I’ve tried both capitalized and non-capitalized, just in case. And I can force it in Developer Tools–>States as needed.

I’m using custom button cards elsewhere, but nowhere am I doing what I want to do here: display a different local image based on entity state.

EDIT: Oh, wait… sensor.status_person1 isn’t a toggleable entity. Isn’t that a limitation of the custom button card? If that’s the case… I may have to accomplish this with conditional cards instead.

EDIT 2: I’ll just add a new comment below…

OK, I’ve tweaked this more or less to my liking. A couple of changes I made to @VaReTaS’s excellent card:

  • I use a separate sensor for each person to populate location from either defined zones or from an input_select which determines whether each person is Home, Away, Just Left, Just Arrived, or Extended Away. Those states come out of a Node-RED flow I put in place a few years ago (can share if interested), and the sensors just provide more detail than “Home” or “Away:”

  • On the card itself, I’ve replaced the battery and Wi-Fi sensors when the person is away. I’ve also added a time for when the person either left or arrived at home. I didn’t change any of the custom field names, though, so hopefully it’s not too confusing!

updated YAML for sensors & cards in this comment below

The result is a card that shows different info based on whether the person is home or away. On the left is a home person. On the right is an away person at a known location (defined zone). If a person is away and not in a defined zone, the border is red.

I’m sure I could lay this out a bit better, but it’s way more informative than my person cards were this time last week.

I never actually got the Proximity sensors to work, so I can’t add direction of travel as a sensor to this card. That might be the only thing I can think I would add at this time.

EDIT: I thought I might add the ability to call people from this card (!) using hold_action: navigate, but so far it’s not working for me:

hold_action:
  action: navigate
  navigation_path: tel:+15555555555

EDIT 2: updated arrival/departure sensors using from those in this post. Waaaay better.

4 Likes

This looks just great :+1: :clap:

I will certainly take some of your ideas and modify mine when I have some time

I’ll post code for some further updated cards.

Unfortunately, my device_tracker entities have completely stopped working with 2022.11.2, so I’ll be rolling back today to see if I can get them working. I’ve posted about it but I’m getting no input yet.

EDIT: device_tracker entities now working.

Here’s the updated cards:

see this comment for YAML

Firstly, love your person card setup. I’ve more or less recreated it on mine, but with one huge exception; it looks nothing like yours. I’m almost certain that it has to do with the theme - would you mind please sharing what theme you’ve used?

Gladly… I’m using a theme called Midnight.
I load it through automation like this:

- alias: 01 - Set Default Theme to Midnight on Startup
  id: Set Default Theme to Midnight on Startup
  initial_state: true
  trigger:
    - event: start
      platform: homeassistant
  action:
    - data:
        name: midnight
      service: frontend.set_theme

it’s located in this file…
Midnight Theme

This is in a file called themes.yaml

But also make sure you have -
stack-in-card
mushroom card
both loaded…
Here’s what mine looks like now I’m sure i"ve changed it since that post:

 - type: custom:stack-in-card
        mode: vertical
        card_mod:
        style: |
          ha-card {
          background-color: rgba(255, 255, 255, .1);
          border: 0 !important;
          }
        cards:
          - type: custom:stack-in-card
            mode: horizontal
            card_mod:
                style: |
                  ha-card { 
                  border: 0 !important;
                  }
            cards:
              - type: custom:mushroom-person-card
                entity: person.john
                icon: " "
                icon_type: icon
                primary_info: none
                secondary_info: none
                card_mod:
                  style: |
                    mushroom-card { 
                      background: url( {{ state_attr('person.john', 'entity_picture') }} ) no-repeat 0px center;
                      background-size: 42px 42px;
                      border: 0 !important;
                    }
                    ha-card {
                      background-color: rgba(255, 255, 255, .7);
                      margin-left: auto;
                      margin-right: auto;
                      width: 66px;
                      border: 0 !important;
                    }

              - type: conditional
                card_mod:
                style: |
                  ha-card { 
                  border: 0 !important;
                  }
                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: "Phone is charging..."
                  secondary: "Battery Level: {{ states('sensor.sm_f926u1_battery_level') }}%"
                  card_mod:
                    style: |
                      mushroom-shape-icon {
                        animation: blink 1s linear infinite;
                      }          
                      @keyframes blink {
                        50% {opacity: 0;}
                      }
                      ha-card { 
                      border: 0 !important;
                      }
              - type: conditional
                conditions:
                  - entity: sensor.sm_f926u1_battery_state
                    state: "full"
                card:
                  type: custom:mushroom-template-card
                  card_mod:
                    style: |
                      ha-card { 
                      border: 0 !important;
                      }
                  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: "Battery Temp: {{ states('sensor.sm_f926u1_battery_temperature') }}°"
                  tap_action:
                    action: more-info
                  fill_container: true
              - type: conditional
                card_mod:
                style: |
                  ha-card { 
                  border: 0 !important;
                  }
                conditions:
                  - entity: sensor.sm_f926u1_battery_state
                    state: "discharging"
                card:
                  type: custom:mushroom-template-card
                  card_mod:
                    style: |
                      ha-card { 
                      border: 0 !important;
                      }
                  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: "Battery Temp: {{ states('sensor.sm_f926u1_battery_temperature') }}°"
                  tap_action:
                    action: more-info
                  fill_container: true
                styles:
                  card:
                    height: 66px;

          - type: custom:mushroom-template-card
            entity: sensor.john
            card_mod:
                style: |
                  ha-card { 
                  border: 0 !important;
                  }
            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 %}
            tap_action:
              action: fire-dom-event
              browser_mod:
                title: John's Location

                icon: mdi:car
                service: browser_mod.popup
                data:
                  size: normal
                  title: Where is John?
                  style: |-
                    --popup-min-width: 500px; --popup-max-width: 670px;
                    --popup-border-radius: 0 !important;
                    --popup-background-color: #B33B00;
                    --popup-border-width: 0 !important;
                  content:
                    type: map
                    default_zoom: 15
                    entities:
                      - device_tracker.sm_f926u1
                    aspect_ratio: 16:9
                    hours_to_show: 4
                    browser_id:
                      - this
                      - dashboard
            multiline_secondary: true

hello DeltaNu1142,

Love your card.
Some (silly) questions, due to not having entire workframe in your code, also not node-red user

  1. Can you please share input select and how you made just left/just arrived states for person ?
  2. for arrival/departing sensors you use an automation ? because I see is the same sensor
  3. i see as a result that sensor is telling me i stay home from 11:13 PM, but I want to have 24h display, not AM/PM. what can do the trick ?

Thank you

1 Like

I’d love to provide more information, but right now my device_trackers are broken. My input_selects for user status is statused by a Node-RED flow.

OK, I’m back on track. Here are some updated sensors. The arrival and departure sensors are the same, except for when they’re triggered. Note I’ve made some changes to the sensor names for consistency, and I’ve added the update card YAML as well.

Sensors:

  - sensor:
    - unique_id: distance_from_home_Person2
      name: Distance from Home Person2
      state: >
        {{ distance('person.Person2','zone.home') | round(1) }}
  - sensor:
    - unique_id: distance_from_home_Person1
      name: Distance from Home Person1
      state: >
        {{ distance('person.Person1','zone.home') | round(1) }}
  - trigger:
      - platform: state
        entity_id: person.Person2
        to: 'home'
    sensor:
    - unique_id: time_arrived_home_Person2
      name: Time Arrived Home Person2
      icon: "mdi-home-clock"
      state: >
          {% set last_changed = states.person.Person2.last_changed | as_local %}
          {% if last_changed < today_at() - timedelta(days=1) %}
            {{ last_changed.strftime('%A at %-I:%M %p') }}
          {% elif last_changed < today_at() %}
            {{ last_changed.strftime('yesterday %-I:%M %p') }}
          {% else %}
            {{ last_changed.strftime('at %-I:%M %p') }}
          {% endif %}

  - trigger:
      - platform: state
        entity_id: person.Person1
        to: 'home'
    sensor:
    - unique_id: time_arrived_home_Person1
      name: Time Arrived Home Person1
      icon: "mdi-home-clock"
      state: >
          {% set last_changed = states.person.Person1.last_changed | as_local %}
          {% if last_changed < today_at() - timedelta(days=1) %}
            {{ last_changed.strftime('%A at %-I:%M %p') }}
          {% elif last_changed < today_at() %}
            {{ last_changed.strftime('yesterday %-I:%M %p') }}
          {% else %}
            {{ last_changed.strftime('at %-I:%M %p') }}
          {% endif %}
  - trigger:
    - platform: state
      entity_id: person.Person2
      from: 'home'
    sensor:
    - unique_id: time_left_home_Person2
      name: Time Left Home Person2
      icon: "mdi-home-clock"
      state: >
        {% set last_changed = states.person.Person2.last_changed | as_local %}
        {% if last_changed < today_at() - timedelta(days=1) %}
          {{ last_changed.strftime('%-I:%M %p on %A') }}
        {% elif last_changed < today_at() %}
          {{ last_changed.strftime('%-I:%M %p yesterday') }}
        {% else %}
          {{ last_changed.strftime('%-I:%M %p') }}
        {% endif %}
  - trigger:
    - platform: state
      entity_id: person.Person1
      from: 'home'
    sensor:
    - unique_id: time_left_home_Person1
      name: Time Left Home Person1
      icon: "mdi-home-clock"
      state: >
        {% set last_changed = states.person.Person1.last_changed | as_local %}
        {% if last_changed < today_at() - timedelta(days=1) %}
          {{ last_changed.strftime('%-I:%M %p on %A') }}
        {% elif last_changed < today_at() %}
          {{ last_changed.strftime('%-I:%M %p yesterday') }}
        {% else %}
          {{ last_changed.strftime('%-I:%M %p') }}
        {% endif %}

Card:

type: custom:button-card
entity: sensor.status_person1
aspect_ratio: 1/1
name: person1
show_entity_picture: true
show_name: false
hold_action:
  action: none
state:
  - value: Home
    styles:
      custom_fields:
        icon:
          - border-color: '#36c570'
  - value: Just Arrived
    styles:
      custom_fields:
        icon:
          - border-color: '#36c570'
  - value: Zone1
    styles:
      card: null
      custom_fields:
        icon:
          - border-color: '#4456e5'
  - value: Zone2
    styles:
      card: null
      custom_fields:
        icon:
          - border-color: '#4456e5'
  - value: Zone3
    styles:
      card: null
      custom_fields:
        icon:
          - border-color: '#4456e5'
  - value: Just Left
    styles:
      card: null
      custom_fields:
        icon:
          - border-color: '#e54456'
  - value: default
    styles:
      card: null
      custom_fields:
        icon:
          - border-color: '#e54456'
styles:
  card:
    - background-color: rgba(7, 103, 215, 0.24)
    - border-radius: 5%
    - padding: 5%
    - color: gray
    - font-size: 10px
    - text-shadow: 0px 0px 0px black
    - justify-self: end
    - align-self: middle
  grid:
    - grid-template-areas: >-
        "icon status" "n n" "homeclock waze" "batterydistance wifidrivetime" "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: white
    homeclock:
      - padding: 0.5em 0px
      - align-self: middle
      - justify-self: start
      - color: white
    wifidrivetime:
      - padding: 0.5em 0px
      - align-self: left
      - justify-self: end
      - color: white
    batterydistance:
      - padding: 0.5em 0px
      - align-self: middle
      - justify-self: start
      - color: white
    waze:
      - padding: 0.5em 0px
      - align-self: left
      - justify-self: end
      - color: white
      - '--text-color-sensor': >-
          [[[ if (states["sensor.waze_travel_time_person1"].state > 60) return
          "#EF4F1A"; ]]]
custom_fields:
  icon: >
    [[[ return entity === undefined ? null : `<img
    src="${states[entity.entity_id].attributes.entity_picture}" width="100%">`;
    ]]]
  status: |
    [[[
      if (states['person.person1'].state !='home') { 
      return `<ha-icon icon="mdi:home-export-outline"
        style="width: 20px; height: 20px; color: '#888888';">
        </ha-icon><span> ${states['sensor.status_person1'].state}</span>`;
      } 
      if (states['person.person1'].state =='home') { 
      return `<ha-icon 
        icon="mdi:home"
        style="width: 20px; height: 20px; color: #ffffff;">
        </ha-icon><span> ${states['sensor.status_person1'].state}</span>`;
      } else {
      return `<ha-icon 
        icon="mdi:map-marker-radius"
        style="width: 20px; height: 20px; color: #ffffff;">
        </ha-icon><span> ${states['sensor.status_person1'].state}</span>`;
      }
    ]]]
  homeclock: |
    [[[
      if (states['person.person1'].state !='home') { 
      return `<ha-icon 
        icon="mdi:home-clock"
        style="width: 20px; height: 20px; color: #ffffff;">
        </ha-icon><span> Left ${states['sensor.time_left_home_person1'].state}</span>`;
      } 
      if (states['person.person1'].state =='home') { 
      return `<ha-icon 
        icon="mdi:home-clock"
        style="width: 20px; height: 20px; color: #ffffff;">
        </ha-icon><span> Arrived ${states['sensor.time_arrived_home_person1'].state}</span>`;
      } else {
      return
      }
    ]]]
  waze: |
    [[[
      return ;
    ]]]
  batterydistance: |
    [[[
      if (states['person.person1'].state != 'home' && states['sensor.distance_from_home_person1'].state <= 5) { 
      return `<ha-icon
        icon="mdi:map-marker-distance"
        style="width: 20px; height: 20px; color: #36c570;">
        </ha-icon>  <span>\<span style="color: #36c570;">${states['sensor.distance_from_home_person1'].state} mi</span></span>`;
      }
      if (states['person.person1'].state != 'home' && states['sensor.distance_from_home_person1'].state > 5) { 
        return `<ha-icon
        icon="mdi:map-marker-distance"
        style="width: 20px; height: 20px; color: white;">
        </ha-icon>  <span>\<span style="color: white;">${states['sensor.distance_from_home_person1'].state} mi</span></span>`;
      }
      if (states['sensor.person1s_iphone_battery_state'].state == 'charging') { 
        return `<ha-icon
        icon="mdi:battery-charging"
        style="width: 20px; height: 20px; color: #36c570;">
        </ha-icon> <span><span style="color: #36c570;">${states['sensor.person1s_iphone_battery_level'].state}%</span></span>`;
      } else {
        return `<ha-icon
        icon="mdi:battery"
        style="width: 20px; height: 20px; color: white;">
        </ha-icon> <span><span style="color: var(--text-color-sensor);">${states['sensor.person1s_iphone_battery_level'].state}%</span></span>`;
      }
    ]]]
  wifidrivetime: |
    [[[
      if (states['person.person1'].state != 'home' && states['sensor.waze_travel_time_person1'].state <= 5) { 
      return `<ha-icon
        icon="mdi:car-clock"
        style="width: 20px; height: 20px; color: #36c570;">
        </ha-icon>  <span>\<span style="color: #36c570;">${states['sensor.waze_travel_time_person1'].state} min</span></span>`;
      }
      if (states['person.person1'].state != 'home' && states['sensor.waze_travel_time_person1'].state > 5) { 
        return `<ha-icon
        icon="mdi:car-clock"
        style="width: 20px; height: 20px; color: white;">
        </ha-icon>  <span>\<span style="color: white;">${states['sensor.waze_travel_time_person1'].state} min</span></span>`;
      }
      if (states['person.person1'].state == 'home' && states['sensor.person1s_iphone_ssid'].state == 'Not Connected') { 
        return `<ha-icon
        icon="mdi:wifi-off"
        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: white;">
        </ha-icon> <span><span style="color: var(--text-color-sensor);">${states['sensor.person1s_iphone_ssid'].state}</span></span>`;
      }
    ]]]
2 Likes

Glad you are back on track.
How can I do that part without node-red?

  - trigger:
    - platform: state
      entity_id: person.Person1
      from: 'home'
    sensor:
    - unique_id: time_left_home_Person1
      name: Time Left Home Person1
      icon: "mdi-home-clock"
      state: >
        {% set last_changed = states.person.Person1.last_changed | as_local %}
        {% if last_changed < today_at() - timedelta(days=1) %}
          {{ last_changed.strftime('%-I:%M %p on %A') }}
        {% elif last_changed < today_at() %}
          {{ last_changed.strftime('%-I:%M %p yesterday') }}
        {% else %}
          {{ last_changed.strftime('%-I:%M %p') }}
        {% endif %}

Which part, the Home/Away/Just Arrived/Just Left/Extended Away status-ing? Well, I admit I’m not much of a coder, which is why Node-RED was so appealing to me in the first place. Here’s the flow for your review. I’m sure it could be replicated in an automation, but you’d be better off asking a house plant how to do that:

[{"id":"558a8b2b9a9690f8","type":"group","z":"647eafda.c7cfa","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["ce09e65.8f84418","4d8f933f.aa124c","e76d582a.9a8f88","241457b2.2cc128","d5810a67.0f3498","c0187e63.5a9e1","6a5f8f00.23807","8bd1d643.a115e8","712d8721.d63168","c1544077.8f84a","4f5a58f6.75a848","ead2621a.497e1","af79d26f.7b667","4b97a8c9.4c2298","c9866881fd8d599e","3f7bf5cad74c8219"],"x":44,"y":19,"w":1242,"h":182},{"id":"ce09e65.8f84418","type":"switch","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"Home?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"home","vt":"str"},{"t":"eq","v":"not_home","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":360,"y":120,"wires":[["4d8f933f.aa124c","6a5f8f00.23807","8bd1d643.a115e8"],["ead2621a.497e1","712d8721.d63168"]]},{"id":"4d8f933f.aa124c","type":"api-current-state","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"Status?","server":"296c0678.b5f9ca","version":3,"outputs":2,"halt_if":"Just Left","halt_if_type":"str","halt_if_compare":"is_not","entity_id":"input_select.{{topic}}","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":0,"forType":"num","forUnits":"minutes","x":500,"y":100,"wires":[["241457b2.2cc128"],["c1544077.8f84a"]]},{"id":"e76d582a.9a8f88","type":"api-call-service","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"Just Left","server":"296c0678.b5f9ca","version":5,"debugenabled":false,"domain":"input_select","service":"select_option","areaId":[],"deviceId":[],"entityId":[],"data":"{\"entity_id\":\"input_select.{{topic}}\",\"option\":\"Just Left\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":640,"y":140,"wires":[["6a5f8f00.23807"]]},{"id":"241457b2.2cc128","type":"api-call-service","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"Just Arrived","server":"296c0678.b5f9ca","version":5,"debugenabled":false,"domain":"input_select","service":"select_option","areaId":[],"deviceId":[],"entityId":[],"data":"{\"entity_id\":\"input_select.{{topic}}\",\"option\":\"Just Arrived\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":650,"y":80,"wires":[["712d8721.d63168","3f7bf5cad74c8219"]]},{"id":"d5810a67.0f3498","type":"api-call-service","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"Away","server":"296c0678.b5f9ca","version":5,"debugenabled":false,"domain":"input_select","service":"select_option","areaId":[],"deviceId":[],"entityId":[],"data":"{\"entity_id\":\"input_select.{{topic}}\",\"option\":\"Away\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":910,"y":160,"wires":[["8bd1d643.a115e8"]]},{"id":"c0187e63.5a9e1","type":"api-call-service","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"Extended Away","server":"296c0678.b5f9ca","version":5,"debugenabled":false,"domain":"input_select","service":"select_option","areaId":[],"deviceId":[],"entityId":[],"data":"{\"entity_id\":\"input_select.{{topic}}\",\"option\":\"Extended Away\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1180,"y":140,"wires":[[]]},{"id":"6a5f8f00.23807","type":"trigger","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"10min","op1":"","op2":"{\"payload\":{\"data\":{\"option\":\"\"}}}","op1type":"nul","op2type":"json","duration":"10","extend":false,"units":"min","reset":"home","bytopic":"topic","outputs":1,"x":810,"y":160,"wires":[["d5810a67.0f3498"]]},{"id":"8bd1d643.a115e8","type":"trigger","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"24hr","op1":"","op2":"{\"payload\":{\"data\":{\"option\":\"\"}}}","op1type":"nul","op2type":"json","duration":"24","extend":false,"units":"hr","reset":"home","bytopic":"topic","outputs":1,"x":1050,"y":140,"wires":[["c0187e63.5a9e1"]]},{"id":"712d8721.d63168","type":"trigger","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"10min","op1":"","op2":"{\"payload\":{\"data\":{\"option\":\"\"}}}","op1type":"nul","op2type":"json","duration":"10","extend":false,"units":"min","reset":"not_home","bytopic":"topic","outputs":1,"x":810,"y":100,"wires":[["c1544077.8f84a"]]},{"id":"c1544077.8f84a","type":"api-call-service","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"Home","server":"296c0678.b5f9ca","version":5,"debugenabled":false,"domain":"input_select","service":"select_option","areaId":[],"deviceId":[],"entityId":[],"data":"{\"entity_id\":\"input_select.{{topic}}\",\"option\":\"Home\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":910,"y":100,"wires":[[]]},{"id":"4f5a58f6.75a848","type":"trigger-state","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"Person","server":"296c0678.b5f9ca","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"^person\\..*$","entityidfiltertype":"regex","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is_not","comparatorValueDatatype":"prevEntity","comparatorValue":"state"}],"inputs":1,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":true,"x":120,"y":120,"wires":[["af79d26f.7b667"],[]]},{"id":"ead2621a.497e1","type":"api-current-state","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"Status?","server":"296c0678.b5f9ca","version":3,"outputs":2,"halt_if":"Just Left,Away, Extended Away","halt_if_type":"str","halt_if_compare":"does_not_include","entity_id":"input_select.{{topic}}","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":0,"forType":"num","forUnits":"minutes","x":500,"y":140,"wires":[["e76d582a.9a8f88"],[]]},{"id":"af79d26f.7b667","type":"change","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"Change","rules":[{"t":"change","p":"topic","pt":"msg","from":"person.","fromt":"str","to":"","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"payload = \"home\" ? \"home\" : \"not_home\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":215,"y":120,"wires":[["4b97a8c9.4c2298"]],"l":false},{"id":"4b97a8c9.4c2298","type":"rbe","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":265,"y":120,"wires":[["ce09e65.8f84418"]],"l":false},{"id":"c9866881fd8d599e","type":"comment","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"Home Occupancy","info":"","x":1110,"y":80,"wires":[]},{"id":"3f7bf5cad74c8219","type":"link out","z":"647eafda.c7cfa","g":"558a8b2b9a9690f8","name":"Anyone Arrives Home","mode":"link","links":["aeb93daa0114a684"],"x":775,"y":60,"wires":[]},{"id":"296c0678.b5f9ca","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

The Link node is only there because I use the “Just Arrived” state in other flows.

1 Like

:frowning:
don’t understand.
You trigger something I suppose an automation when person1 leaves home, but how you define sensor time_left_home_person1 ? or you update it ?

I think you’re referring to the quoted YAML from this post, right?

This is a template sensor, and the trigger (when the state of Person1 changes from ‘home’ to something else) causes the entity to record the time of the state change.

refer to: Person Cards - Show Off Yours - #135 by farao780

That is a template sensor, not done in Node-RED at all. You can place this in your configuration.yaml file as described here.

done that. sensors looking good. now you update sensors via calling service homeassistant.update entity? because both arrived and left sensors show same thing.

or what is the purpose of:

  - trigger:
    - platform: state
      entity_id: person.Person1
      from: 'home'

@VaReTaS, I don’t suppose you know how I’d add multiple conditions to this statement:

batterydistance:
[...]
              [[[ if (states["sensor.Person1s_iphone_battery_level"].state < 50)
              return "#EF4F1A"; ]]]

?

I tried this:

batterydistance:
[...]
              [[[ if ((states["sensor.Person1s_iphone_battery_level"].state < 50) and (states['sensor.distance_from_home_Person1'].state <= 2)) 
              return "#EF4F1A"; ]]]

…but it didn’t work for me.

…that’s the purpose of the triggers. For one sensor, it triggers the timestamp to be written as the sensor value when Person1 leaves the zone, and for the other sensor, it triggers when Person1 arrives at the zone.

There’s likely a better way to do it. I could probably get away with using just one sensor per person, and then using a conditional statement in the card. This is just the way I did it because–and I reiterate–I’m not a programmer.

thank you for patience
i’m almost there
how can i align home to arrived (not to be in upper right corner , but just above ssid

i have something like that and working:

      - '--text-color-sensor': >-
          [[[
          if (entity.state < 60) return 'lime';
          if (entity.state >= 60 && entity.state < 80) return 'orange';
          else return 'red';]]]
1 Like