- type: custom:mushroom-chips-card
chips:
- type: template
entity: cover.1
icon: |
{% if is_state('cover.1', 'on') %}
mdi:roller-shade-closed
{% else %}
mdi:roller-shade-open
{% endif %}
icon_color: |-
{% if is_state('cover.1', 'on') %}
red
{% else %}
green
{% endif %}
}
entity_id that begins with a number
If your template uses an entity_id
that begins with a number (example: states.device_tracker.2008_gmc
) you must use a bracket syntax to avoid errors caused by rendering the entity_id
improperly. In the example given, the correct syntax for the device tracker would be: states.device_tracker['2008_gmc']
entity: cover.['1']
and {% if is_state('cover.['1']', 'on') %}
this is also not working
Personally, I would change the entity id to avoid this being an issue in future templates, but Mushroom’s built in entity
variable is working for me with number-first object ids, test the following:
type: custom:mushroom-chips-card
chips:
- type: template
entity: cover.1
icon: |-
{{ iif(is_state(entity, 'open'), 'mdi:roller-shade-closed', 'mdi:roller-shade-open') }}
icon_color: |-
{{ iif(is_state(entity, 'open'), 'red', 'green') }}
so I changed the entityname by your advice.
What I have now is, when the state is changing, the icon doesn’t. Has it to be a conditional “type” then ?
lI have it now like this
- type: conditional
conditions:
- entity: cover.group_slaapkamer_raam
state: 'on'
chip:
type: template
icon: mdi:bottom-panel-close-rounded
icon_color: white
alignment: end
card_mod:
style: |
ha-card {
--chip-box-shadow: none;
--chip-background: none;
--chip-spacing: 0;
- type: conditional
conditions:
- entity: cover.group_slaapkamer_raam
state: 'off'
chip:
type: template
icon: mdi:bottom-panel-open-outline-sharp
icon_color: grey
alignment: end
card_mod:
style: |
ha-card {
--chip-box-shadow: none;
--chip-background: none;
--chip-spacing: 0;
but that is not working…
There shouldn’t be a dot.
cover['1']
I don’t really understand why you would want to do it that way, but you have to use the correct configuration format for the cards you want to use… The basic configuration of a Conditional Card is as follows:
type: conditional
conditions: []
card:
type:
You need to have a card
and `type variables…
- type: conditional
conditions:
- entity: cover.group_slaapkamer_raam
state: 'open'
card:
- type: custom:mushroom-chips-card
chips:
- type: template
entity: cover.group_slaapkamer_raam
icon: mdi:bottom-panel-close-rounded
icon_color: white
alignment: end
card_mod:
style: |
ha-card {
--chip-box-shadow: none;
--chip-background: none;
--chip-spacing: 0;
- type: conditional
conditions:
- entity: cover.group_slaapkamer_raam
state: 'closed'
card:
- type: custom:mushroom-chips-card
chips:
- type: template
entity: cover.group_slaapkamer_raam
icon: mdi:bottom-panel-open-outline-sharp
icon_color: grey
alignment: end
card_mod:
style: |
ha-card {
--chip-box-shadow: none;
--chip-background: none;
--chip-spacing: 0;