Text entry control by automation

I want to enter 2 numerical codes and use a button to pass the code to an esphome device that actuates … in my case the front door lock. The problem is the conditions in the automation are not applied and the script running the automation and just activates the lock

Automation yamll

‘’’
alias: lockFrontDoor
description: security door control actions
triggers:

  • trigger: state
    entity_id:
    • script.lock_front_door_2
      to:
      conditions:
  • condition: and
    conditions:
    • condition: state
      entity_id: input_text.text1
      attribute: pattern
      state: ‘314159’
    • condition: state
      entity_id: input_text.text2
      attribute: pattern
      state: ‘2.718’
      actions:
  • type: turn_on
    device_id: f757fad91cc2dd9857bd4c4c2ec1d4be
    entity_id: 27bc859d73ffec574346acdc33cb9da9
    domain: switch
  • action: notify.notify
    metadata: {}
    data:
    message: Front Door accessed
  • delay:
    hours: 0
    minutes: 0
    seconds: 10
    milliseconds: 0
  • data:
    value: ‘“”’
    target:
    entity_id: input_text.text1
    action: input_text.set_value
  • data:
    value: ‘“”’
    target:
    entity_id: input_text.text2
    action: input_text.set_value
    mode: single

# and the script that uses a runs the automation from the actuation of a dash board switch
#**script yaml** 

action: automation.trigger
target:
entity_id: automation.lockfrontdoor
data:
skip_condition: false

Hello Paul,
Thanks for coming here and asking a question.
Would you be so kind as to adjusting the format of your code so that we can read it properly & check the YAML spacing, etc. Editing your original is the preferred way. It is very hard for us to tell what is what when the text formatter jumbles everything like that.
You can use the </> button like this… How to format your code in forum posts
OR… Here is an example of how to fix formatting from the site FAQ Page.
How to help us help you - or How to ask a good question.

Ok I think I have cracked it by adding a value template. The actions at the end blank the codes entered after 10s

‘’’

alias: Un lock Front Door
description: security door control actions
triggers:

  • trigger: state
    entity_id:
    • script.lock_front_door_2
      to: null
      conditions:
  • condition: and
    conditions:
    • condition: template

    your own code should go in regex_match

    value_template: "{{ states('input_text.text1') | regex_match('123456') }}"
    
    • condition: template
      value_template: “{{ states(‘input_text.text2’) | regex_match(‘6.789’) }}”
      actions:
  • type: turn_on
    device_id: f757fad91cc2dd9857bd4c4c2ec1d4be
    entity_id: 9ee6947d79b05e44c1d7fcd4f2abf43a
    domain: switch
  • action: notify.notify
    metadata: {}
    data:
    message: Front Door accessed
  • delay:
    hours: 0
    minutes: 0
    seconds: 10
    milliseconds: 0
  • data:
    value: “""”
    target:
    entity_id: input_text.text1
    action: input_text.set_value
  • data:
    value: “""”
    target:
    entity_id: input_text.text2
    action: input_text.set_value
    mode: single
    ‘’’