Dear all,
I am trying to beautify my presence display/card. But I am failing to show the right icons/color based on the state.
This is the “old view” and representing the right states
This is the “new view” with right states but wrong icons/colors.
The code I am using is as follows:
square: true
type: grid
cards:
- type: vertical-stack
cards:
- type: custom:button-card
entity: device_tracker.bernd_s20
name: Bernd
show_name: true
show_icon: true
show_state: true
icon: |
[[[
if (entity.state === 'Zu Hause') return 'mdi:home-account';
if (entity.state === 'Abwesend') return 'mdi:home-export-outline';
else return 'mdi:flash';
]]]
styles:
grid:
- grid-template-areas: '"n i" "s i" "l i"'
- grid-template-columns: 1fr 40%
icon:
- color: |
[[[
if (entity.state === 'Zu Hause') return 'green';
if (entity.state === 'Abwesend') return 'orange';
else return 'red';
]]]
- type: custom:button-card
entity: device_tracker.ute_p20_2
name: Ute
show_name: true
show_icon: true
show_state: true
icon: |
[[[
if (entity.state == 'Zu Hause') return 'mdi:home-account';
if (entity.state == 'Abwesend') return 'mdi:home-export-outline';
else return 'mdi:flash';
]]]
styles:
grid:
- grid-template-areas: '"n i" "s i" "l i"'
- grid-template-columns: 1fr 40%
icon:
- color: |
[[[
if (entity.state == 'Zu Hause') return 'green';
if (entity.state == 'Abwesend') return 'orange';
else return 'red';
]]]
- type: custom:button-card
entity: device_tracker.tim_a53_7
name: Tim
show_name: true
show_icon: true
show_state: true
icon: |
[[[
if (entity.state == 'Zu Hause') return 'mdi:home-account';
if (entity.state == 'Abwesend') return 'mdi:home-export-outline';
else return 'mdi:flash';
]]]
styles:
grid:
- grid-template-areas: '"n i" "s i" "l i"'
- grid-template-columns: 1fr 40%
icon:
- color: |
[[[
if (entity.state == 'Zu Hause') return 'green';
if (entity.state == 'Abwesend') return 'orange';
else return 'red';
]]]
- type: custom:button-card
entity: device_tracker.felix_huawei
name: Felix
show_name: true
show_icon: true
show_state: true
icon: |
[[[
if (entity.state == 'Zu Hause') return 'mdi:home-account';
if (entity.state == 'Abwesend') return 'mdi:home-export-outline';
else return 'mdi:flash';
]]]
styles:
grid:
- grid-template-areas: '"n i" "s i" "l i"'
- grid-template-columns: 1fr 40%
icon:
- color: |
[[[
if (entity.state == 'Zu Hause') return 'green';
if (entity.state == 'Abwesend') return 'orange';
else return 'red';
]]]
columns: 2
tried it with “==” and “===” - not working either…
Also tried
[[[
if (entity.state == 'Zu Hause') return 'mdi:home-account';
else if (entity.state == 'Abwesend') return 'mdi:home-export-outline';
else return 'mdi:flash';
]]]