This should work
type: custom:button-card
entity: input_boolean.kiosk_1080
name: AUTO on/off
tap_action:
action: call-service
service: input_boolean.toggle
service_data:
entity_id: input_boolean.kiosk_1080
This should work
type: custom:button-card
entity: input_boolean.kiosk_1080
name: AUTO on/off
tap_action:
action: call-service
service: input_boolean.toggle
service_data:
entity_id: input_boolean.kiosk_1080
Apologies for being new to this. I’ve spent a couple of hours reading through the first 2 years of responses in this thread but couldn’t find an answer. I don’t think I can read another 2 years at this point and hopefully I can just ask what might be obvious.
Almost every response in here has to do with defined entities - ‘sensor.this.that’. I am hoping to use a small bit of the original poster’s template on an unknown amount of sensors. There are up to ~100 different ones. I only want to display a sensor if it’s got a “off” state. My code for just one sensor is this:
type: custom:button-card
entity: sensor.docker_checkrr_state
template: alerter-dual
name: Checkrr
variables:
color_seconds: 5
I could repeat this for each sensor but that would be silly. I’d essentially like to do this:
type: custom:button-card
entity: sensor.docker_*_state
template: alerter-dual
name: Checkrr
variables:
color_seconds: 5
(note the asterisk). I would place this in a conditional card so that it’s only displayed if the entity value is ‘off’.
I’ve tried using auto-entities, but this doesn’t work with templates. What happens is that it sends all 100 entity names to the template, which of course doesn’t expect more than one. The thread discussing auto-entities recommends using the lovelace-layout-card, making note of the section titled ‘Use with entity filters’ in the readme. However, this doesn’t work either - there’s no way to tell lovelace-layout-card to use this custom:button-card. Or perhaps there is and I’m getting it wrong. I’ve tried for several hours but just get messed up.
I’ve read a bit on the ‘decluttering-card’ but I don’t think that’s what I want to do either.
At this point I think I’ve gone WAAAAY too far down the rabbit hole for what I want to do, which is a really simple thing:
There could be any number of these sensors and they’ll change over time, so I don’t want to hard code in the sensor names.
Is there a simple way to do this that doesn’t require several more hours of learning?
Hello,
I can change the buttons in the Mushroom Alarm Panel, but not the color of the icons. What am I doing wrong - type: custom:mushroom-alarm-control-panel-card
entity: alarm_control_panel.lupusec_alarm
states:
- armed_home
- armed_away
card_mod:
style:
mushroom-button:nth-child(1):
$: |
.button {
–bg-color: orange;
}
ha-icon {
–card-mod-icon-color: black;
}
mushroom-button:nth-child(2):
$: |
.button {
–bg-color: green;
}
Hi! That’s awesome! Any chance to have some ideas for code?
https://community.home-assistant.io/t/mushroom-cards-card-mod-styling-config-guide/600472
Examples from here. But the example above doesn’t work for me as described
Not the right thread for Mushroom questions, but this is the code you’ll need
type: custom:mushroom-alarm-control-panel-card
entity: alarm_control_panel.ha_alarm
states:
- armed_home
- armed_away
- armed_night
card_mod:
style:
mushroom-button:nth-child(1):
$: |
.button {
--bg-color: orange !important;
--icon-color: blue !important;
}
mushroom-button:nth-child(2):
$: |
.button {
--bg-color: red !important;
--icon-color: white !important;
}
mushroom-button:nth-child(3):
$: |
.button {
--bg-color: grey !important;
--icon-color: yellow !important;
}
Use this thread going forward…
Hi All,
I’m looking for ideas/ways to improve my custom card for my bin collections. I want to improve how it works and how it looks on both desktop and mobile.
Below is my code;
type: custom:button-card
label: Black Bin <br> will be collected on
entity: sensor.black_bin_collection
show_name: false
show_icon: false
show_label: true
show_state: false
tap_action: none
styles:
grid:
- grid-template-areas: '"l item1" "l blank"'
- grid-template-columns: 50% 40%
- column-gap: 0%
- row-gap: 3px
card:
- height: 100%
- border-radius: var(--border-radius)
- overflow: visible
- box-shadow: 0px 0px 10px -9px black
- border-radius: 25px
- background-color: grey
- justify-items: center
- justify-content: center
label:
- text-align: left
- font-size: 15px
- font-family: Montserrat
- font-weight: 800
- align-self: end
- color: var(--contrast-100)
custom_fields:
item1:
card:
type: custom:button-card
tap_action:
action: none
label: |
[[[
var state = states['sensor.black_bin_collection'].state;
if (state === 'unknown') {
return 'Coming Soon';
} else {
return state;
}
]]]
show_label: true
styles:
grid:
- grid-template-areas: '"state"'
- grid-template-columns: min-content
- grid-template-rows: min-content
label:
- margin-top: 1px
- justify-items: center
- justify-content: center
- font-size: 15px
- font-family: Montserrat
- font-weight: 500
card:
- background-color: grey
This is how it looks.
Desktop:
Mobile:
I’m looking for ideas for improvement and how to design this better Thanks
i trying to change the color of an svg file when the color of the rgb light is changing, but its not working, i can change the color to static color
type: custom:button-card
entity: light.yeelight_color_0x37073da
entity_picture: /local/ic/custom_icons/bulb.svg
show_state: false
show_icon: false
show_entity_picture: true
styles:
entity_picture:
- filter: |
[[[
if (entity.state === 'on') {
return 'invert(27%) sepia(99%) saturate(7489%) hue-rotate(356deg) brightness(101%) contrast(104%)';
} else {
return 'brightness(100%)';
}
]]]
but when i try something like this its not working ( i tried few diffrent ways)
type: custom:button-card
entity: light.yeelight_color_0x37073da
entity_picture: /local/ic/custom_icons/masterbedroomnopepole.svg
show_state: false
show_icon: false
show_entity_picture: true
styles:
entity_picture:
- filter: "[[[ return `hue-rotate(${states['light.yeelight_color_0x37073da'].attributes.hs_color[0]}deg) saturate(${states['light.yeelight_color_0x37073da'].attributes.hs_color[1]}%)`; ]]]"
any help how can i do it ?
Can someone help me make a templates for this?
Thank you.
- type: custom:layout-card
layout_type: custom:grid-layout
layout:
grid-template-columns: max-content 1fr max-content
grid-template-rows: min-content
grid-template-areas: '"one . two three"'
cards:
- view_layout:
grid-area: one
type: custom:button-card
name: לפי שעה
show_state: true
show_name: false
icon: hue:plug-eu-group
entity: sensor.energy_total_next_bill_cost
tap_action:
action: more-info
styles:
grid:
- grid-template-areas: '"i s n"'
card:
- padding: 4px
- background-color: var(--card_background_color)
- box-shadow: var(--rounded-box-shadow)
- border-radius: var(--rounded-border-raduis)
# img_cell:
# - width: 40px
# - height: 40px
# - background: white
# - border-radius: 100%
icon:
- width: 20px
- height: 20px
- color: var(--card_icon_color)
- margin-top: -3px
# name:
# - color: white
# - font-size: 14px
# - padding: 0 10px
state:
- color: var(--card_state_color)
- font-size: 16px
- font-weight: 400
- padding: 0 10px
- view_layout:
grid-area: two
type: custom:button-card
show_state: true
show_name: false
show_icon: true
name: Next Bill
icon: mdi:power-plug-outline
entity: sensor.power_cost_per_hour
tap_action:
action: more-info
styles:
grid:
- grid-template-areas: '"i s n"'
card:
- padding: 4px
- background-color: var(--card_background_color)
- box-shadow: var(--rounded-box-shadow)
- border-radius: var(--rounded-border-raduis)
# img_cell:
# - width: 40px
# - height: 40px
# - background: white
# - border-radius: 100%
icon:
- width: 20px
- height: 20px
- color: var(--card_icon_color)
- margin-top: -3px
# name:
# - color: white
# - font-size: 14px
# - padding: 0 10px
state:
- color: var(--card_state_color)
- font-size: 16px
- font-weight: 400
- padding: 0 10px
- view_layout:
grid-area: three
type: custom:button-card
name: לפי שעה
show_state: true
show_name: false
icon: hue:socket-eu
entity: sensor.total_power
tap_action:
action: more-info
styles:
grid:
- grid-template-areas: '"i s n"'
card:
- padding: 4px
- background-color: var(--card_background_color)
- box-shadow: var(--rounded-box-shadow)
- border-radius: var(--rounded-border-raduis)
# img_cell:
# - width: 40px
# - height: 40px
# - background: white
# - border-radius: 100%
icon:
- width: 20px
- height: 20px
- color: var(--card_icon_color)
- margin-top: -3px
# name:
# - color: white
# - font-size: 14px
# - padding: 0 10px
state:
- color: var(--card_state_color)
- font-size: 16px
- font-weight: 400
- padding: 0 10px
mine looks like this, not my own code but modified to how I wanted it.
I use mushroom for everything.
Hi Simon, would you mind sharing the code?
sure. uses mushroom, card_mod, stack-in-card and Google material icons.
- type: custom:stack-in-card
mode: vertical
cards:
- type: horizontal-stack
card_mod:
style: |
ha-card {
box-shadow: none;
border: none;
ha-card-border-width: 0px;
}
cards:
- type: custom:mushroom-template-card
card_mod:
style: |
ha-card {
border: none;
box-shadow: none;
ha-card-border-width: 0px;
}
primary: Bin Collection
secondary: ' {{ states(''sensor.all_waste_types'') }}'
icon: mdi:sack
icon_color: >-
{{ 'blue' if '0 days' in states('sensor.all_waste_types') else
'blue' }}
multiline_secondary: true
tap_action:
action: none
hold_action:
action: none
double_tap_action:
action: none
- type: custom:mushroom-chips-card
chips:
- type: template
content: ''
icon: mdi:trash-can
icon_color: >-
{{ 'green ' if 'Rubbish' in states('sensor.all_waste_types')
else 'grey' }}
card_mod:
style: |
ha-card {
background: rgba(var(--rgb-{{ 'green' if 'Rubbish' in states('sensor.all_waste_types') else 'grey' }}), 0.2) !important;
border: none;
box-shadow: none;
ha-card-border-width: 0px;
}
ha-card:after {
content: "{{ 'done' if 'Rubbish' in states('sensor.all_waste_types') else 'close' }}";
position: absolute;
display: flex;
justify-content: center;
align-items: center;
background: rgb(var(--rgb-{{ 'green' if 'Rubbish' in states('sensor.all_waste_types') else 'grey' }}));
color: var(--card-background-color);
font-weight: bolder;
border-radius: 50%;
top: -5px;
right: -5px;
width: 16px;
height: 16px;
font-size: 11px;
font-family: 'Material Icons';
}
- type: template
content: ''
icon: mdi:recycle
icon_color: >-
{{ 'indigo' if 'Recycling' in states('sensor.all_waste_types')
else 'grey' }}
card_mod:
style: |
ha-card {
background: rgba(var(--rgb-{{ 'indigo' if 'Recycling' in states('sensor.all_waste_types') else 'grey' }}), 0.2) !important;
border: none;
box-shadow: none;
}
ha-card:after {
content: "{{ 'done' if 'Recycling' in states('sensor.all_waste_types') else 'close' }}";
position: absolute;
display: flex;
justify-content: center;
align-items: center;
background: rgb(var(--rgb-{{ 'indigo' if 'Recycling' in states('sensor.all_waste_types') else 'grey' }}));
color: var(--card-background-color);
font-weight: bolder;
border-radius: 50%;
top: -5px;
right: -5px;
width: 16px;
height: 16px;
font-size: 11px;
font-family: 'Material Icons';
}
- type: template
content: ''
icon: mdi:leaf
icon_color: >-
{{ 'brown' if 'Garden' in states('sensor.all_waste_types')
else 'grey' }}
card_mod:
style: |
ha-card {
background: rgba(var(--rgb-{{ 'brown' if 'Garden' in states('sensor.all_waste_types') else 'grey' }}), 0.2) !important;
border: none;
box-shadow: none;
}
ha-card:after {
content: "{{ 'done' if 'Garden' in states('sensor.all_waste_types') else 'close' }}";
position: absolute;
display: flex;
justify-content: center;
align-items: center;
background: rgb(var(--rgb-{{ 'brown' if 'Garden' in states('sensor.all_waste_types') else 'grey' }}));
color: var(--card-background-color);
font-weight: bolder;
border-radius: 50%;
top: -5px;
right: -5px;
width: 16px;
height: 16px;
font-size: 11px;
font-family: 'Material Icons';
}
alignment: end
card_mod:
style: |
ha-card {
top: 10px;
right: 17px;
}
card_mod:
style: |
ha-card {
--ha-card-box-shadow: 0px;
}
You have learned a lot Frosty!!!
Thank you! I can’t take credit for the code. but understanding what your copy, pasting and modifying is important.
3 months ago I knew nothing, I’ve read through every post on mushroom especially the ones from your self helping other people. silently in the background understanding and reading the examples you so kindly provided lol.
my dashboard looks so different now as to when I started.
The Google material icons is that a HACS integration? And is it perhaps this one?
it was along time ago. I think this is the method I used
https://community.home-assistant.io/t/mushroom-cards-build-a-beautiful-dashboard-easily-part-1/388590/3050?u=frosty
I’ll look into this! Thanks!
Hi all, I wondered if I could get some help please.
I’ve recently implemented custom:button-card into a could of my dashboard elements and so far this post along with a few other resources has given me everything I need.
I’m trying to add some logic into a template so that the notification element in custom_fields is only displayed when a variable matches some specific values. I’ve tested the logic and that’s all working but I’m not even sure if it’s possible to do what I want. Here is an example which hopefully shows what I’m getting at.
button_card_templates:
lightandoccupancy:
icon: mdi:lightbulb
aspect_ratio: 1/1
name: |
[[[ return [variables.cardname] ]]]
styles:
name:
- font-size: 15px
- padding: 7%
icon:
- margin-top: 18%
- scale: 95%
card:
- scale: 80%
grid:
- position: relative
custom_fields: |
[[[
if (states[variables.occupancyentity].state in ['on', 'off'])
return
notification:;
- background-color: |
[[[
if (states[variables.occupancyentity].state == 'on')
return "#ffc107";
return "#44739e";
]]]
- border-radius: 50%;
- position: absolute;
- left: 70%;
- top: 5%;
- height: 15px;
- width: 15px;
- font-size: 0px;
- line-height: 20px;
- icon: mdi:lightbulb;
]]]
custom_fields:
notification: |
[[[ return (states[variables.lightentity].state) ]]]
Hi, the if else should be like this
- background: |
[[[
if (states['yourentity'].state == 'off')
return '#FF204E';
else
return '#8DECB4';
]]]
You need the ‘ ‘ in the last code too
Thanks for the tips