Dynamically define lovelace card entity based on current user

Ok, I am hesitant if this is even possible but I am hoping someone has a good solution here.

I am using conditional cards to minimize entities when not needed in lovelace. I have it set up so that you can press a header and it will minimize/hide the entities within that conditional card. It works really nice but the only downside is that separate users can minimize or maximize these headers at the same time which means that your UI could be minimized by the other person when you still want it there. I am using input_booleans for this. A press of the header sets the input boolean state and the conditional card listens to that state.

This is an example of such a lovelace config together with the custom button card:

            - type: "custom:button-card"
              name: "Temperatur"
              template: header_expand
              entity: input_boolean.temperatur

            - type: conditional
              conditions:
                - entity: input_boolean.temperatur
                  state: "on"
              card:
                type: horizontal-stack
                cards: 

I would like to be able to use templating or something else to dynamically set the entity_id in the two above cards to two separate input_booleans that are unique to each user. So instead of “entity: input_boolean.temperatur” I would like it to show “entity: input_boolean.temperatur_filip” when I am using the view and to “entity: input_boolean.temperatur_emma” when my wife is.

Is this even possible? The card docs says that the “entity” option needs to be a string. But could this somehow be overcome by using a template or variable there instead?

I could create separate views for me and my wife with different hard coded entity options but that would make me have a double of the lovelace code and be much more difficult to maintain.

Thanks for reading!

1 Like