Help with imap email content setup please

 - platform: imap_email_content
   server: imap.gmail.com
   port: 993
   username: !secret gmail_username
   password: !secret gmail_password
   name: rad
   folder: inbox
   senders:
    - [email protected]   
   value_template: >
       {% if is_state_attr('sensor.rad', 'subject', 'Upcoming Visit') %}
          Upcoming Visit
       {% else %}
         {{ states('sensor.rad') }}
       {% endif %}

I’m getting unknown as the sensor state. Pretty sure it’s an error on my part any help would be greatly appreciated