Set current Dashboard user to input_select.helper

Hey,

I have a challenge.

I want to register when someone took out, or took in the Garbage Bin. Therefor I want the person in question to click on this button below.

As you see, that invokes a trigger call-action, that selects an option in the helper input_select.gft_bak_buiten_gezet, either Martin, Fleur or Steijn.

I know that I have to give the option as data, but it is now hardcoded.

I thought that {{user}} might do the trick but it doesn’t.

Can anyone help me out, or has a clue how to achieve this?

type: custom:button-card
entity: sensor.circulus_pmd
name: Plastic
show_state: true
color: orange
styles:
  card:
    - height: 120px
    - padding-bottom: 10%
  state:
    - padding-top: 2%
    - font-size: 14px
  icon:
    - width: 50%
state:
  - value: Vandaag
    color: white
    styles:
      card:
        - background-color: orange
      state:
        - color: black
      name:
        - color: black
        - font-weight: 800
  - value: Morgen
    color: white
    styles:
      card:
        - background-color: orange
      state:
        - color: black
      name:
        - color: black
        - font-weight: 800
      icon:
        - animation: blink 5s ease infinite
tap_action:
  action: call-service
  service: input_select.select_option
  target:
    entity_id: input_select.gft_bak_buiten_gezet
  data:
    option: Fleur
double_tap_action:
  action: navigate
  navigation_path: /dashboard-voorbeeld/circulus

this should

i’m not sure about how to grab that in lovelace. but it’s available in a trigger. so if you have your card trigger an automation, that automation event can get the current user with this:

 {{ states.person|selectattr("attributes.user_id", "==", trigger.to_state.context.user_id)|map(attribute="attributes.friendly_name")|first }}

and then you can pass it into your select.

1 Like

Thanks!

I need some more help with this. I don’t have a clue how to apply this. Can you help me out a bit more?

let me know if this help:

alias: test ui script
sequence:
  - variables:
      user_name: >
        {{ states.person | selectattr("attributes.user_id", "==",
        context.user_id) | map(attribute="attributes.friendly_name") | first
        }}      
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ user_name == 'your_name' }}"
        sequence:
          - service: input_select.select_option
            entity_id: input_select.gft_bak_buiten_gezet
            data:
              option: Fleur
  - {}
mode: single

that goes in a script.

then this goes in our dashboard:

show_name: true
show_icon: true
type: button
tap_action:
  action: toggle
entity: script.test_ui_script