Skip to content

Icon Actions Inconsistencies #1034

@GGSSDD

Description

@GGSSDD

Checklist

  • I updated the card to the latest version available
  • I cleared the cache of my browser

Describe the bug
I have a setup where I use the custom button card in a Decluttering Card template. In the frontend the Decluttering Card is duplicated inside a Swipe Swipe with different values set for each repetition. I have dynamic actions set for the Button Card, already adapted to the new breaking changes introduced with the 5.0 version (meaning the use of “javascript”). The card actions used to work just fine and they still do, but the icon actions are all messed up, even though I never touched those, so they should’ve been disabled by default. I’ve tried everything, setting the icon_action to none, it didn’t work, setting the icon_action to match the card *_action, nothing, it’s all scrambled, and nothing works, icon actions related. I have other similar setups, with Decluttering templates and custom card actions but they behave as expected.

Version of the card
Version: 5.0.2

To Reproduce
This is the configuration I used:

Relevant part of Decluttering template:

type: conditional
conditions:
  - condition: state
    entity: '[[switch1]]'
    state_not: unknown
card:
  type: custom:button-card
  card_mod:
    style: |
      ha-card {
        height: 35px !important;
      }
  entity: '[[switch1]]'
  show_state: false
  show_name: false
  show_icon: true
  icon: |
    [[[ 
      const ent = states['[[switch1]]'];
      const iconOn = '[[switch1_icon_state_on]]' ? '[[switch1_icon_state_on]]' : null;
      const iconOff = '[[switch1_icon_state_off]]' ? '[[switch1_icon_state_off]]' : null;

      if (['on', 'open'].includes(ent.state))
        return iconOn || ent.attributes.icon;

      if (['off', 'closed'].includes(ent.state))
        return iconOff || ent.attributes.icon;

      return ent.attributes.icon;
    ]]]
  tap_action:
    action: javascript
    javascript: |
      [[[
        const entityId = '[[switch1]]';
        const actionType = '[[switch1_action_type]]';
        if (actionType !== 'tap') return;
        hass.callService('homeassistant', 'toggle', { entity_id: entityId });
      ]]]
  double_tap_action:
    action: javascript
    javascript: |
      [[[
        const entityId = '[[switch1]]';
        const actionType = '[[switch1_action_type]]';
        if (actionType !== 'double_tap') return;
        hass.callService('homeassistant', 'toggle', { entity_id: entityId });
      ]]]
  hold_action:
    action: javascript
    javascript: |
      [[[
        const entityId = '[[switch1]]';
        const actionType = '[[switch1_action_type]]';
        if (actionType !== 'hold') return;
        hass.callService('homeassistant', 'toggle', { entity_id: entityId });
      ]]]
  styles:
    card:
      - border-radius: 50%
      - padding: 0
      - background: rgba(200, 200, 190, 1)
      - box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.7), inset 0px 2px 1px rgba(255, 255, 255, 0.7), inset 0px -1px 2px rgba(0, 0, 0, 0.6)
      - z-index: 100
    icon:
      - width: 17px
      - color: rgba(110, 110, 100, 1)
  state:
    - value: 'on'
      styles:
        card:
          - background: >
              linear-gradient(to bottom, rgba(230, 135, 9, 1), rgba(255, 145, 9, 1))
          - box-shadow: >
              inset 0px 2px 4px rgba(0, 0, 0, 0.5),
              inset 0px -2px 4px rgba(255, 200, 150, 1)
        icon:
          - color: white
    - value: 'open'
      styles:
        card:
          - background: >
              linear-gradient(to bottom, rgba(230, 135, 9, 1), rgba(255, 145, 9, 1))
          - box-shadow: >
              inset 0px 2px 4px rgba(0, 0, 0, 0.5),
              inset 0px -2px 4px rgba(255, 200, 150, 1)
        icon:
          - color: white
  view_layout:
    grid-area: switch1

Relevant part of Frontend setup:

