Automation template: empty "else" part

Try replacing the empty string with a states() function that reports the sensor’s own (previous) value.

  - platform: template
    sensors:
      amount_spent:
        friendly_name: "Amount Spent"
        value_template: >
          {% set amount = state_attr('sensor.sm_g977u_last_notification', 'android.text') %}
          {{ iif(amount is not search('AMZN|online|GOOGLE|PAYPAL', false), amount.split()[2], states('sensor.amount_spent')) }}

1 Like

Sorry, for the delayed reply. I had to wait for more charges on my card until I could see if this was working. It is working perfectly. Thank you so much!

1 Like