Entities card: show state_color for an automation but run a script

I currently have two separate entities. One shows the current state of an automation (on/off) including state_color. The second runs a script which disables that automation and toggles a light.

I would like to combine those into a single entity row which:

  • Shows the current state of the automation via state_color
  • Runs the script to disable the automation when tapped
  • Ideally: Allows for custom text (in this case “Snooze”) on the right side.

I have been able to accomplish these things separately but not together in a single entity, maybe it’s not possible.

Here is an example. The first two under the “Attempts” section give all the aspects I’m looking for but the state_color does not work. The section below that includes the items being effected so I can see their state during the testing.

type: entities
entities:
  - type: section
    label: Attempts
  - entity: script.snooze_alerts
    name: Alerts
    icon: mdi:alarm-light
    action_name: snooze
    tap_action:
      action: call-service
      service: script.snooze_alerts
  - type: button
    entity: automation.notify_alerts
    name: Alerts
    icon: mdi:alarm-light
    action_name: snooze
    tap_action:
      action: call-service
      service: script.snooze_alerts
  - type: section
    label: Automation / Entities
  - entity: automation.notify_alerts
    icon: mdi:alarm-light
    name: Alerts
  - entity: light.basement_lamp_bulb
show_header_toggle: false
state_color: true

Here you can see than the automation entity in the lower section shows the state_color like I want, but the attempts at combining them do not, though they do have the other aspects I’m looking for (say “snooze” and run the script).

Here is a mockup of the final result I want.

I can get the desired results with a full blown button card but that does not fit into the dashboard I’m trying to build, unless there’s a way to make it really compact, like the size of an entity row.

type: button
tap_action:
  action: call-service
  service: script.snooze_alerts
entity: automation.notify_alerts
icon: mdi:alarm-light
name: Snooze Alerts

image

I was unable to find a way to do this with the entities card but I did accomplish effectively the same thing with the glances card, though the visual layout isn’t really what I want. i.e the entities card row style so it fits in aesthetically with the rest of the entities in that card

image

type: glance
entities:
  - entity: automation.notify_alerts
    name: Alerts
    icon: mdi:alarm-light
    tap_action:
      action: call-service
      service: script.snooze_alerts
  - entity: light.basement_lamp_bulb
    name: Lamp
show_state: false
columns: 3
state_color: true
show_icon: true

As far as I got the idea you need two things:

  1. Tapping on some element should run a script.
  2. Icon color of some element should reflect a state - on/off.
type: entities
entities:
  - type: button
    name: Do something
    action_name: snooze
    tap_action:
      action: call-service
      service: input_boolean.toggle
      service_data:
        entity_id: input_boolean.test_boolean
    card_mod:
      style: |
        :host {
          {% if is_state('input_boolean.test_boolean','on')%}
          --paper-item-icon-color: var(--paper-item-icon-active-color);
          {% endif %}
        }

image

1 Like

I think you have distilled the criteria well and are correct.

I was hoping to accomplish it with “core” functionality as mods can cause sprawl in terms of added maintenance / compatibility / complexity over time, etc but I suspected mods are the only way to truly accomplish what I want.