I need help, I'm trying to make a card on the panel with an automation, in it I use the entity field and I'm trying to change the person according to the connected profile

hello I need help, I’m trying to make a card on the panel with an automation, in it I use the entity field and I’m trying to change the person according to the connected profile
Is there a way for the dashboard to identify which user is logged in? if so how would i do that, currently i tried this code but it didn’t work

entity: |-
  {% if is('person.lucas') %}
   person.lucas
  {% elif is('person.renato') %}
   person.renato
  {% elif is('person.lilian') %}
   person.lilian
  {% else %}
   person.painel
  {% endif %}

a version of the code that worked was this

badge_icon: |-
  {% if is_state('person.lucas','home') %}
   mdi:home
  {% elif is_state('person.renato','home') %}
   mdi:home
  {% elif is_state('person.lilian','home') %}
   mdi:home
  {% else %}
   mdi:home-assistant
  {% endif %}

but what I want to do, I imagine that the panel needs to identify which user is logged in, if it has any code that I can use to pull this information?

the version that works is for another function(badge_icon), for the version i’m currently trying (entity) it doesn’t work for the automation i’m trying

What do you need it for?
The reason for asking is that “Logged in” is only really needed if you want to sent a notification to the person.
If you just want to know who is home, then the person or device_tracker entities is better, since an user being away and connected remotely would still be logged in.

Ahh! you wanted to get the user viewing the lovelace interface and not who were logged in in general. :slight_smile:

It’s not exactly that, I still can’t get it to work

Post your entire YAML code for the card then.
{{ user }} only works in the GUI and not in automations, scripts or the like.

I’ll explain more or less where I want to go

and how do you explain this working? the name on this occasion

Try this card:

type: markdown
content: |-
  {% set username = ('person.'+user).lower() %}
  {{ states(username) }}
  {{ state_attr(username,'friendly_name') }}

this only works for a specific user, my idea is to make a card that corresponds to the person who is logged in on the lovlance screen
making the card dependent on who is viewing it, making it show information about who is currently viewing it

When I view it with one of my users I get the information for that user and when I view it with another user then I get that users information.
Could it be your browser cache? Try to click refresh (or F5) with CTRL or Shift held down.

no the answer remains as

I used chrome’s inspect page to disable the cache, it’s not the cache that’s the problem

What does just {{ user }} output and is there a person entity named that?

I still don’t think you understand what I’m trying to do, I understand that it’s possible to do it this way for an entity,

image

but I don’t want to do it for just one entity, I’m trying to make a card for all entities/person so that the person who is seeing the card 1 will see the name of the person who is seeing it, for example lucas, then the name lucas and his statuses, but if the person you are looking at is renato then renato will appear and his statuses and not lucas do you understand?

So something like this?

type: markdown
content: |-
  {%- set persons = states.person -%}
  <table width=100%><tr><td>Friendly Name</td><td>State</td></tr>
  {%- for single_person in persons %}
    <tr><td>
    {{- single_person.attributes.friendly_name -}}
    </td><td>
    {{- single_person.state -}}
    </td></tr>
  {%- endfor -%}

right with this code you put all the users and status on the screen, but as i said i’m trying to put only, literally just the user who is watching the panel, like this: lucas accessing panel = card: lucas and lucas status and by example lucas’ phone battery, now renato is also accessing it from his phone so the panel shows him like this = card: Renato and renato status and following the previous example renato’s phone battery but it could be other related information to the user who is viewing, but the idea is not to show all users at once, but only the one who is accessing, understand?

But this one will show the values for just the user logged into that view.
If Renato logs in then it will show Renato’s values.
If Lucas logs in then it will show Lucas’ values.

type: markdown
content: |-
  {% set username = ('person.'+user).lower() %}
  {{ states(username) }}
  {{ state_attr(username,'friendly_name') }}

if you can explain to me why this code works in half… ?
I need something that works 100%