- type: custom:mushroom-template-card
primary: AC
secondary: >-
{% set ac_on = expand(states.group.ac) | selectattr( 'state', 'eq','on') |
list | count %} {% if ac_on > 1 %}
{{ ac_on }} On
{% elif ac_on == 1 %}
{{ ac_on }} On
{% else %} {% endif %}
layout: vertical
icon_color: '{{ ''blue'' if is_state(entity, ''on'') else ''disabled'' }} '
entity: group.ac
tap_action:
action: more-info
hold_action:
action: toggle
icon: mdi:snowflake
card_mod:
style:
mushroom-shape-icon$: |
ha-icon {
{{ '--icon-animation: rotation 1s linear infinite;' if is_state(config.entity, 'on') }}
}
The animation not working, any idea?
One of the biggest âquality-of-lifeâ improvements (in my view) to the Mushroom cards would be for only the icon portion of a card to toggle the entity, rather than the whole card being one giant active button.
Quite often Iâve inadvertently grazed over part of a card only to toggle a light/fan/switch etc. unexpectedly. This also happens when trying to go back to the previous screen using the âswipe from edgeâ feature on Android. (Obviously these issues are touchscreen-specific).
Thereâs already an open issue for this: [Feature]: limit tap target area to the button ¡ Issue #446 ¡ piitaya/lovelace-mushroom ¡ GitHub
However it hasnât been progressed in months so not sure how likely it is to be officially implemented.
SoâŚis there anyway some of these cardmod tricks could be used to achieve this? Ideally Iâd love for just the icon to toggle the underlying entity, and clicking anywhere else on the card would bring up the more-info dialog (or something else).
I think the is_state(config.entity, 'on')
should be just is_state(entity, 'on')
Still no animationâŚ
Donât you need to declare the entity before referencing it ? Try moving entity: group.ac
above the icon_color line
- type: custom:mushroom-template-card
primary: AC
secondary: >-
{% set ac_on = expand(states.group.ac) | selectattr( 'state', 'eq','on') |
list | count %} {% if ac_on > 1 %}
{{ ac_on }} On
{% elif ac_on == 1 %}
{{ ac_on }} On
{% else %} {% endif %}
layout: vertical
entity: group.ac
icon_color: '{{ ''blue'' if is_state(entity, ''on'') else ''disabled'' }} '
tap_action:
action: more-info
hold_action:
action: toggle
icon: mdi:snowflake
card_mod:
style:
mushroom-shape-icon$: |
ha-icon {
{{ '--icon-animation: rotation 1s linear infinite;' if is_state(entity, 'on') }}
}
not working
Is âonâ definitely the right status for this entity i.e. an AC unit.
Should it be something else, like ârunningâ or âheatingâ or âcoolingâ etcâŚ?
EDIT: actually, do you not need to also define the @keyframes for the rotation animation? I donât see it in your code snippet.
its a group of input_boolean
That would be my next check too. Just found this in my code :
entity: sensor.hot_tub_heater_action
fill_container: false
icon: '{{ ''mdi:radiator'' if is_state(entity, ''Heater On'') else ''null'' }}'
icon_color: '{{ ''red'' if is_state(entity, ''Heater On'') else ''null'' }}'
Or maybe use the âspinâ animation since itâs builtin and doesnât need you specify the @keyframes. This is the very first example from @rhysb animations list:
type: custom:mushroom-template-card
primary: Spin
icon: mdi:fan
icon_color: teal
card_mod:
style:
mushroom-shape-icon$: |
ha-icon {
--icon-animation: spin 1s linear infinite;
}
let me tell you, Iâm looking for this for a long time and I bet that somebody has a solution
In Mushroom Light Card, the Icon is automatically picking up the light/RGB etc color
how can I get the information/state of the EXACT color and include it as color in Mushroom Chip ?
use case:
I have a LED strip badge (crossed out when off)
What I would like to achieve is to have the badge color matching to the LED strip color
anybody :)?
I have no issue with the animation when no on\off condition set.
also the icon color change depanding state works.
Yeah so I think itâs not working cos the necessary @keyframes section is missing. You can either add it, or try to use the âspinâ animation instead (which doesnât require the @keyframes).
This works for me:
type: custom:mushroom-template-card
primary: AC
secondary: >-
{% set ac_on = expand(states.group.ac) | selectattr( 'state',
'eq','on') | list | count %} {% if ac_on > 1 %} {{ ac_on }} On {% elif ac_on
== 1 %} {{ ac_on }} On {% else %} {% endif %}
layout: vertical
entity: group.ac
icon_color: '{{ ''blue'' if is_state(entity, ''on'') else ''disabled'' }} '
tap_action:
action: more-info
hold_action:
action: toggle
icon: mdi:snowflake
card_mod:
style:
mushroom-shape-icon$: |
ha-icon {
{{ '--icon-animation: spin 1s linear infinite;' if is_state(config.entity, 'on') }}
}
Is this the sort of thing you want?
type: custom:mushroom-template-card
primary: Lounge
icon: mdi:sofa
icon_color: '{{ ''amber'' if is_state(entity, ''on'') }}'
entity: light.lounge_light
badge_icon: >-
{{ 'mdi:led-strip-variant' if is_state('light.lounge_cabinet_light', 'on')
else 'mdi:led-strip-variant-off' }}
card_mod:
style: |
mushroom-badge-icon {
{% set r = state_attr('light.lounge_cabinet_light', 'rgb_color')[0] %}
{% set g = state_attr('light.lounge_cabinet_light', 'rgb_color')[1] %}
{% set b = state_attr('light.lounge_cabinet_light', 'rgb_color')[2] %}
{% if is_state('light.lounge_cabinet_light', 'on') %}
--main-color: rgb({{r}}, {{g}}, {{b}});
{% endif %}
}
Use is_state(entity, 'on')
within the template card and is_state(config.entity, 'on')
within the card_mod
of the card.
seriously, you are my hero from now, so many things already done with your examples
now⌠I know it might be too much
can I somehow add Brightness level as well ?
Thank you for your share.
Any advice/help on how to make PNGs to animated icons (Similar to Battery) for water and diesel?
Yes, like this:
type: custom:mushroom-template-card
primary: Lounge
icon: mdi:sofa
icon_color: '{{ ''amber'' if is_state(entity, ''on'') }}'
entity: light.lounge_light
badge_icon: >-
{{ 'mdi:led-strip-variant' if is_state('light.lounge_cabinet_light', 'on')
else 'mdi:led-strip-variant-off' }}
card_mod:
style: |
mushroom-badge-icon {
{% set r = state_attr('light.lounge_cabinet_light', 'rgb_color')[0] %}
{% set g = state_attr('light.lounge_cabinet_light', 'rgb_color')[1] %}
{% set b = state_attr('light.lounge_cabinet_light', 'rgb_color')[2] %}
{% if is_state('light.lounge_cabinet_light', 'on') %}
{% set bri = state_attr('light.lounge_cabinet_light', 'brightness') / 255 %}
--main-color: rgba({{r}}, {{g}}, {{b}}, {{bri}});
{% endif %}
}