Sensor don't update (Button card, template, custom_field)

Hi All,

I have a washing machine, connected through “Home connect”, the device contains an entity “sensor.washing_machine_operation_state” providing me with the operating state being either DelayedStart, Finished, Run, Ready.

I would like to use this state as a frontend formatting condition but i have a problem, the string (do i use the right term?) I use doesn’t update with the entity. So the first time I called the state it was DelayedStart, how it has changed on the entity but i still get DelayedStart from my string.

As you may notice, my thermology isn’t up there and it made looking for a solution very difficult.

this is what I’m trying to do, but as said, it doesn’t update. Could anyone help me out?

    custom_fields:
      i: |
        [[[
          if ((states['sensor.washing_machine_operation_state'].state) == 'DelayedStart') return '<ha-icon icon="mdi:clock-outline" style="width: 38%; height: 38%; color: green;">'; 
          if ((states['sensor.washing_machine_operation_state'].state) == 'Finished') return ''; 
          if ((states['sensor.washing_machine_operation_state'].state) == 'Run') return (states['sensor.washmachine_remaining_minutes'].state) + 'min'; 
          if ((states['sensor.washing_machine_operation_state'].state) == 'Ready') return ''; 
          else return "";
        ]]]

Thanks in advance

Edit: I Tried taking it out of the template and put it right in to the card but that didn’t work

Use triggers_update in your card. For explanation see second case here.


type: custom:button-card
entity: sensor.your_sensor
triggers_update: all
custom_fields:
  i: |
    [[[
      if (entity.state == 'DelayedStart') return '<ha-icon icon="mdi:clock-outline" style="width: 38%; height: 38%; color: green;">'; 
      if (entity.state == 'Run') return (states['sensor.washmachine_remaining_minutes']?.state) + 'min'; 
      else return null;
    ]]]

Thanks! I tried this, found the same case, but didn’t work.

I tried to post my solution yesterday but the server was down. Somewhere in my code I put down “=” instead of “==”. problem was gone after i fixed this typo.