Custom:button-card not updating on value change

custom:button-card doesnt update motionSensor on value change. I’ve added triggers-update: all. and still no go. its update only with refresh page

          - type: custom:button-card
            variables:
              tempsensor: sensor.c3_aio_temperature
              humidsensor: sensor.c3_aio_humidity
              motionSensor: switch.bathroom_fan_upstairs
              fontSize: 1.4rem
              motionIconSize: 16px  
            triggers_update:
              - '[[[ return variables.motionSensor; ]]]'
            entity: switch.bathroom_fan_upstairs
            name: Light
            template:
              - lightt
              - icon_spot
            state_display: >
                [[[
                  function findFirstH1Above(element) {
                    let currentElement = element;
                    while (currentElement) {
                      if (currentElement.shadowRoot) {
                        const shadowH1 = currentElement.shadowRoot.querySelector('h1');
                        if (shadowH1) return shadowH1;
                      }
                      const lightH1 = currentElement.querySelector('h1');
                      if (lightH1) return lightH1;
                      currentElement = currentElement.getRootNode().host;
                      if (!currentElement) break;
                    }
                    return null;
                  }
                
                  let parentElement = this.getRootNode().host;
                  let headerTitle = findFirstH1Above(parentElement);
                
                  if (headerTitle && !headerTitle.dataset.processed) {
                    const tempSensor = parseFloat(states[variables.tempsensor]?.state);
                    const humidSensor = parseFloat(states[variables.humidsensor]?.state);
                    const positionSensor = parseFloat(states[variables.positionSensor]?.state);
                    const motionState = states[variables.motionSensor]?.state;
                    const motionIcon = motionState === 'on' ? 'mdi:motion-sensor' : 'mdi:motion-sensor-off';
                    const fontSize = variables.fontSize || '14px';
                    const motionIconSize = variables.motionIconSize || '20px';
                    let currentTitle = headerTitle.innerText;
                    headerTitle.style.display = 'flex';
                    headerTitle.style.width = '100%';
                    headerTitle.style.justifyContent = 'space-between';
                    headerTitle.style.alignItems = 'center';
                    headerTitle.style.paddingInline = 'inherit';
                    const formattedTemp = !isNaN(tempSensor) ? 
                        (tempSensor % 1 === 0 ? tempSensor.toFixed(0) : tempSensor.toFixed(1)).replace('.', ',') + '°C' : '';
                    const formattedHumid = !isNaN(humidSensor) ? humidSensor.toFixed(0) + '%' : '';
                    const formattedPosition = !isNaN(positionSensor) ? positionSensor.toFixed(0) + '%' : '';
                    let sensorValues = [];
                    if (formattedTemp) sensorValues.push(formattedTemp);
                    if (formattedHumid) sensorValues.push(formattedHumid);
                    if (formattedPosition) sensorValues.push(formattedPosition);
                    const sensorDisplay = sensorValues.join(' / ');
                    const motionIconHTML = states[variables.motionSensor] 
                      ? `<ha-icon icon="${motionIcon}" style="margin-left: 5px; --mdc-icon-size: ${motionIconSize};"></ha-icon>`
                      : '';
                    headerTitle.innerHTML = `
                      <div>${currentTitle}</div>
                      <div style="font-size: ${fontSize}; display: flex; align-items: center;">
                        ${sensorDisplay}
                        ${motionIconHTML}
                      </div>
                    `;
                    headerTitle.dataset.processed = true;
                  }
                ]]]

I could be wrong, but could it be related to the templated trigger_update? What if you set it to “all”?

i tried that aswell, still not working

I think you have made a deadlock for yourself.
The update_trigger is an internal value, so it will only be updated once the update_trigger fires, but that will never fire, because the value only change when it is fired.

Can you set the update_trigger to the sensor directly?

yes i did try this too, same result

triggers_update:

  • ‘[[[ return variables.motionSensor; ]]]’

and

triggers_update:

  • switch.bathroom_fan_upstairs

from my understanding the triggers update only fire when there a change in value and re run the button card, right?