custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.97k stars 242 forks source link

Custom_fields not update in popup card #667

Closed Veuchez closed 1 year ago

Veuchez commented 1 year ago

This button has a custom_fields "notifications" that updates based on the state of a sensor.

type: custom:mod-card
card_mod:
  style: |
    ha-card {
    background:none;
    border:0;
    border-radius:0 10px 10px 0!important;
    box-shadow:0 0;
    transition:none
    }
card:
  type: vertical-stack
  cards:
    - type: custom:button-card
      color: auto
      entity: input_select.smarther_cucina_setboost
      name: BOOST
      tap_action:
        action: call-service
        service: input_select.select_next
        service_data:
          entity_id: input_select.smarther_cucina_setboost
      hold_action:
        action: call-service
        service: script.smarther_cucina_spegnimento_boost_automatic_mode
      show_state: false
      size: 30px
      state:
        - value: 0.1
          color: var(--disabled-text-color)
          icon: mdi:play-speed
          name: |
            [[[
              if (states['input_select.smarther_cucina_language'].state == 'EN') { 
                return 'SET BOOST';
              } if (states['input_select.smarther_cucina_language'].state == 'IT') { 
                  return 'IMPOSTA BOOST';
                }
            ]]]
        - value: 30
          color: rgb(255, 153, 153)
          icon: mdi:play-speed
          name: BOOST 30
        - value: 60
          color: rgb(255, 102, 102)
          icon: mdi:play-speed
          name: BOOST 60
        - value: 90
          color: rgb(255, 80, 80)
          icon: mdi:play-speed
          name: BOOST 90
      styles:
        card:
          - font-size: 10px
          - background: none
          - border: 0
          - border-radius: 0
          - box-shadow: 0 0
          - margin-top: '-2px'
          - transition: none
        custom_fields:
          notification:
            - background-color: |
                [[[
                  if (states['sensor.smarther_cucina_fine_boost_minuti'].state > 0)
                    return "red";
                  return "none";
                ]]]
            - border-radius: 50%
            - position: absolute
            - left: 64%
            - top: 10%
            - height: 15px
            - width: 15px
            - font-size: 9px
            - line-height: 15px
            - color: white
      custom_fields:
        notification: |
          [[[ 
            if (states['sensor.smarther_cucina_fine_boost_minuti'].state > 0) 
                return states['sensor.smarther_cucina_fine_boost_minuti'].state;
            return ' ';
          ]]]

When I insert this button in a popup custom_fields "notifications" not update. it only updates when I refresh the page. How come? am I doing something wrong?

type: custom:button-card
size: 60%
show_name: false
show_state: false
tap_action:
  action: fire-dom-event
  browser_mod:
    service: browser_mod.popup
    data:
      card_mod:
        style:
          ha-dialog$: |
            .mdc-dialog .mdc-dialog__container .mdc-dialog__surface {
              #width:100%;
              box-shadow:none;
              border-radius: 0px;
              border: 0px !important;
              background: none;
            } 
      content:
        type: custom:mod-card
        card_mod:
          style: |
            ha-card {
            background:none;
            border:0;
            border-radius:0 10px 10px 0!important;
            box-shadow:0 0;
            transition:none
            }
        card:
          type: vertical-stack
          cards:
            - type: custom:button-card
              color: auto
              entity: input_select.smarther_cucina_setboost
              name: BOOST
              tap_action:
                action: call-service
                service: input_select.select_next
                service_data:
                  entity_id: input_select.smarther_cucina_setboost
              hold_action:
                action: call-service
                service: script.smarther_cucina_spegnimento_boost_automatic_mode
              show_state: false
              size: 30px
              state:
                - value: 0.1
                  color: var(--disabled-text-color)
                  icon: mdi:play-speed
                  name: |
                    [[[
                      if (states['input_select.smarther_cucina_language'].state == 'EN') { 
                        return 'SET BOOST';
                      } if (states['input_select.smarther_cucina_language'].state == 'IT') { 
                          return 'IMPOSTA BOOST';
                        }
                    ]]]
                - value: 30
                  color: rgb(255, 153, 153)
                  icon: mdi:play-speed
                  name: BOOST 30
                - value: 60
                  color: rgb(255, 102, 102)
                  icon: mdi:play-speed
                  name: BOOST 60
                - value: 90
                  color: rgb(255, 80, 80)
                  icon: mdi:play-speed
                  name: BOOST 90
              styles:
                card:
                  - font-size: 10px
                  - background: none
                  - border: 0
                  - border-radius: 0
                  - box-shadow: 0 0
                  - margin-top: '-2px'
                  - transition: none
                custom_fields:
                  notification:
                    - background-color: |
                        [[[
                          if (states['sensor.smarther_cucina_fine_boost_minuti'].state > 0)
                            return "red";
                          return "none";
                        ]]]
                    - border-radius: 50%
                    - position: absolute
                    - left: 64%
                    - top: 10%
                    - height: 15px
                    - width: 15px
                    - font-size: 9px
                    - line-height: 15px
                    - color: white
              custom_fields:
                notification: >
                  [[[ 
                    if (states['sensor.smarther_cucina_fine_boost_minuti'].state > 0) 
                        return states['sensor.smarther_cucina_fine_boost_minuti'].state;
                    return ' ';
                  ]]]
RomRider commented 1 year ago

browser_mod has been updated to address this, I think. This has nothing to do with button-card, I'm closing it.