Parsing Secrets in If-Then Statements

Is there a way to use a secret from the secrets.yaml file in an if-then statement?

For example, I want to use a code/value/phrase passed from Alexa to HA, then compare that code/value/phrase against a value stored in the secrets.yaml file. The if-then statement is used to determine what response Alexa will say as a response.

As an example, the code below is working for me currently. The alarm code (1111) is currently hard-coded in the if-then statement in the intent:

ArmAlarmAwayIntent:
  action:
    service: alarm_control_panel.alarm_arm_away
    entitiy_id: alarm_control_panel.ha_alarm
    data:
      code: !secret alarm_code
  speech:
    type: plaintext
    text: >
      {%- if Code == "1111" -%}
        Arming the alarm away, Goodbye
      {%- else -%}
        Invalid code, please try again
      {%- endif -%}

I’d like to replace the “1111” with the !secrets alarm_passcode value so that I don’t have to hard-code it in all my automations. Is this possible?

Since I’ve decided that I don’t care much for coding in yaml, I haven’t really played with the capabilities of automations, but if you use appdaemon, this should be easy enough to do. You can either read the secret code from a file using python’s file utilities, or you could take security a step further and hash your codes, and then compare against a hash, rather than storing in plaintext.