#Icon color based on different entity state for custom: button-card

1 messages · Page 1 of 1 (latest)

tulip breach
#

Hello,
i have created button to run a script for AC control.

show_icon: true
color_type: icon
type: custom:button-card
entity: script.ac_office_cool
tap_action:
  action: perform-action
  perform_action: script.turn_on
  target:
    entity_id: script.ac_office_cool
  data: {}```
This works fine and it does run the script.
How can i color icon of this button based on the state of the AC entity this script controls (so that means different entity from the script itself)?

script entity : `script.ac_office_cool`
AC entity : `climate.ac_office` and from developer tools : `climate.ac_office.hvac_modes` contains list of all states of the unit
sly peak
#

You can simply put climate.ac_office as the card's entity. The tap action will still run the script.
If you're looking to customize the card based on the state, here's an example for you: ```yaml
type: custom:button-card
entity: climate.hvac
show_name: false
show_icon: true
color_type: icon
tap_action:
action: perform-action
perform_action: script.turn_on
target:
entity_id: script.ac_office_cool
data: {}
state:

  • value: 'cool'
    styles:
    icon:
    - color: blue
    card:
    - background-color: deepskyblue
  • value: 'heat'
    styles:
    icon:
    - color: red
    card:
    - background-color: maroon
#

Also, the custom:button-card can be configured to run different scripts based on the state of the entity. For example, if the entity's state is cool, have it run script.ac_office_cool. But, if it is set to heat, have it run script.ac_office_heat. (or whatever the case may be.) The custom:button-card is one of the few cards that can pull this off. (The alternative would be to work both scripts into one and have it figure out how it needs to run.)

tulip breach
#

this is great, thanks a lot
it's matter of how to think about it, in this case the entity setting
retrospectively it makes sense, after all i want to set it based on climate.ac_office entity so that should be the entity for the button