New User system, use username for conditions

Now that the user system is up and running, how do I write a condition based on the user that logged in ?

I don’t think that’s possible. What do you have in mind?

You can use auth/current_user websocket command to get current login user.

Or $('home-assistant').hass.user if you are in the front end

A condition, where do you want a condition?

Automations (the most relevant place for conditions I can think of) do not run in the frontend, so there is no notion of logged in user. There is only one HA instance running, but possibly zero, one, or even more users that are logged in in the frontend at the same time.

Or are you trying to change something in the frontend based on the logged-in user? Not sure that is possible right now, probably in future releases.

I think lox wants to display cards or even views, depending on the logged in user.

I want to do this, too.

4 Likes

That is what I want to do

You guys ever figure this out? Trying to do same, conditional cards for specific users.
Trying to hide the good stuff from my wife! :stuck_out_tongue_winking_eye:

Just an FYI - I think I’ve found two different ways to currently show user based cards.

1 Like

CCH is what you want.

1 Like

Does state switch user works for you?

Yes, it works as advertised. I use it along with the custom header integration to display all the stuff my wife wouldn’t or shouldn’t play with when she’s logged in. Didn’t end up really needing it though I don’t think she’s ever bothered using the UI except maybe to turn the alarm off. Most of our stuff is pretty automated or voice controlled now.

In which context can I use this? Tried straight in the .yaml but didn’t expect to be that easy… Should I put it in a template?

I want to use this to enable cards/tabs only if the logged user is at home.

Any idea how this can be achieved? Thanks

1 Like