type: custom:mod-card
style:
  swipe-card$: |
    swiper-slide {
      backface-visibility: hidden !important;
      -webkit-backface-visibility: hidden !important;
      transform-style: preserve-3d !important;
      will-change: transform;
      -webkit-transform: translateZ(0);
    }
  style: |
    ha-card {
      background-color: none !important;
      padding: 0;
    }
card:
  type: custom:swipe-card
  start_card: 4
  parameters:
    effect: fade
    fadeEffect:
      crossFade: true
    speed: 1200
    mousewheel: true
  cards:
    - type: custom:decluttering-card
      template: custom_area_card
      variables:
        - area_title: Outdoor Front
        - sensor1: sensor.gc131_twc_temperature
        - sensor2: sensor.gc131_twc_relative_humidity
        - sensor3: ""
        - switch1: switch.cruiser_detection
        - switch1_action_type: tap
        - switch1_icon_state_on: ""
        - switch1_icon_state_off: ""
        - switch2: switch.zb_septic_pump_toggle
        - switch2_action_type: tap
        - switch2_icon_state_on: ""
        - switch2_icon_state_off: ""
        - switch3: input_boolean.vto_unlock_area_card
        - switch3_action_type: hold
        - switch3_icon_state_on: ""
        - switch3_icon_state_off: ""
        - switch4: ""
        - switch4_action_type: ""
        - switch4_icon_state_on: ""
        - switch4_icon_state_off: ""
        - switch5: ""
        - switch5_action_type: ""
        - switch5_icon_state_on: ""
        - switch5_icon_state_off: ""
        - switch6: ""
        - switch6_action_type: ""
        - switch6_icon_state_on: ""
        - switch6_icon_state_off: ""
        - switch7: ""
        - switch7_action_type: ""
        - switch7_icon_state_on: ""
        - switch7_icon_state_off: ""
        - switch8: ""
        - switch8_action_type: ""
        - alert1: alarm_control_panel.gc131_alarm
        - alert2: binary_sensor.cruiser_motionalarm
        - alert3: binary_sensor.interfon_button_pressed
        - alert4: ""
        - alert5: ""
        - alert6: ""
    - type: custom:decluttering-card
      template: custom_area_card
      variables:
        - area_title: Outdoor Back
        - sensor1: sensor.gc131_twc_temperature
        - sensor2: sensor.gc131_twc_relative_humidity
        - sensor3: ""
        - switch1: switch.bullet_detection
        - switch1_action_type: tap
        - switch1_icon_state_on: ""
        - switch1_icon_state_off: ""
        - switch2: ""
        - switch2_action_type: ""
        - switch2_icon_state_on: ""
        - switch2_icon_state_off: ""
        - switch3: ""
        - switch3_action_type: ""
        - switch3_icon_state_on: ""
        - switch3_icon_state_off: ""
        - switch4: ""
        - switch4_action_type: ""
        - switch4_icon_state_on: ""
        - switch4_icon_state_off: ""
        - switch5: ""
        - switch5_action_type: ""
        - switch5_icon_state_on: ""
        - switch5_icon_state_off: ""
        - switch6: ""
        - switch6_action_type: ""
        - switch6_icon_state_on: ""
        - switch6_icon_state_off: ""
        - switch7: ""
        - switch7_action_type: ""
        - switch7_icon_state_on: ""
        - switch7_icon_state_off: ""
        - switch8: ""
        - switch8_action_type: ""
        - switch8_icon_state_on: ""
        - switch8_icon_state_off: ""
        - alert1: alarm_control_panel.gc131_alarm
        - alert2: binary_sensor.bullet_motionalarm
        - alert3: ""
        - alert4: ""
        - alert5: ""
        - alert6: ""

Expected behavior
The icon actions should match the card actions, or at least to be able to disable them.

Desktop (please complete the following information):

  • Browser: Microsoft Edge
  • Version: latest

Smartphone (please complete the following information):

  • Device: iPhone 11 Pro
  • OS: 18.7.1
  • Browser: Conpanion App
  • Version: latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions