#Button card won't refresh

1 messages · Page 1 of 1 (latest)

red owl
#

Hello,
I'm using this template

    type: custom:button-card
    show_icon: false
    show_state: true
    state_display: |
      [[[ 
        return states[variables.base + "_temperature"]?.state ?
        states[variables.base + "_temperature"]?.state + " °C" : ":hourglass_flowing_sand:"; 
      ]]]
    styles:
      card:
        - font-size: 18px
        - height: 110px
        - border-radius: 12px
      name:
        - font-size: 20px
        - font-weight: bold
        - text-align: center
      state:
        - font-size: 24px
        - font-weight: bold
        - color: |
            [[[ 
              const t = parseFloat(states[variables.base + "_temperature"]?.state);
              return isNaN(t) ? '#aaaaaa' :
                    t < 16 ? '#4A90E2' : 
                    t < 21 ? '#50E3C2' :
                    t < 25 ? '#7ED321' :
                    t < 28 ? '#F5A623' : '#D0021B';
            ]]]
      custom_fields:
        humidity:
          - position: absolute
          - bottom: 6px
          - right: 10px
          - font-size: 14px
          - color: |
              [[[ 
                const h = parseFloat(states[variables.base + "_humidity"]?.state);
                return isNaN(h) ? 'white' : h > 60 ? 'orange' : 'white';
              ]]]
        battery:
          - position: absolute
          - bottom: 6px
          - left: 10px
          - font-size: 14px
          - color: white
        updated:
          - position: absolute
          - bottom: 6px
          - left: 50%
          - transform: translateX(-50%)
          - font-size: 10px
          - color: white
        door:
          - position: absolute
          - top: 6px
          - right: 10px
          - font-size: 14px
          - color: |
              [[[ 
                const d = states[variables.window]?.state;
                return d === "on" ? "#D0021B" : "#7ED321"; // rot = offen, grün = zu
              ]]]
    custom_fields:
      humidity: |
        [[[ 
          const h = states[variables.base + "_humidity"]?.state;
          return h ? ":droplet: " + h + " %" : ":droplet: -- %";
        ]]]
      battery: |
        [[[ 
          const b = states[variables.base + "_battery"]?.state;
          return b ? ":battery: " + b + " %" : ":battery: -- %";
        ]]]
      updated: |
        [[[ 
          const updated = new Date(states[variables.base + "_temperature"]?.last_changed);
          const hours = updated.getHours().toString().padStart(2, '0');
          const minutes = updated.getMinutes().toString().padStart(2, '0');
          return ":clock3: " + hours + ":" + minutes;
        ]]]
      door: |
        [[[ 
          const d = states[variables.window]?.state;
          return d === "on" ? ":door: Offen" : d === "off" ? ":door: Zu" : ":door: --";
        ]]]```

like this on a dasshboard:

```type: custom:button-card
name: Büro
template: room_overview_card
variables:
  base: sensor.shellyht_746eb1
  window: binary_sensor.bthome_sensor_2424_window```


When i open and close the shelly BLU Window/Door sensor it wont refresh the state on the button card. 
i placed the entity for testing plain on the dashbaord and the state refreshes there. 
Am i doing something wrong? 

Best regards!
tired seal
red owl