How does the {{ user }} tag work?

Currently there is only me in the house which is great for automations, etc.
However shortly there will be another person living here.

Trying to figure out if the {{ user }} is inherit in HA or do I have configure my system to use so it picks up on the correct user.

Thank you!

It outputs the name of the person currently logged in to the device you are currently using.

1 Like

So basically you can use {{ user }} in place of a name like John or Elizabeth… whoever comes through the door and triggers an automation using a name it’ll replace it with whoever the person is?

Not exactly. It’s more something you would use as a greeting on a dashboard. It displays who is logged in on that particular device. So it could be used in a template card as a greeting on your dashboard.

For example, see:

1 Like

Thank you so much!!!

hello

 - type: custom:stack-in-card
        cards:
          - type: custom:mushroom-template-card
            primary: Hello, {{user}}
            secondary: How are you?
            icon: mdi:home
          - type: custom:mushroom-chips-card
            chips:
              - type: light
                entity: switch.counter_lights
                content_info: none
                use_light_color: true
              - type: template
                content: >-
                  {{ state_attr('climate.john_s_device',
                  'temperature')|float}}°F
                tap_action:
                  action: none
              - type: entity
                entity: binary_sensor.sink_kitchen_window_contact
                content_info: none
              - type: template
                content: >-
                  {{ state_attr('sensor.john',
                  'devicetracker_zone')}}
                tap_action:
                  action: none
1 Like

Hello,
So how to use this {{user}} in javascript templates in custom:button-card? I would like to tweak a little bit styling or maybe even add {{user}} name on the button content.

Just so you know I’m not ignoring you… I honestly do not have an answer for that one :slight_smile:

Custom Button card supports javascript only, not jinja2. In addition, you can’t template the user from my understanding so there are limited options if you want to use the Button Card

The custom_fields: in the Button card will accept other card types that will allow the use of {{user}}.

type: custom:button-card
custom_fields:
  user:
    card:
      type: custom:mushroom-template-card
      primary: Hello, {{user}}
      secondary: How are you?
      icon: mdi:account
      card_mod:
        style: |
          ha-card {
            border: none;
              }
  test:
    card:                    
      type: custom:button-card
      entity: light.couch
      name: TEST
      tap_action: none
      show_state: false
      styles:
        card:
          - font-size: 15px
          - background: transparent
          - border: none
          - left: -300px