Tsar
(Christian)
February 2, 2022, 8:35am
1
Hi,
I want the color of the button depending of the state of a dropbox, but this doesn’t work :
type: custom:button-card
name: living
icon: mdi:stop
state:
- value: 'on'
color: >
[[[
if (states['input_select.airco_modus'].state == 'heat')
return "red";
return "blue";
]]]
- value: 'off'
spin: false
tap_action:
action: call-service
service: climate.turn_off
service_data:
entity_id:
- climate.airco_living_links
- climate.airco_living_rechts
target: {}
entity: binary_sensor.airco_living_is_on
tom_l
February 2, 2022, 11:09am
2
Try this:
state:
- value: 'on'
color: >
[[[
if (states['input_select.airco_modus'].state == 'heat')
return 'red';
else
return 'blue';
]]]
1 Like
tom_l
February 2, 2022, 11:43am
4
- type: custom:button-card
[...]
state:
- value: 'on'
styles:
state:
color: >
[[[
if (states['input_select.airco_modus'].state == 'heat')
return 'red';
else
return 'blue';
]]]
icon:
color: >
[[[
if (states['input_select.airco_modus'].state == 'heat')
return 'red';
else
return 'blue';
]]]
tom_l
February 2, 2022, 12:11pm
6
Tsar
(Christian)
February 2, 2022, 1:17pm
7
Yes, found it !
- operator: template
value: |
[[[
return (states['input_select.airco_modus'].state == 'heat') && (states['binary_sensor.airco_living_is_on'].state == 'on')
]]]
color: red
spin: false
- operator: template
value: |
[[[
return (states['input_select.airco_modus'].state == 'cool') && (states['binary_sensor.airco_living_is_on'].state == 'on')
]]]
color: powderblue
spin: false
- operator: default
spin: false
Instead of looking to the dropdown box, I would like to see the state of my aircon.
So, I did this :
- operator: template
value: |
[[[
return (states['climate.airco_living_links'].attributes.hvac_modes == 'heat') && (states['binary_sensor.airco_living_is_on'].state == 'on')
]]]
color: red
spin: false
But this doesn’t work…any idea ?
Tsar
(Christian)
February 2, 2022, 1:38pm
8
Found it : states[‘climate.airco_living_links’].state
Fzibi21
(Fzibi21)
November 2, 2022, 2:19pm
9
hello there:
I am trying to get the color changed in a button card wenn a particular script is running . can someone help ?
type: vertical-stack
cards:
- type: custom:mushroom-vacuum-card
entity: vacuum.rocky
commands:
- start_pause
- stop
- return_home
- locate
- square: true
columns: 4
type: grid
cards:
- show_name: true
show_icon: true
type: button
tap_action:
action: call-service
service: script.1643022832589
data: {}
target: {}
entity: vacuum.rocky
icon: mdi:stairs
name: Hallway
theme: Mushroom
- show_name: true
show_icon: true
type: button
tap_action:
action: call-service
service: script.1642517723169
data: {}
target: {}
entity: vacuum.rocky
icon: mdi:toilet
name: Bathroom
- show_name: true
show_icon: true
type: button
tap_action:
action: call-service
service: script.1647465285998
data: {}
target: {}
entity: vacuum.rocky
icon: mdi:washing-machine-alert
name: HTR
- show_name: true
show_icon: true
type: button
tap_action:
action: call-service
service: script.kitchen
data: {}
target: {}
entity: vacuum.rocky
icon: mdi:countertop-outline
name: Kitchen
- show_name: true
show_icon: true
type: button
tap_action:
action: call-service
service: script.dinner
data: {}
target: {}
entity: vacuum.rocky
icon: mdi:silverware-fork-knife
name: Dinning
- show_name: true
show_icon: true
type: button
tap_action:
action: call-service
service: script.living
data: {}
target: {}
entity: vacuum.rocky
icon: mdi:sofa
name: Living Room
- show_name: true
show_icon: true
type: button
tap_action:
action: call-service
service: script.1643021333614
data: {}
target: {}
entity: vacuum.rocky
icon: mdi:chair-rolling
name: Office
- show_name: true
show_icon: true
type: button
tap_action:
action: call-service
service: script.empty
data: {}
target: {}
entity: vacuum.rocky
icon: mdi:delete-empty
name: Empty
MrThiemann
(Mr Thiemann)
November 2, 2022, 6:38pm
10
I’m not so sure if you can intercept the state of the script?!
executing it triggers only a short impulse… maybe install a helper here that is switched on as long as the script is running?
the condition could then be determined.
I am trying to make the mdi:lock icon turn red when the alarm (Ring) is armed, the rest of the time it remains black. The button itself does not control the alarm it merely navigates to the alarm page but it would be useful to see at a glance when the alarm is armed.
I have been trying to get this working without success - anyone help?
type: custom:button-card
tap_action:
action: navigate
navigation_path: fire01_alarm
operator: template
value: |
[[[
return (states['alarm_control_panel.lancaster_alarm'].state == 'armed_away')
return 'red';
]]]
color: red
spin: false
icon: mdi:lock
styles:
card:
- border-radius: 5px
- width: 100px
icon:
- width: 55%
style: |
ha-card {
background: transparent
}