Trying to find a way to hide/show entities within a card based on the state of another entity.
Reading lovelace docs, I found entity-filter, a type of card. This card supports filtering of entities but it seems to only support filtering entities based on each entity’s own state, not on the state of other entities.
My use case is simple: I have a template switch that runs that enables one-off action and has a timer (input_datettime) that sets the time for the action to start. I want to hide the input_datettime if the template switch is off.
On the legacy UI, CustomUI supports templating the ‘hidden’ attribute of any entity. I was wondering whether to invest time/effort learning and deploying CustomUI or wait for the next-gen UI, hoping it bring the flexibility that the legacy UI was didn’t have.
If the feature does not exist in lovelace I can submit a feature request - thought I would ask the experts first
I’ve implemented a “conditional entity” using a Conditional Card plus Custom:vertical-stack-in-card. This can hide or show an entity based on the state of a switch in the same “Card”.
It doesn’t look great - due to ‘vertical-stack-in-card’ adding quite a bit of deadspace, but at least it does the job.
You should handle this differently. Make 2 cards, one without the overide time and one with. Make 2 condtional cards for each of them and you wont have whitespace.
Very smart!
Thanks for the feedback. That will do the job better, will do the change.
Still hoping that in the future we will get support for conditional visibility of entities and cards so we can simplify configuration for this type of use cases.
Then that conditional visibility of cards/entities could also support ‘current_user’ / ‘current_user_not’ / ‘user_group’… but I digress
Just to report the result: the idea worked very well, but I had to enclose both “on” and “off” conditional cards within a vertical-stack, otherwise turning on the switch would work but the updated card showed up in a different column of the dashboard for some reason.
Enclosing in a vertical stack gave the exact behavior I wanted.
Thanks @petro
I have a similar situation, but want to be able independently hide two entities based on states of another two (two input_number and input_boolean respectively).
My understanding is that’s almost impossible with the approach proposed by @petro as I’ll need not two but 6 cards and I’m not quite sure how to juggle them.
Is there any other way to achieve the result?
what a monster… 8()
I’ll give it a try, but it’s a very peculiar way of UI design with Lovelace… oh well
Update: in my case I have one permanent entity and it resulted in 4 conditional cards from off/off to on/on. And in all of them I had to disable heading toggle and define the very same title.
It works, but what an overhead… I wish it could be easier and more elegant…
And I doubt it is easy to hide an input_number in ONE of those conditional cards if its value is 0 (tried and failed, but I’m just learning)
On the other hand, I’m glad it works, let’s hope it will evolve further in the right direction.