#Dynamic tile card options
1 messages ยท Page 1 of 1 (latest)
The Mushroom Tile card (IIRC) does not accept templates. If it did, it would makes things easier. Here's some options for you to consider. - TWO conditional cards, one for locked state and one for unlocked.
- Use a custom:state-switch card (which is basically a
conditional card on steroids)
type: custom:state-switch
entity: template
template: "{% if is_state('input_boolean.tester', 'on') %} unlocked {% else %} locked {% endif %}"
states:
unlocked:
type: custom:mushroom-title-card
title: Rooms ๐
title_tap_action:
action: call-service
service: script.lock_main_door
target: {}
locked:
type: custom:mushroom-title-card
title: Rooms ๐
title_tap_action:
action: call-service
service: script.unlock_main_door
target: {}```EDIT: Corrected script names.
- Use the Mushroom Template Card instead but style it to look like the Title Card. This will probably require card_mod to do.
- In an unorthodox approach, you could use the [custom:button-card](<https://github.com/custom-cards/button-card>) and style it to look like the Mushroom Title Card. The styling approach could be a bit easier than using card_mod for the Template Card because custom:button-card has its own styling capabilities. This card also has better layout capabilities so you could define an actual icon region and not have to rely on 30 spaces to get the icon aligned where you want it.
This is the state-switch example:
Here's an example of styling the custom:button-card to look like a Mushroom Light Card. It's not 100% but pretty close. Top is Mushroom, bottom is custom:button-card.
Thanks! I liked this option. however Is there a way for only make the unlock emoji clickable? anod not the whole line of the 'Rooms'? I don't want people to click by mistake on that line and it will unlock the door when you had no intention to do that.
In it's current form, I'm going to say no because technically the lock isn't an icon; it's just part of the title's text. Using the custom:stack-in-card might do what you want. It will basically take two cards and make them look like one. Here, I've used a Mushroom Title card (acting strictly as the title) and then a custom:button-card that presents the icon and supports the appropriate action. ```yaml
type: custom:stack-in-card
mode: horizontal
card_mod:
style: |
ha-card {
--ha-card-background: none;
border: none
}
cards:
- type: custom:mushroom-title-card
title: Rooms - type: custom:button-card
entity: input_boolean.tester
show_icon: false
name: |
[[[ if (entity.state == 'on') return '๐'; else return '๐' ]]]
styles:
card:
- height: 50px
- margin: 10px
name:
- font-size: 25px
tap_action:
action: call-service
service: |
[[[ if (entity.state == 'on') return 'script.lock_main_door'; else return 'script.unlock_main_door' ]]]
target: {}```In the screenshot, the top is the card from earlier; the bottom is the newest version.
You could also do the same thing with just a custom:button-card by adding custom_field for the lock icon. Setting the "Title" card to no actions would prevent it from being clickable. It would be another button kind of like the code above and the title will be its own card. It would be a little bit more involved to set up but could give added "options/features".
The custom:button-card also has a lock option that requires the button to be held for a couple of seconds before it can be clicked. That could add an extra layer of protection from accidentally unlocking the door.
Interesting, I will dig into that, thanks man!
some weird thing in my HA, For some reason I cannot see the new card type (stack-in-card)
http://pastie.org/p/0Cw7rgSTKpqxSh1u0q8CQJ
and that's from my configuration.yaml file ^ (line 9)
You know what's the solution to my problem? I can't figure this out...
I've never noticed it before but it does not show up in the UI. Select Manual and just type it in.
type: custom:stack-in-card
mode: horizontal
cards:
- type: button
entity: light.living_room_lights
- type: button
entity: light.living_room_lights```
Sorry for the late response, I wasn't home for a while..
I get this error when I try to paste the code lines into the Manual option via UI.
EDIT:
Nevermind, It was the boolean.tester, I changed it to the script.unlock_main_door