Skip to content

Commit bd557a5

Browse files
author
Andrew Blackburn
committed
add Status Icon Only Card v1.1
1 parent 8a65987 commit bd557a5

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
---
2+
custom_card_andyblac_status_icon_only:
3+
# v1.1
4+
template:
5+
- "ulm_translation_engine"
6+
variables:
7+
tap_action:
8+
action: "navigate"
9+
navigation_path: "[[[ return entity?.attributes?.navigation ? entity?.attributes?.navigation : 'none'; ]]]"
10+
hold_action:
11+
action: "more-info"
12+
entity: "[[[ return entity.entity_id; ]]]"
13+
ulm_active_state: >
14+
[[[
15+
let not_active = ['0','disarmed','off','closed','not_home','standby','idle','docked','unknown','unavailable','paused']
16+
function containsNumbers(str) {
17+
return /\d/.test(str);
18+
}
19+
if (!not_active.includes(entity.state)) {
20+
if (containsNumbers(entity.state)) {
21+
return entity?.state;
22+
}
23+
return entity?.state;
24+
}
25+
]]]
26+
27+
size: "45%"
28+
aspect_ratio: "1/1"
29+
show_icon: true
30+
show_label: true
31+
show_name: false
32+
label: "[[[ return variables.ulm_active_state ]]]"
33+
34+
tap_action:
35+
action: "[[[ return variables?.tap_action?.action ? variables.tap_action.action : 'none'; ]]]"
36+
navigation_path: "[[[ return variables.tap_action.navigation_path; ]]]"
37+
url_path: "[[[ return variables.tap_action.url_path; ]]]"
38+
service: "[[[ return variables.tap_action.service; ]]]"
39+
service_data: "[[[ return variables.tap_action.service_data; ]]]"
40+
hold_action:
41+
action: "[[[ return variables?.hold_action?.action ? variables.hold_action.action : 'none'; ]]]"
42+
navigation_path: "[[[ return variables.hold_action.navigation_path; ]]]"
43+
url_path: "[[[ return variables.hold_action.url_path; ]]]"
44+
service: "[[[ return variables.hold_action.service; ]]]"
45+
service_data: "[[[ return variables.hold_action.service_data; ]]]"
46+
47+
48+
state:
49+
- value: "unavailable"
50+
styles:
51+
custom_fields:
52+
notification:
53+
- border-radius: "50%"
54+
- position: "absolute"
55+
- right: "6%"
56+
- height: "30%"
57+
- width: "30%"
58+
- line-height: 0
59+
- background-color: "rgba(var(--color-red),1)"
60+
- styles:
61+
label:
62+
- color: "[[[ return variables.ulm_card_status_color ? 'rgba(var(--color-'+variables.ulm_card_status_color+'),1)' : 'rgba(var(--color-theme),0.7)'; ]]]"
63+
- background-color: >
64+
[[[
65+
if (variables.ulm_card_status_badge_bg) {
66+
return variables.ulm_card_status_color ? 'rgba(var(--color-'+variables.ulm_card_status_color+'),0.2)' : 'rgba(var(--color-theme),0.2)';
67+
} else {
68+
return variables.ulm_card_status_color ? 'rgba(var(--color-'+variables.ulm_card_status_color+'),0.0)' : 'rgba(var(--color-theme),0.0)';
69+
}
70+
]]]
71+
icon:
72+
- color: "[[[ return variables.ulm_card_status_color ? 'rgba(var(--color-'+variables.ulm_card_status_color+'),1)' : 'rgba(var(--color-theme),0.7)'; ]]]"
73+
img_cell:
74+
- background-color: "[[[ return variables.ulm_card_status_color ? 'rgba(var(--color-'+variables.ulm_card_status_color+'),0.2)' : 'rgba(var(--color-theme),0.2)'; ]]]"
75+
id: "on"
76+
value: "[[[ return variables.ulm_active_state ]]]"
77+
78+
styles:
79+
label:
80+
- font-weight: "bold"
81+
- font-size: "90%"
82+
- border-radius: "[[[ return variables.ulm_card_status_badge_bg ? '50%' : '0%'; ]]]"
83+
- position: "absolute"
84+
- right: "6%"
85+
- top: "[[[ return variables.ulm_card_status_badge_bg ? '2%' : '0%'; ]]]"
86+
- height: "30%"
87+
- width: "30%"
88+
- line-height: "24px"
89+
- color: "rgba(var(--color-theme),0.2)"
90+
- background-color: "rgba(var(--color-theme),0)"
91+
icon:
92+
- color: "rgba(var(--color-theme),0.2)"
93+
img_cell:
94+
- background-color: "rgba(var(--color-theme),0.05)"
95+
- border-radius: "50%"
96+
- position: "absolute"
97+
- left: "-18%"
98+
- top: "18%"
99+
card:
100+
- border-radius: "15px"
101+
- box-shadow: "var(--box-shadow)"
102+
- padding: "5px"
103+
104+
custom_fields:
105+
notification: >
106+
[[[
107+
if (entity?.state == 'unavailable'){
108+
return '<ha-icon icon="mdi:exclamation" style="width: 100%; height: 100%; color: var(--primary-background-color);"></ha-icon>';
109+
}
110+
]]]

0 commit comments

Comments
 (0)